test/prop_tests.c

changeset 134
4d320dc3a7af
parent 110
1cf71e56f01e
child 147
1aa598f36872
equal deleted inserted replaced
133:0a70e0d36949 134:4d320dc3a7af
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #include "prop_tests.h" 29 #include "prop_tests.h"
30 30
31 UCX_TEST_IMPLEMENT(test_ucx_properties_new) { 31 UCX_TEST(test_ucx_properties_new) {
32 UcxProperties *parser = ucx_properties_new(); 32 UcxProperties *parser = ucx_properties_new();
33 33
34 UCX_TEST_BEGIN 34 UCX_TEST_BEGIN
35 35
36 UCX_TEST_ASSERT(parser != NULL, "failed"); 36 UCX_TEST_ASSERT(parser != NULL, "failed");
40 UCX_TEST_END 40 UCX_TEST_END
41 41
42 ucx_properties_free(parser); 42 ucx_properties_free(parser);
43 } 43 }
44 44
45 UCX_TEST_IMPLEMENT(test_ucx_properties_next) { 45 UCX_TEST(test_ucx_properties_next) {
46 const char *tests[] = { 46 const char *tests[] = {
47 "name = value\n", 47 "name = value\n",
48 "name=value\n", 48 "name=value\n",
49 "n=value\n", 49 "n=value\n",
50 "name=v\n", 50 "name=v\n",
111 } 111 }
112 112
113 UCX_TEST_END 113 UCX_TEST_END
114 } 114 }
115 115
116 UCX_TEST_IMPLEMENT(test_ucx_properties_next_multi) { 116 UCX_TEST(test_ucx_properties_next_multi) {
117 const char *names[] = { 117 const char *names[] = {
118 "a", 118 "a",
119 "b", 119 "b",
120 "c", 120 "c",
121 "uap", 121 "uap",
174 UCX_TEST_END 174 UCX_TEST_END
175 175
176 ucx_properties_free(parser); 176 ucx_properties_free(parser);
177 } 177 }
178 178
179 UCX_TEST_IMPLEMENT(test_ucx_properties_next_part) { 179 UCX_TEST(test_ucx_properties_next_part) {
180 UcxProperties *parser = ucx_properties_new(); 180 UcxProperties *parser = ucx_properties_new();
181 const char *str; 181 const char *str;
182 int r; 182 int r;
183 sstr_t name; 183 sstr_t name;
184 sstr_t value; 184 sstr_t value;
284 UCX_TEST_END 284 UCX_TEST_END
285 285
286 ucx_properties_free(parser); 286 ucx_properties_free(parser);
287 } 287 }
288 288
289 UCX_TEST_IMPLEMENT(test_ucx_properties_next_long) { 289 UCX_TEST(test_ucx_properties_next_long) {
290 UcxProperties *parser = ucx_properties_new(); 290 UcxProperties *parser = ucx_properties_new();
291 int r; 291 int r;
292 size_t name_len = 512; 292 size_t name_len = 512;
293 char *long_name = (char*)malloc(name_len); 293 char *long_name = (char*)malloc(name_len);
294 memset(long_name, 'a', 70); 294 memset(long_name, 'a', 70);
360 free(long_name); 360 free(long_name);
361 free(long_value); 361 free(long_value);
362 ucx_properties_free(parser); 362 ucx_properties_free(parser);
363 } 363 }
364 364
365 UCX_TEST_IMPLEMENT(test_ucx_properties2map) { 365 UCX_TEST(test_ucx_properties2map) {
366 UcxMap *map = ucx_map_new(16); 366 UcxMap *map = ucx_map_new(16);
367 UcxProperties *parser = ucx_properties_new(); 367 UcxProperties *parser = ucx_properties_new();
368 368
369 UCX_TEST_BEGIN 369 UCX_TEST_BEGIN
370 370
415 UCX_TEST_END 415 UCX_TEST_END
416 416
417 ucx_properties_free(parser); 417 ucx_properties_free(parser);
418 } 418 }
419 419
420 UCX_TEST_IMPLEMENT(test_ucx_properties_load) { 420 UCX_TEST(test_ucx_properties_load) {
421 UCX_TEST_BEGIN 421 UCX_TEST_BEGIN
422 FILE *f = tmpfile(); 422 FILE *f = tmpfile();
423 UCX_TEST_ASSERT(f, "test file cannot be opened, test aborted"); 423 UCX_TEST_ASSERT(f, "test file cannot be opened, test aborted");
424 424
425 fprintf(f, "# properties file\n\nkey1 = value1\nkey2 = value2\n"); 425 fprintf(f, "# properties file\n\nkey1 = value1\nkey2 = value2\n");
478 fclose(f); 478 fclose(f);
479 479
480 UCX_TEST_END 480 UCX_TEST_END
481 } 481 }
482 482
483 UCX_TEST_IMPLEMENT(test_ucx_properties_store) { 483 UCX_TEST(test_ucx_properties_store) {
484 UcxMap *map1 = ucx_map_new(16); 484 UcxMap *map1 = ucx_map_new(16);
485 ucx_map_cstr_put(map1, "key1", "value1"); 485 ucx_map_cstr_put(map1, "key1", "value1");
486 ucx_map_cstr_put(map1, "key2", "value2"); 486 ucx_map_cstr_put(map1, "key2", "value2");
487 ucx_map_cstr_put(map1, "key3", "value3"); 487 ucx_map_cstr_put(map1, "key3", "value3");
488 ucx_map_cstr_put(map1, "key4", "value4"); 488 ucx_map_cstr_put(map1, "key4", "value4");

mercurial