148 "to test if the buffer extension works as designed"); |
148 "to test if the buffer extension works as designed"); |
149 |
149 |
150 FILE *f = fopen("test_ucx_map_store", "w"); |
150 FILE *f = fopen("test_ucx_map_store", "w"); |
151 int r; |
151 int r; |
152 |
152 |
153 fwrite(" # comment test", 1, 15, f); |
153 fwrite(" # comment test\n", 1, 16, f); |
154 r = ucx_map_store(map, f); |
154 r = ucx_map_store(map, f); |
155 fwrite("#discard this", 1, 13, f); |
155 fwrite("!discard this", 1, 13, f); |
156 |
156 |
157 fclose(f); |
157 fclose(f); |
158 ucx_map_free(map); |
158 ucx_map_free(map); |
159 map = ucx_map_new(1); |
159 map = ucx_map_new(1); |
160 f = fopen("test_ucx_map_store", "r"); |
160 f = fopen("test_ucx_map_store", "r"); |
163 UCX_TEST_BEGIN |
163 UCX_TEST_BEGIN |
164 char *value; |
164 char *value; |
165 UCX_TEST_ASSERT(r == 0, "IO errors, test cannot be performed"); |
165 UCX_TEST_ASSERT(r == 0, "IO errors, test cannot be performed"); |
166 |
166 |
167 value = ucx_map_cstr_get(map, "test"); |
167 value = ucx_map_cstr_get(map, "test"); |
|
168 UCX_TEST_ASSERT(value != NULL, "value not found for key: test"); |
168 UCX_TEST_ASSERT(strcmp(value, "test") == 0, "value error for key: test"); |
169 UCX_TEST_ASSERT(strcmp(value, "test") == 0, "value error for key: test"); |
169 |
170 |
170 value = ucx_map_cstr_get(map, "key"); |
171 value = ucx_map_cstr_get(map, "key"); |
|
172 UCX_TEST_ASSERT(value != NULL, "value not found for key: key"); |
171 UCX_TEST_ASSERT(strcmp(value, "value") == 0, "value error for key: key"); |
173 UCX_TEST_ASSERT(strcmp(value, "value") == 0, "value error for key: key"); |
172 |
174 |
173 value = ucx_map_cstr_get(map, "other.very.long.key"); |
175 value = ucx_map_cstr_get(map, "other.very.long.key"); |
|
176 UCX_TEST_ASSERT(value != NULL, |
|
177 "value not found for key: other.very.long.key"); |
174 UCX_TEST_ASSERT(strcmp(value, "value") == 0, |
178 UCX_TEST_ASSERT(strcmp(value, "value") == 0, |
175 "value error for key: other.very.long.key"); |
179 "value error for key: other.very.long.key"); |
176 |
180 |
177 value = ucx_map_cstr_get(map, "testkey"); |
181 value = ucx_map_cstr_get(map, "testkey"); |
|
182 UCX_TEST_ASSERT(value != NULL, "value not found for key: testkey"); |
178 UCX_TEST_ASSERT(strcmp(value, "testvalue") == 0, |
183 UCX_TEST_ASSERT(strcmp(value, "testvalue") == 0, |
179 "value error for key: testkey"); |
184 "value error for key: testkey"); |
180 |
185 |
181 value = ucx_map_cstr_get(map, "simple"); |
186 value = ucx_map_cstr_get(map, "simple"); |
|
187 UCX_TEST_ASSERT(value != NULL, "value not found for key: simple"); |
182 UCX_TEST_ASSERT(strcmp(value, "not a key but an extremely long value " |
188 UCX_TEST_ASSERT(strcmp(value, "not a key but an extremely long value " |
183 "to test if the buffer extension works as designed") == 0, |
189 "to test if the buffer extension works as designed") == 0, |
184 "value error for key: simple"); |
190 "value error for key: simple"); |
185 |
191 |
186 UCX_TEST_END |
192 UCX_TEST_END |