| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "gate/tests.h" | ||
| 2 | #include "test_values.h" | ||
| 3 | #include "gate/values.h" | ||
| 4 | #include "gate/debugging.h" | ||
| 5 | #include "gate/streams.h" | ||
| 6 | #include "gate/blobs.h" | ||
| 7 | |||
| 8 | struct value_test_matrix | ||
| 9 | { | ||
| 10 | gate_uint16_t type_id; | ||
| 11 | void const* ptr_value; | ||
| 12 | gate_size_t value_size; | ||
| 13 | }; | ||
| 14 | |||
| 15 | ✗ | static gate_result_t GATE_CALL dummy_func(gate_dataptr_t data) | |
| 16 | { | ||
| 17 | GATE_UNUSED_ARG(data); | ||
| 18 | ✗ | return GATE_RESULT_OK; | |
| 19 | } | ||
| 20 | |||
| 21 | static gate_bool_t value_bool = true; | ||
| 22 | static gate_int8_t value_i8 = -123; | ||
| 23 | static gate_uint8_t value_ui8 = 234; | ||
| 24 | static gate_int16_t value_i16 = -23456; | ||
| 25 | static gate_uint16_t value_ui16 = 34567; | ||
| 26 | static gate_int32_t value_i32 = -1234567890; | ||
| 27 | static gate_uint32_t value_ui32 = 3456789012; | ||
| 28 | static gate_int64_t value_i64 = -9012345678901234567; | ||
| 29 | static gate_uint64_t value_ui64 = 12345678901234567890ULL; | ||
| 30 | static gate_real32_t value_r32 = -123.456f; | ||
| 31 | static gate_real64_t value_r64 = -12345.6789f; | ||
| 32 | static gate_uintptr_t value_addr = 0; | ||
| 33 | static gate_dataptr_t value_ptr = &value_bool; | ||
| 34 | static gate_funcptr_t value_func = &dummy_func; | ||
| 35 | static gate_cstr_t value_cstr = "1234"; | ||
| 36 | static gate_wstr_t value_wstr = L"1234"; | ||
| 37 | static gate_guid_t value_guid = GATE_INIT_EMPTY; | ||
| 38 | static gate_date_t value_date = GATE_DATE_INIT_EMPTY; | ||
| 39 | static gate_daytime_t value_daytime = GATE_DAYTIME_INIT_EMPTY; | ||
| 40 | static gate_datetime_t value_datetime = GATE_DATETIME_INIT_EMPTY; | ||
| 41 | static gate_time_t value_time = GATE_TIME_INIT; | ||
| 42 | static gate_string_t value_string = GATE_STRING_INIT_STATIC("1234"); | ||
| 43 | /* static gate_array_t value_array = GATE_ARRAY_INIT_EMPTY; */ | ||
| 44 | static gate_blob_t value_blob = GATE_BLOB_INIT_EMPTY; | ||
| 45 | |||
| 46 | 1 | static void init_test_matrix_values() | |
| 47 | { | ||
| 48 | 1 | value_addr = (gate_uintptr_t)(void*)&value_bool; | |
| 49 | 1 | } | |
| 50 | |||
| 51 | |||
| 52 | static struct value_test_matrix const test_matrix[] = { | ||
| 53 | { GATE_TYPE_BOOL, &value_bool, sizeof(gate_bool_t) }, | ||
| 54 | { GATE_TYPE_I8, &value_i8, sizeof(gate_int8_t) }, | ||
| 55 | { GATE_TYPE_UI8, &value_ui8, sizeof(gate_uint8_t) }, | ||
| 56 | { GATE_TYPE_I16, &value_i16, sizeof(gate_int16_t) }, | ||
| 57 | { GATE_TYPE_UI16, &value_ui16, sizeof(gate_uint16_t) }, | ||
| 58 | { GATE_TYPE_I32, &value_i32, sizeof(gate_int32_t) }, | ||
| 59 | { GATE_TYPE_UI32, &value_ui32, sizeof(gate_uint32_t) }, | ||
| 60 | { GATE_TYPE_I64, &value_i64, sizeof(gate_int64_t) }, | ||
| 61 | { GATE_TYPE_UI64, &value_ui64, sizeof(gate_uint64_t) }, | ||
| 62 | { GATE_TYPE_R32, &value_r32, sizeof(gate_real32_t) }, | ||
| 63 | { GATE_TYPE_R64, &value_r64, sizeof(gate_real64_t) }, | ||
| 64 | { GATE_TYPE_ADDRESS, &value_addr, sizeof(gate_uintptr_t) }, | ||
| 65 | { GATE_TYPE_DATAPTR, &value_ptr, sizeof(gate_dataptr_t) }, | ||
| 66 | { GATE_TYPE_FUNCPTR, &value_func, sizeof(gate_funcptr_t) }, | ||
| 67 | { GATE_TYPE_CSTR, &value_cstr, sizeof(gate_cstr_t) }, | ||
| 68 | { GATE_TYPE_WSTR, &value_wstr, sizeof(gate_wstr_t) }, | ||
| 69 | { GATE_TYPE_GUID, &value_guid, sizeof(gate_guid_t) }, | ||
| 70 | { GATE_TYPE_DATE, &value_date, sizeof(gate_date_t) }, | ||
| 71 | { GATE_TYPE_DAYTIME, &value_daytime, sizeof(gate_daytime_t) }, | ||
| 72 | { GATE_TYPE_DATETIME, &value_datetime,sizeof(gate_datetime_t) }, | ||
| 73 | { GATE_TYPE_TIME, &value_time, sizeof(gate_time_t) }, | ||
| 74 | { GATE_TYPE_STRING, &value_string, sizeof(gate_string_t) }, | ||
| 75 | /* { GATE_TYPE_ARRAY, &value_array, sizeof(gate_array_t) }, */ | ||
| 76 | { GATE_TYPE_BLOB, &value_blob, sizeof(gate_blob_t) } | ||
| 77 | }; | ||
| 78 | static gate_size_t const test_matrix_size = sizeof(test_matrix) / sizeof(test_matrix[0]); | ||
| 79 | |||
| 80 | |||
| 81 | 23 | static gate_bool_t check_loaders(gate_value_t const* val) | |
| 82 | { | ||
| 83 | 23 | gate_bool_t b_value = false; | |
| 84 | 23 | gate_int8_t i8_value = 0; | |
| 85 | 23 | gate_int16_t i16_value = 0; | |
| 86 | 23 | gate_int32_t i32_value = 0; | |
| 87 | 23 | gate_int64_t i64_value = 0; | |
| 88 | 23 | gate_uint8_t ui8_value = 0; | |
| 89 | 23 | gate_uint16_t ui16_value = 0; | |
| 90 | 23 | gate_uint32_t ui32_value = 0; | |
| 91 | 23 | gate_uint64_t ui64_value = 0; | |
| 92 | 23 | gate_string_t str_value = GATE_STRING_INIT_EMPTY; | |
| 93 | 23 | gate_blob_t blob_value = GATE_BLOB_INIT_EMPTY; | |
| 94 | 23 | gate_type_id_t tid = gate_value_type(val); | |
| 95 | 23 | void const* ptr = gate_value_get_ptr(val); | |
| 96 | |||
| 97 |
1/2✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
|
23 | GATE_TEST_CHECK_OK(gate_value_load_bool(tid, ptr, &b_value)); |
| 98 |
1/2✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
|
23 | GATE_TEST_CHECK_OK(gate_value_load_int8(tid, ptr, &i8_value)); |
| 99 |
1/2✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
|
23 | GATE_TEST_CHECK_OK(gate_value_load_int16(tid, ptr, &i16_value)); |
| 100 |
1/2✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
|
23 | GATE_TEST_CHECK_OK(gate_value_load_int32(tid, ptr, &i32_value)); |
| 101 |
1/2✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
|
23 | GATE_TEST_CHECK_OK(gate_value_load_int64(tid, ptr, &i64_value)); |
| 102 |
1/2✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
|
23 | GATE_TEST_CHECK_OK(gate_value_load_uint8(tid, ptr, &ui8_value)); |
| 103 |
1/2✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
|
23 | GATE_TEST_CHECK_OK(gate_value_load_uint16(tid, ptr, &ui16_value)); |
| 104 |
1/2✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
|
23 | GATE_TEST_CHECK_OK(gate_value_load_uint32(tid, ptr, &ui32_value)); |
| 105 |
1/2✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
|
23 | GATE_TEST_CHECK_OK(gate_value_load_uint64(tid, ptr, &ui64_value)); |
| 106 | |||
| 107 |
1/2✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
|
23 | GATE_TEST_CHECK_OK(gate_value_load_string(tid, ptr, &str_value)); |
| 108 | 23 | gate_string_release(&str_value); | |
| 109 | |||
| 110 |
1/2✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
|
23 | GATE_TEST_CHECK_OK(gate_value_load_blob(tid, ptr, &blob_value)); |
| 111 | 23 | gate_blob_release(&blob_value); | |
| 112 | |||
| 113 | 23 | return true; | |
| 114 | } | ||
| 115 | |||
| 116 | 322 | static void reset_value(gate_value_t* ptr_val, gate_type_id_t tid) | |
| 117 | { | ||
| 118 | 322 | gate_value_release(ptr_val); | |
| 119 | 322 | ptr_val->value_type = tid; | |
| 120 | 322 | } | |
| 121 | |||
| 122 | 23 | static gate_bool_t check_savers(gate_type_id_t tid) | |
| 123 | { | ||
| 124 | 23 | gate_value_t val = GATE_INIT_EMPTY; | |
| 125 | 23 | gate_string_t str_val = GATE_STRING_INIT_EMPTY; | |
| 126 | 23 | gate_blob_t blob_val = GATE_BLOB_INIT_EMPTY; | |
| 127 | 23 | void* ptr = &val.content.ptr_value; | |
| 128 | |||
| 129 | 23 | reset_value(&val, tid); | |
| 130 |
1/2✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
|
23 | GATE_TEST_CHECK_OK(gate_value_save_bool(true, tid, ptr)); |
| 131 | 23 | reset_value(&val, tid); | |
| 132 |
1/2✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
|
23 | GATE_TEST_CHECK_OK(gate_value_save_int8(-123, tid, ptr)); |
| 133 | 23 | reset_value(&val, tid); | |
| 134 |
1/2✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
|
23 | GATE_TEST_CHECK_OK(gate_value_save_int16(-123, tid, ptr)); |
| 135 | 23 | reset_value(&val, tid); | |
| 136 |
1/2✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
|
23 | GATE_TEST_CHECK_OK(gate_value_save_int32(-123, tid, ptr)); |
| 137 | 23 | reset_value(&val, tid); | |
| 138 |
1/2✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
|
23 | GATE_TEST_CHECK_OK(gate_value_save_int64(-123, tid, ptr)); |
| 139 | 23 | reset_value(&val, tid); | |
| 140 |
1/2✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
|
23 | GATE_TEST_CHECK_OK(gate_value_save_uint8(123, tid, ptr)); |
| 141 | 23 | reset_value(&val, tid); | |
| 142 |
1/2✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
|
23 | GATE_TEST_CHECK_OK(gate_value_save_uint16(123, tid, ptr)); |
| 143 | 23 | reset_value(&val, tid); | |
| 144 |
1/2✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
|
23 | GATE_TEST_CHECK_OK(gate_value_save_uint32(123, tid, ptr)); |
| 145 | 23 | reset_value(&val, tid); | |
| 146 |
1/2✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
|
23 | GATE_TEST_CHECK_OK(gate_value_save_uint64(123, tid, ptr)); |
| 147 | 23 | reset_value(&val, tid); | |
| 148 |
1/2✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
|
23 | GATE_TEST_CHECK_OK(gate_value_save_real32(123.456f, tid, ptr)); |
| 149 | 23 | reset_value(&val, tid); | |
| 150 |
1/2✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
|
23 | GATE_TEST_CHECK_OK(gate_value_save_real64(123.456, tid, ptr)); |
| 151 | |||
| 152 | 23 | reset_value(&val, tid); | |
| 153 |
1/2✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
|
23 | GATE_TEST_CHECK_OK(gate_value_save_string(&str_val, tid, ptr)); |
| 154 | 23 | gate_string_release(&str_val); | |
| 155 | |||
| 156 | 23 | reset_value(&val, tid); | |
| 157 |
1/2✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
|
23 | GATE_TEST_CHECK_OK(gate_value_save_blob(&blob_val, tid, ptr)); |
| 158 | 23 | gate_blob_release(&blob_val); | |
| 159 | |||
| 160 | 23 | reset_value(&val, tid); | |
| 161 | 23 | return true; | |
| 162 | } | ||
| 163 | |||
| 164 | 1 | static gate_bool_t test_aligned_lengths() | |
| 165 | { | ||
| 166 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_aligned_length(GATE_TYPE_BOOL) != 0); |
| 167 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_aligned_length(GATE_TYPE_I8) != 0); |
| 168 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_aligned_length(GATE_TYPE_UI8) != 0); |
| 169 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_aligned_length(GATE_TYPE_I16) != 0); |
| 170 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_aligned_length(GATE_TYPE_UI16) != 0); |
| 171 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_aligned_length(GATE_TYPE_I32) != 0); |
| 172 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_aligned_length(GATE_TYPE_UI32) != 0); |
| 173 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_aligned_length(GATE_TYPE_I64) != 0); |
| 174 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_aligned_length(GATE_TYPE_UI64) != 0); |
| 175 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_aligned_length(GATE_TYPE_R32) != 0); |
| 176 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_aligned_length(GATE_TYPE_R64) != 0); |
| 177 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_aligned_length(GATE_TYPE_ADDRESS) != 0); |
| 178 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_aligned_length(GATE_TYPE_DATAPTR) != 0); |
| 179 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_aligned_length(GATE_TYPE_FUNCPTR) != 0); |
| 180 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_aligned_length(GATE_TYPE_CSTR) != 0); |
| 181 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_aligned_length(GATE_TYPE_WSTR) != 0); |
| 182 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_aligned_length(GATE_TYPE_GUID) != 0); |
| 183 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_aligned_length(GATE_TYPE_DATE) != 0); |
| 184 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_aligned_length(GATE_TYPE_DAYTIME) != 0); |
| 185 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_aligned_length(GATE_TYPE_DATETIME) != 0); |
| 186 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_aligned_length(GATE_TYPE_TIME) != 0); |
| 187 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_aligned_length(GATE_TYPE_STRING) != 0); |
| 188 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_aligned_length(GATE_TYPE_ARRAY) != 0); |
| 189 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_aligned_length(GATE_TYPE_BLOB) != 0); |
| 190 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_aligned_length(GATE_TYPE_ARRAYLIST) != 0); |
| 191 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_aligned_length(GATE_TYPE_STRUCT) != 0); |
| 192 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_aligned_length(GATE_TYPE_OBJECT) != 0); |
| 193 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_aligned_length(GATE_TYPE_PROPERTY) != 0); |
| 194 | 1 | return true; | |
| 195 | } | ||
| 196 | |||
| 197 | 1 | static gate_bool_t test_generic_type_init() | |
| 198 | { | ||
| 199 | { | ||
| 200 | 1 | gate_int64_t value = 123; | |
| 201 | 1 | gate_int64_t value2 = 123; | |
| 202 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK_OK(gate_type_init(GATE_TYPE_I64, &value)); |
| 203 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | GATE_TEST_CHECK_EQUAL(value, 0); |
| 204 | |||
| 205 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK_OK(gate_type_copy(GATE_TYPE_I64, &value2, &value)); |
| 206 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | GATE_TEST_CHECK_EQUAL(value2, 0); |
| 207 | |||
| 208 | 1 | value2 = 123; | |
| 209 | 1 | gate_type_copy(GATE_TYPE_I64, &value2, NULL); | |
| 210 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | GATE_TEST_CHECK_EQUAL(value2, 0); |
| 211 | |||
| 212 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK_OK(gate_type_release(GATE_TYPE_I64, &value2)); |
| 213 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK_OK(gate_type_release(GATE_TYPE_I64, &value)); |
| 214 | } | ||
| 215 | |||
| 216 | { | ||
| 217 | static const gate_string_t src = GATE_STRING_INIT_STATIC("hello"); | ||
| 218 | 1 | gate_string_t value = GATE_STRING_INIT_EMPTY; | |
| 219 | |||
| 220 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK_OK(gate_type_copy(GATE_TYPE_STRING, &value, &src)); |
| 221 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_string_equals(&value, &src)); |
| 222 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK_OK(gate_type_release(GATE_TYPE_STRING, &value)); |
| 223 | } | ||
| 224 | { | ||
| 225 | static const gate_blob_t src = { "test", 4 }; | ||
| 226 | 1 | gate_blob_t value = GATE_INIT_EMPTY; | |
| 227 | |||
| 228 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK_OK(gate_type_copy(GATE_TYPE_BLOB, &value, &src)); |
| 229 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK_EQUAL(gate_blob_compare(&value, &src), 0); |
| 230 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK_OK(gate_type_release(GATE_TYPE_BLOB, &value)); |
| 231 | } | ||
| 232 | { | ||
| 233 | 1 | gate_array_t src = GATE_INIT_EMPTY; | |
| 234 | 1 | gate_array_t value = GATE_INIT_EMPTY; | |
| 235 | 1 | gate_array_create_static(&src, "abc", 1, 3); | |
| 236 | |||
| 237 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK_OK(gate_type_copy(GATE_TYPE_ARRAY, &value, &src)); |
| 238 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK_OK(gate_type_release(GATE_TYPE_ARRAY, &value)); |
| 239 | } | ||
| 240 | { | ||
| 241 | 1 | gate_memstream_t* src = gate_memstream_create(16); | |
| 242 | 1 | gate_object_t* value = NULL; | |
| 243 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | GATE_TEST_REQUIRE(src != NULL); |
| 244 | |||
| 245 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK_OK(gate_type_copy(GATE_TYPE_OBJECT, &value, &src)); |
| 246 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK_OK(gate_type_release(GATE_TYPE_OBJECT, &value)); |
| 247 | 1 | gate_object_release(src); | |
| 248 | } | ||
| 249 | 1 | return true; | |
| 250 | } | ||
| 251 | |||
| 252 | 1 | static gate_bool_t test_type_signatures() | |
| 253 | { | ||
| 254 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_signature(GATE_TYPE_VOID) != NULL); |
| 255 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_signature(GATE_TYPE_ARRAYLIST) != NULL); |
| 256 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_signature(GATE_TYPE_ARRAYLIST_BOOL) != NULL); |
| 257 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_signature(GATE_TYPE_ARRAYLIST_I8) != NULL); |
| 258 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_signature(GATE_TYPE_ARRAYLIST_I16) != NULL); |
| 259 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_signature(GATE_TYPE_ARRAYLIST_I32) != NULL); |
| 260 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_signature(GATE_TYPE_ARRAYLIST_I64) != NULL); |
| 261 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_signature(GATE_TYPE_ARRAYLIST_UI8) != NULL); |
| 262 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_signature(GATE_TYPE_ARRAYLIST_UI16) != NULL); |
| 263 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_signature(GATE_TYPE_ARRAYLIST_UI32) != NULL); |
| 264 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_signature(GATE_TYPE_ARRAYLIST_UI64) != NULL); |
| 265 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_signature(GATE_TYPE_ARRAYLIST_R32) != NULL); |
| 266 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_signature(GATE_TYPE_ARRAYLIST_R64) != NULL); |
| 267 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_signature(GATE_TYPE_ARRAYLIST_ADDRESS) != NULL); |
| 268 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_signature(GATE_TYPE_ARRAYLIST_DATAPTR) != NULL); |
| 269 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_signature(GATE_TYPE_ARRAYLIST_FUNCPTR) != NULL); |
| 270 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_signature(GATE_TYPE_ARRAYLIST_CSTR) != NULL); |
| 271 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_signature(GATE_TYPE_ARRAYLIST_WSTR) != NULL); |
| 272 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_signature(GATE_TYPE_ARRAYLIST_GUID) != NULL); |
| 273 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_signature(GATE_TYPE_ARRAYLIST_DATE) != NULL); |
| 274 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_signature(GATE_TYPE_ARRAYLIST_DAYTIME) != NULL); |
| 275 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_signature(GATE_TYPE_ARRAYLIST_DATETIME) != NULL); |
| 276 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_signature(GATE_TYPE_ARRAYLIST_TIME) != NULL); |
| 277 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_signature(GATE_TYPE_ARRAYLIST_STRING) != NULL); |
| 278 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_signature(GATE_TYPE_ARRAYLIST_ARRAY) != NULL); |
| 279 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_signature(GATE_TYPE_ARRAYLIST_BLOB) != NULL); |
| 280 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_signature(GATE_TYPE_ARRAYLIST_STRUCT) != NULL); |
| 281 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_signature(GATE_TYPE_ARRAYLIST_OBJECT) != NULL); |
| 282 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_signature(GATE_TYPE_ARRAYLIST_PROPERTY) != NULL); |
| 283 | |||
| 284 | { | ||
| 285 | 1 | gate_type_sig_t const sig = gate_type_signature(GATE_TYPE_I8); | |
| 286 | 1 | gate_type_sig_t const sig2 = gate_type_signature(GATE_TYPE_I16); | |
| 287 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_signature_equals(sig, sig) == true); |
| 288 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_signature_equals(sig, NULL) == false); |
| 289 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(gate_type_signature_equals(sig, sig2) == false); |
| 290 | } | ||
| 291 | 1 | return true; | |
| 292 | } | ||
| 293 | |||
| 294 | |||
| 295 | 1 | GATE_TEST_FUNCTION(test_values) | |
| 296 | { | ||
| 297 | gate_size_t ndx; | ||
| 298 | |||
| 299 | 1 | GATE_TEST_UNIT_BEGIN(test_values); | |
| 300 | |||
| 301 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(test_aligned_lengths()); |
| 302 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(test_generic_type_init()); |
| 303 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(test_type_signatures()); |
| 304 | |||
| 305 | 1 | init_test_matrix_values(); | |
| 306 | |||
| 307 |
2/2✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
|
24 | for (ndx = 0; ndx != test_matrix_size; ++ndx) |
| 308 | { | ||
| 309 | 23 | struct value_test_matrix const* const m = &test_matrix[ndx]; | |
| 310 | 23 | gate_value_t val = GATE_INIT_EMPTY; | |
| 311 | 23 | gate_value_t val_copy = GATE_INIT_EMPTY; | |
| 312 | gate_value_t buffer; | ||
| 313 | char serial_buf[512]; | ||
| 314 | gate_size_t serial_buf_used; | ||
| 315 | gate_size_t serial_buf_parsed; | ||
| 316 | 23 | char const* type_signame = gate_type_signature(m->type_id); | |
| 317 | |||
| 318 | 23 | GATE_TEST_TRACE_VALUE(m->type_id); | |
| 319 |
1/2✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
|
23 | GATE_TEST_REQUIRE(type_signame != NULL); |
| 320 | 23 | GATE_TEST_TRACE_MESSAGE(type_signame); | |
| 321 | |||
| 322 |
1/2✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
|
23 | GATE_TEST_CHECK(gate_value_create(m->type_id, m->ptr_value, &val) != NULL); |
| 323 |
1/2✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
|
23 | GATE_TEST_CHECK_EQUAL(gate_value_type(&val), m->type_id); |
| 324 |
1/2✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
|
23 | GATE_TEST_CHECK_NOT_EQUAL(gate_value_get_ptr(&val), NULL); |
| 325 |
1/2✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
|
23 | GATE_TEST_CHECK_OK(gate_value_get(&val, &buffer.content, m->value_size)); |
| 326 |
1/2✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
|
23 | GATE_TEST_CHECK_NOT_EQUAL(gate_value_clone(&val, &val_copy), NULL); |
| 327 | 23 | gate_value_release(&val_copy); | |
| 328 | |||
| 329 | 23 | serial_buf_used = gate_value_serialize(&val, serial_buf, sizeof(serial_buf)); | |
| 330 |
1/2✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
|
23 | GATE_TEST_CHECK(serial_buf_used > 0); |
| 331 | 23 | gate_mem_clear(&val_copy, sizeof(val_copy)); | |
| 332 | 23 | serial_buf_parsed = gate_value_deserialize(serial_buf, sizeof(serial_buf), &val_copy); | |
| 333 |
1/2✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
|
23 | GATE_TEST_CHECK_EQUAL(serial_buf_parsed, serial_buf_used); |
| 334 | 23 | gate_value_release(&val_copy); | |
| 335 | |||
| 336 | 23 | check_loaders(&val); | |
| 337 | 23 | check_savers(m->type_id); | |
| 338 | |||
| 339 | 23 | gate_value_release(&val); | |
| 340 | } | ||
| 341 | |||
| 342 | 1 | GATE_TEST_UNIT_END; | |
| 343 | } | ||
| 344 |