116 UCX_TEST_END |
116 UCX_TEST_END |
117 |
117 |
118 ucx_array_free(&array); |
118 ucx_array_free(&array); |
119 } |
119 } |
120 |
120 |
|
121 UCX_TEST(test_ucx_array_set) { |
|
122 UcxArray array = ucx_array_new(16, sizeof(int)); |
|
123 |
|
124 int x = 42; |
|
125 |
|
126 UCX_TEST_BEGIN |
|
127 |
|
128 ucx_array_set(&array, 7, &x); |
|
129 UCX_TEST_ASSERT(ucx_array_at_int(array, 7) == 42, "failed"); |
|
130 UCX_TEST_ASSERT(array.size >= 8, "array not resized on set"); |
|
131 UCX_TEST_ASSERT(array.capacity == 16, "capacity changed unnecessarily"); |
|
132 |
|
133 x = 13; |
|
134 ucx_array_set(&array, 27, &x); |
|
135 |
|
136 UCX_TEST_ASSERT(ucx_array_at_int(array, 27) == 13, "failed"); |
|
137 UCX_TEST_ASSERT(array.size == 28, "array not resized on set"); |
|
138 UCX_TEST_ASSERT(array.capacity == 28, "capacity not grown"); |
|
139 |
|
140 ucx_array_set(&array, 7, NULL); |
|
141 |
|
142 UCX_TEST_ASSERT(ucx_array_at_int(array, 7) == 0, "not zeroed on NULL set"); |
|
143 |
|
144 UCX_TEST_END |
|
145 |
|
146 ucx_array_free(&array); |
|
147 } |
|
148 |
121 UCX_TEST(test_ucx_array_equals) { |
149 UCX_TEST(test_ucx_array_equals) { |
122 UcxArray a1 = ucx_array_new(16, sizeof(int)); |
150 UcxArray a1 = ucx_array_new(16, sizeof(int)); |
123 UcxArray a2 = ucx_array_new(16, sizeof(int)); |
151 UcxArray a2 = ucx_array_new(16, sizeof(int)); |
124 UcxArray a3 = ucx_array_new(16, sizeof(long int)); |
152 UcxArray a3 = ucx_array_new(16, sizeof(long int)); |
125 UcxArray a4 = ucx_array_new(16, sizeof(int)); |
153 UcxArray a4 = ucx_array_new(16, sizeof(int)); |