tests/test_properties.c

changeset 964
3860f509fcbe
parent 929
192a440b99df
equal deleted inserted replaced
963:2f601274bbac 964:3860f509fcbe
30 #include "util_allocator.h" 30 #include "util_allocator.h"
31 31
32 #include "cx/properties.h" 32 #include "cx/properties.h"
33 #include "cx/hash_map.h" 33 #include "cx/hash_map.h"
34 34
35 CX_TEST(test_cx_properties_init) { 35 CX_TEST(test_properties_init) {
36 CxProperties prop; 36 CxProperties prop;
37 CX_TEST_DO { 37 CX_TEST_DO {
38 cxPropertiesInitDefault(&prop); 38 cxPropertiesInitDefault(&prop);
39 39
40 CX_TEST_ASSERT(prop.config.delimiter == '='); 40 CX_TEST_ASSERT(prop.config.delimiter == '=');
47 47
48 cxPropertiesDestroy(&prop); 48 cxPropertiesDestroy(&prop);
49 } 49 }
50 } 50 }
51 51
52 CX_TEST(test_cx_properties_next) { 52 CX_TEST(test_properties_next) {
53 const char *tests[] = { 53 const char *tests[] = {
54 "name = value\n", 54 "name = value\n",
55 "name=value\n", 55 "name=value\n",
56 "n=value\n", 56 "n=value\n",
57 "name=v\n", 57 "name=v\n",
113 } 113 }
114 } 114 }
115 cxPropertiesDestroy(&prop); 115 cxPropertiesDestroy(&prop);
116 } 116 }
117 117
118 CX_TEST(test_cx_properties_next_multi) { 118 CX_TEST(test_properties_next_multi) {
119 const char *keys[] = { 119 const char *keys[] = {
120 "a", 120 "a",
121 "b", 121 "b",
122 "c", 122 "c",
123 "uap", 123 "uap",
175 CX_TEST_ASSERT(result == CX_PROPERTIES_NO_DATA); 175 CX_TEST_ASSERT(result == CX_PROPERTIES_NO_DATA);
176 } 176 }
177 cxPropertiesDestroy(&prop); 177 cxPropertiesDestroy(&prop);
178 } 178 }
179 179
180 CX_TEST(test_cx_properties_next_part) { 180 CX_TEST(test_properties_next_part) {
181 CxProperties prop; 181 CxProperties prop;
182 cxPropertiesInitDefault(&prop); 182 cxPropertiesInitDefault(&prop);
183 CxPropertiesStatus result; 183 CxPropertiesStatus result;
184 cxstring key; 184 cxstring key;
185 cxstring value; 185 cxstring value;
284 CX_TEST_ASSERT(result == CX_PROPERTIES_NO_DATA); 284 CX_TEST_ASSERT(result == CX_PROPERTIES_NO_DATA);
285 } 285 }
286 cxPropertiesDestroy(&prop); 286 cxPropertiesDestroy(&prop);
287 } 287 }
288 288
289 CX_TEST(test_ucx_properties_next_long_lines) { 289 CX_TEST(test_properties_next_long_lines) {
290 CxProperties prop; 290 CxProperties prop;
291 cxPropertiesInitDefault(&prop); 291 cxPropertiesInitDefault(&prop);
292 CxPropertiesStatus result; 292 CxPropertiesStatus result;
293 cxstring key; 293 cxstring key;
294 cxstring value; 294 cxstring value;
367 367
368 free(long_key); 368 free(long_key);
369 free(long_value); 369 free(long_value);
370 } 370 }
371 371
372 CX_TEST(test_cx_properties_load_string_to_map) { 372 CX_TEST(test_properties_load_string_to_map) {
373 CxTestingAllocator talloc; 373 CxTestingAllocator talloc;
374 cx_testing_allocator_init(&talloc); 374 cx_testing_allocator_init(&talloc);
375 CxAllocator *alloc = &talloc.base; 375 CxAllocator *alloc = &talloc.base;
376 CX_TEST_DO { 376 CX_TEST_DO {
377 char buffer[512]; 377 char buffer[512];
430 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); 430 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc));
431 } 431 }
432 cx_testing_allocator_destroy(&talloc); 432 cx_testing_allocator_destroy(&talloc);
433 } 433 }
434 434
435 CX_TEST(test_cx_properties_load_file_to_map) { 435 CX_TEST(test_properties_load_file_to_map) {
436 CxTestingAllocator talloc; 436 CxTestingAllocator talloc;
437 cx_testing_allocator_init(&talloc); 437 cx_testing_allocator_init(&talloc);
438 CxAllocator *alloc = &talloc.base; 438 CxAllocator *alloc = &talloc.base;
439 CX_TEST_DO { 439 CX_TEST_DO {
440 FILE *f = tmpfile(); 440 FILE *f = tmpfile();
506 } 506 }
507 507
508 CxTestSuite *cx_test_suite_properties(void) { 508 CxTestSuite *cx_test_suite_properties(void) {
509 CxTestSuite *suite = cx_test_suite_new("properties"); 509 CxTestSuite *suite = cx_test_suite_new("properties");
510 510
511 cx_test_register(suite, test_cx_properties_init); 511 cx_test_register(suite, test_properties_init);
512 cx_test_register(suite, test_cx_properties_next); 512 cx_test_register(suite, test_properties_next);
513 cx_test_register(suite, test_cx_properties_next_multi); 513 cx_test_register(suite, test_properties_next_multi);
514 cx_test_register(suite, test_cx_properties_next_part); 514 cx_test_register(suite, test_properties_next_part);
515 cx_test_register(suite, test_ucx_properties_next_long_lines); 515 cx_test_register(suite, test_properties_next_long_lines);
516 cx_test_register(suite, test_cx_properties_load_string_to_map); 516 cx_test_register(suite, test_properties_load_string_to_map);
517 cx_test_register(suite, test_cx_properties_load_file_to_map); 517 cx_test_register(suite, test_properties_load_file_to_map);
518 518
519 return suite; 519 return suite;
520 } 520 }

mercurial