| 382 |
382 |
| 383 free(long_key); |
383 free(long_key); |
| 384 free(long_value); |
384 free(long_value); |
| 385 } |
385 } |
| 386 |
386 |
| |
387 CX_TEST(test_properties_next_starts_with_newlines) { |
| |
388 const char *str1 = "key1 = value1"; |
| |
389 const char *str2 = "\nkey2 = value2\n"; |
| |
390 |
| |
391 CxProperties prop; |
| |
392 cxPropertiesInitDefault(&prop); |
| |
393 |
| |
394 cxstring key; |
| |
395 cxstring value; |
| |
396 |
| |
397 CX_TEST_DO { |
| |
398 CX_TEST_ASSERT(0 == cxPropertiesFill(&prop, str1)); |
| |
399 CX_TEST_ASSERT(cxPropertiesNext(&prop, &key, &value) == CX_PROPERTIES_INCOMPLETE_DATA); |
| |
400 CX_TEST_ASSERT(0 == cxPropertiesFill(&prop, str2)); |
| |
401 CX_TEST_ASSERT(cxPropertiesNext(&prop, &key, &value) == CX_PROPERTIES_NO_ERROR); |
| |
402 CX_TEST_ASSERT(!cx_strcmp(key, "key1")); |
| |
403 CX_TEST_ASSERT(!cx_strcmp(value, "value1")); |
| |
404 CX_TEST_ASSERT(cxPropertiesNext(&prop, &key, &value) == CX_PROPERTIES_NO_ERROR); |
| |
405 CX_TEST_ASSERT(!cx_strcmp(key, "key2")); |
| |
406 CX_TEST_ASSERT(!cx_strcmp(value, "value2")); |
| |
407 CX_TEST_ASSERT(cxPropertiesNext(&prop, &key, &value) == CX_PROPERTIES_NO_DATA); |
| |
408 } |
| |
409 |
| |
410 cxPropertiesDestroy(&prop); |
| |
411 } |
| |
412 |
| 387 CX_TEST(test_properties_next_line_continuation) { |
413 CX_TEST(test_properties_next_line_continuation) { |
| 388 const char *str = |
414 const char *str = |
| 389 "key1 = multiline \\\nvalue\n" |
415 "key1 = multiline \\\nvalue\n" |
| 390 "key2 = normal\n" |
416 "key2 = normal\n" |
| 391 "key3 = multiline \\\n trim \n" |
417 "key3 = multiline \\\n trim \n" |
| 834 cx_test_register(suite, test_properties_init); |
860 cx_test_register(suite, test_properties_init); |
| 835 cx_test_register(suite, test_properties_next); |
861 cx_test_register(suite, test_properties_next); |
| 836 cx_test_register(suite, test_properties_next_multi); |
862 cx_test_register(suite, test_properties_next_multi); |
| 837 cx_test_register(suite, test_properties_next_part); |
863 cx_test_register(suite, test_properties_next_part); |
| 838 cx_test_register(suite, test_properties_next_long_lines); |
864 cx_test_register(suite, test_properties_next_long_lines); |
| |
865 cx_test_register(suite, test_properties_next_starts_with_newlines); |
| 839 cx_test_register(suite, test_properties_next_line_continuation); |
866 cx_test_register(suite, test_properties_next_line_continuation); |
| 840 cx_test_register(suite, test_properties_next_line_continuation_part); |
867 cx_test_register(suite, test_properties_next_line_continuation_part); |
| 841 cx_test_register(suite, test_properties_load); |
868 cx_test_register(suite, test_properties_load); |
| 842 cx_test_register(suite, test_properties_load_empty_file); |
869 cx_test_register(suite, test_properties_load_empty_file); |
| 843 cx_test_register(suite, test_properties_load_only_comments); |
870 cx_test_register(suite, test_properties_load_only_comments); |