| 9 | assert_d_eq(err, 0, "Unexpected failure"); |
| 10 | } |
| 11 | TEST_END |
| 12 | |
| 13 | TEST_BEGIN(test_malloc_strtoumax) { |
| 14 | struct test_s { |
| 15 | const char *input; |
| 16 | const char *expected_remainder; |
| 17 | int base; |
| 18 | int expected_errno; |
| 19 | const char *expected_errno_name; |
| 20 | uintmax_t expected_x; |
| 21 | }; |
| 22 | #define ERR(e) e, #e |
| 23 | #define KUMAX(x) ((uintmax_t)x##ULL) |
| 24 | #define KSMAX(x) ((uintmax_t)(intmax_t)x##LL) |
| 25 | struct test_s tests[] = { |
| 26 | {"0", "0", -1, ERR(EINVAL), UINTMAX_MAX}, |
| 27 | {"0", "0", 1, ERR(EINVAL), UINTMAX_MAX}, |
| 28 | {"0", "0", 37, ERR(EINVAL), UINTMAX_MAX}, |
| 29 | |
| 30 | {"", "", 0, ERR(EINVAL), UINTMAX_MAX}, |
| 31 | {"+", "+", 0, ERR(EINVAL), UINTMAX_MAX}, |
| 32 | {"++3", "++3", 0, ERR(EINVAL), UINTMAX_MAX}, |
| 33 | {"-", "-", 0, ERR(EINVAL), UINTMAX_MAX}, |
| 34 | |
| 35 | {"42", "", 0, ERR(0), KUMAX(42)}, |
| 36 | {"+42", "", 0, ERR(0), KUMAX(42)}, |
| 37 | {"-42", "", 0, ERR(0), KSMAX(-42)}, |
| 38 | {"042", "", 0, ERR(0), KUMAX(042)}, |
| 39 | {"+042", "", 0, ERR(0), KUMAX(042)}, |
| 40 | {"-042", "", 0, ERR(0), KSMAX(-042)}, |
| 41 | {"0x42", "", 0, ERR(0), KUMAX(0x42)}, |
| 42 | {"+0x42", "", 0, ERR(0), KUMAX(0x42)}, |
| 43 | {"-0x42", "", 0, ERR(0), KSMAX(-0x42)}, |
| 44 | |
| 45 | {"0", "", 0, ERR(0), KUMAX(0)}, |
| 46 | {"1", "", 0, ERR(0), KUMAX(1)}, |
| 47 | |
| 48 | {"42", "", 0, ERR(0), KUMAX(42)}, |
| 49 | {" 42", "", 0, ERR(0), KUMAX(42)}, |
| 50 | {"42 ", " ", 0, ERR(0), KUMAX(42)}, |
| 51 | {"0x", "x", 0, ERR(0), KUMAX(0)}, |
| 52 | {"42x", "x", 0, ERR(0), KUMAX(42)}, |
| 53 | |
| 54 | {"07", "", 0, ERR(0), KUMAX(7)}, |
| 55 | {"010", "", 0, ERR(0), KUMAX(8)}, |
| 56 | {"08", "8", 0, ERR(0), KUMAX(0)}, |
| 57 | {"0_", "_", 0, ERR(0), KUMAX(0)}, |
| 58 | |
| 59 | {"0x", "x", 0, ERR(0), KUMAX(0)}, |
| 60 | {"0X", "X", 0, ERR(0), KUMAX(0)}, |
| 61 | {"0xg", "xg", 0, ERR(0), KUMAX(0)}, |
| 62 | {"0XA", "", 0, ERR(0), KUMAX(10)}, |
| 63 | |
| 64 | {"010", "", 10, ERR(0), KUMAX(10)}, |
| 65 | {"0x3", "x3", 10, ERR(0), KUMAX(0)}, |
| 66 | |
| 67 | {"12", "2", 2, ERR(0), KUMAX(1)}, |
| 68 | {"78", "8", 8, ERR(0), KUMAX(7)}, |
nothing calls this directly
no test coverage detected