| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "test_comparers.h" | ||
| 2 | #include "gate/comparers.h" | ||
| 3 | #include "gate/strings.h" | ||
| 4 | #include "gate/guids.h" | ||
| 5 | #include "gate/times.h" | ||
| 6 | |||
| 7 | #define COMPARE_LESSER_WITH_GREATER_VALUE(cmp_func, lval, gval) \ | ||
| 8 | GATE_TEST_CHECK( cmp_func (&lval, &gval) < 0); \ | ||
| 9 | GATE_TEST_CHECK( cmp_func (&gval, &lval) > 0); \ | ||
| 10 | GATE_TEST_CHECK( cmp_func (&lval, &lval) == 0); | ||
| 11 | |||
| 12 | #define GENERATE_TYPE_COMPARE_TEST(g_type, cmp_func) do { \ | ||
| 13 | static const g_type a = (g_type)10; \ | ||
| 14 | static const g_type b = (g_type)20; \ | ||
| 15 | COMPARE_LESSER_WITH_GREATER_VALUE(cmp_func, a, b); \ | ||
| 16 | } while(0) | ||
| 17 | |||
| 18 | |||
| 19 | 1 | GATE_TEST_FUNCTION(test_comparers) | |
| 20 | { | ||
| 21 | 1 | GATE_TEST_UNIT_BEGIN(test_comparers); | |
| 22 | |||
| 23 |
3/6✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
|
1 | GENERATE_TYPE_COMPARE_TEST(gate_int8_t, gate_compare_int8); |
| 24 |
3/6✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
|
1 | GENERATE_TYPE_COMPARE_TEST(gate_int16_t, gate_compare_int16); |
| 25 |
3/6✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
|
1 | GENERATE_TYPE_COMPARE_TEST(gate_int32_t, gate_compare_int32); |
| 26 |
3/6✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
|
1 | GENERATE_TYPE_COMPARE_TEST(gate_int64_t, gate_compare_int64); |
| 27 |
3/6✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
|
1 | GENERATE_TYPE_COMPARE_TEST(gate_uint8_t, gate_compare_uint8); |
| 28 |
3/6✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
|
1 | GENERATE_TYPE_COMPARE_TEST(gate_uint16_t, gate_compare_uint16); |
| 29 |
3/6✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
|
1 | GENERATE_TYPE_COMPARE_TEST(gate_uint32_t, gate_compare_uint32); |
| 30 |
3/6✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
|
1 | GENERATE_TYPE_COMPARE_TEST(gate_uint64_t, gate_compare_uint64); |
| 31 |
3/6✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
|
1 | GENERATE_TYPE_COMPARE_TEST(gate_intptr_t, gate_compare_intptr); |
| 32 |
3/6✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
|
1 | GENERATE_TYPE_COMPARE_TEST(gate_uintptr_t, gate_compare_uintptr); |
| 33 |
3/6✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
|
1 | GENERATE_TYPE_COMPARE_TEST(gate_real32_t, gate_compare_real32); |
| 34 |
3/6✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
|
1 | GENERATE_TYPE_COMPARE_TEST(gate_real64_t, gate_compare_real64); |
| 35 | |||
| 36 | do { | ||
| 37 | static gate_bool_t const a = false; | ||
| 38 | static gate_bool_t const b = true; | ||
| 39 |
3/6✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
|
1 | COMPARE_LESSER_WITH_GREATER_VALUE(gate_compare_bool, a, b); |
| 40 | } while (0); | ||
| 41 | |||
| 42 | do { | ||
| 43 | static gate_cstr_t const a = "a"; | ||
| 44 | static gate_cstr_t const b = "aa"; | ||
| 45 |
3/6✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
|
1 | COMPARE_LESSER_WITH_GREATER_VALUE(gate_compare_cstring, a[0], b[0]); |
| 46 | } while (0); | ||
| 47 | |||
| 48 | do { | ||
| 49 | static gate_wstr_t const a = L"a"; | ||
| 50 | static gate_wstr_t const b = L"aa"; | ||
| 51 |
3/6✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
|
1 | COMPARE_LESSER_WITH_GREATER_VALUE(gate_compare_wstring, a[0], b[0]); |
| 52 | } while (0); | ||
| 53 | |||
| 54 | do { | ||
| 55 | static gate_string_t const a = GATE_STRING_INIT_STATIC("a"); | ||
| 56 | static gate_string_t const b = GATE_STRING_INIT_STATIC("aa"); | ||
| 57 |
3/6✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
|
1 | COMPARE_LESSER_WITH_GREATER_VALUE(gate_compare_string, a, b); |
| 58 | } while (0); | ||
| 59 | |||
| 60 | do { | ||
| 61 | static gate_string_t const a = GATE_STRING_INIT_STATIC("a"); | ||
| 62 | static gate_string_t const b = GATE_STRING_INIT_STATIC("AA"); | ||
| 63 |
3/6✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
|
1 | COMPARE_LESSER_WITH_GREATER_VALUE(gate_compare_string_ic, a, b); |
| 64 | } while (0); | ||
| 65 | |||
| 66 | do { | ||
| 67 | static gate_guid_t const a = GATE_GUID_INIT(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); | ||
| 68 | static gate_guid_t const b = GATE_GUID_INIT(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12); | ||
| 69 |
3/6✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
|
1 | COMPARE_LESSER_WITH_GREATER_VALUE(gate_compare_guid, a, b); |
| 70 | } while (0); | ||
| 71 | |||
| 72 | do { | ||
| 73 | static gate_date_t const a = GATE_DATE_INIT(2018, 10, 6); | ||
| 74 | static gate_date_t const b = GATE_DATE_INIT(2018, 10, 7); | ||
| 75 | static gate_date_t const c = GATE_DATE_INIT(2018, 11, 6); | ||
| 76 | static gate_date_t const d = GATE_DATE_INIT(2019, 10, 6); | ||
| 77 |
3/6✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
|
1 | COMPARE_LESSER_WITH_GREATER_VALUE(gate_compare_date, a, b); |
| 78 |
3/6✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
|
1 | COMPARE_LESSER_WITH_GREATER_VALUE(gate_compare_date, a, c); |
| 79 |
3/6✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
|
1 | COMPARE_LESSER_WITH_GREATER_VALUE(gate_compare_date, a, d); |
| 80 | } while (0); | ||
| 81 | |||
| 82 | do { | ||
| 83 | static gate_daytime_t const a = GATE_DAYTIME_INIT(12, 15, 30, 500000); | ||
| 84 | static gate_daytime_t const b = GATE_DAYTIME_INIT(12, 15, 30, 500001); | ||
| 85 | static gate_daytime_t const c = GATE_DAYTIME_INIT(12, 15, 31, 500000); | ||
| 86 | static gate_daytime_t const d = GATE_DAYTIME_INIT(12, 16, 30, 500000); | ||
| 87 | static gate_daytime_t const e = GATE_DAYTIME_INIT(13, 15, 30, 500000); | ||
| 88 |
3/6✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
|
1 | COMPARE_LESSER_WITH_GREATER_VALUE(gate_compare_daytime, a, b); |
| 89 |
3/6✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
|
1 | COMPARE_LESSER_WITH_GREATER_VALUE(gate_compare_daytime, a, c); |
| 90 |
3/6✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
|
1 | COMPARE_LESSER_WITH_GREATER_VALUE(gate_compare_daytime, a, d); |
| 91 |
3/6✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
|
1 | COMPARE_LESSER_WITH_GREATER_VALUE(gate_compare_daytime, a, e); |
| 92 | } while (0); | ||
| 93 | |||
| 94 | do { | ||
| 95 | static gate_datetime_t const a = GATE_DATETIME_INIT(2018, 10, 6, 12, 15, 30, 500000); | ||
| 96 | static gate_datetime_t const b = GATE_DATETIME_INIT(2018, 10, 6, 12, 15, 30, 500001); | ||
| 97 | static gate_datetime_t const c = GATE_DATETIME_INIT(2018, 10, 7, 12, 15, 30, 500000); | ||
| 98 |
3/6✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
|
1 | COMPARE_LESSER_WITH_GREATER_VALUE(gate_compare_datetime, a, b); |
| 99 |
3/6✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
|
1 | COMPARE_LESSER_WITH_GREATER_VALUE(gate_compare_datetime, a, c); |
| 100 | } while (0); | ||
| 101 | |||
| 102 | do { | ||
| 103 | static gate_time_t const a = { 1, 1 }; | ||
| 104 | static gate_time_t const b = { 1, 2 }; | ||
| 105 | static gate_time_t const c = { 2, 1 }; | ||
| 106 |
3/6✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
|
1 | COMPARE_LESSER_WITH_GREATER_VALUE(gate_compare_time, a, b); |
| 107 |
3/6✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
|
1 | COMPARE_LESSER_WITH_GREATER_VALUE(gate_compare_time, a, c); |
| 108 | } while (0); | ||
| 109 | |||
| 110 | 1 | GATE_TEST_UNIT_END; | |
| 111 | } | ||
| 112 |