tests/test_properties.c

changeset 1683
e5399c60ae96
parent 1669
d416628d6c7d
equal deleted inserted replaced
1682:9dd7995c51bb 1683:e5399c60ae96
515 } 515 }
516 516
517 cxPropertiesDestroy(&prop); 517 cxPropertiesDestroy(&prop);
518 } 518 }
519 519
520 CX_TEST(test_properties_next_alternative_delimiter) {
521 CxProperties prop;
522 CxPropertiesConfig alt_config = {0};
523 alt_config.delimiter = ':';
524 cxPropertiesInit(&prop, alt_config);
525
526 cxstring key;
527 cxstring value;
528 CxPropertiesStatus result;
529
530 CX_TEST_DO {
531 CX_TEST_ASSERT(0 == cxPropertiesFill(&prop, "no_delimiter = value\n"));
532 result = cxPropertiesNext(&prop, &key, &value);
533 CX_TEST_ASSERT(result == CX_PROPERTIES_INVALID_MISSING_DELIMITER);
534 cxPropertiesReset(&prop);
535 CX_TEST_ASSERT(0 == cxPropertiesFill(&prop, "correct : value\n"));
536 result = cxPropertiesNext(&prop, &key, &value);
537 CX_TEST_ASSERT(result == CX_PROPERTIES_NO_ERROR);
538 CX_TEST_ASSERT(!cx_strcmp(key, "correct"));
539 CX_TEST_ASSERT(!cx_strcmp(value, "value"));
540 }
541 cxPropertiesDestroy(&prop);
542 }
543
520 static FILE *cx_opentmp(char *tpl) { 544 static FILE *cx_opentmp(char *tpl) {
521 #ifdef WITH_MKSTEMP 545 #ifdef WITH_MKSTEMP
522 strcpy(tpl, "ucxtestXXXXXX"); 546 strcpy(tpl, "ucxtestXXXXXX");
523 int fd = mkstemp(tpl); 547 int fd = mkstemp(tpl);
524 if (fd < 0) return NULL; 548 if (fd < 0) return NULL;
863 cx_test_register(suite, test_properties_next_part); 887 cx_test_register(suite, test_properties_next_part);
864 cx_test_register(suite, test_properties_next_long_lines); 888 cx_test_register(suite, test_properties_next_long_lines);
865 cx_test_register(suite, test_properties_next_starts_with_newlines); 889 cx_test_register(suite, test_properties_next_starts_with_newlines);
866 cx_test_register(suite, test_properties_next_line_continuation); 890 cx_test_register(suite, test_properties_next_line_continuation);
867 cx_test_register(suite, test_properties_next_line_continuation_part); 891 cx_test_register(suite, test_properties_next_line_continuation_part);
892 cx_test_register(suite, test_properties_next_alternative_delimiter);
868 cx_test_register(suite, test_properties_load); 893 cx_test_register(suite, test_properties_load);
869 cx_test_register(suite, test_properties_load_empty_file); 894 cx_test_register(suite, test_properties_load_empty_file);
870 cx_test_register(suite, test_properties_load_only_comments); 895 cx_test_register(suite, test_properties_load_only_comments);
871 cx_test_register(suite, test_properties_load_error); 896 cx_test_register(suite, test_properties_load_error);
872 cx_test_register(suite, test_properties_load_file_not_exists); 897 cx_test_register(suite, test_properties_load_file_not_exists);

mercurial