add test_properties_next_starts_with_newlines()

Thu, 25 Dec 2025 11:47:50 +0100

author
Mike Becker <universe@uap-core.de>
date
Thu, 25 Dec 2025 11:47:50 +0100
changeset 1669
d416628d6c7d
parent 1668
3ffdfe1776b4
child 1670
56f55f2f70c0

add test_properties_next_starts_with_newlines()

just a precaution

tests/test_properties.c file | annotate | diff | comparison | revisions
--- a/tests/test_properties.c	Thu Dec 25 11:39:26 2025 +0100
+++ b/tests/test_properties.c	Thu Dec 25 11:47:50 2025 +0100
@@ -384,6 +384,32 @@
     free(long_value);
 }
 
+CX_TEST(test_properties_next_starts_with_newlines) {
+    const char *str1 = "key1 = value1";
+    const char *str2 = "\nkey2 = value2\n";
+
+    CxProperties prop;
+    cxPropertiesInitDefault(&prop);
+
+    cxstring key;
+    cxstring value;
+
+    CX_TEST_DO {
+        CX_TEST_ASSERT(0 == cxPropertiesFill(&prop, str1));
+        CX_TEST_ASSERT(cxPropertiesNext(&prop, &key,  &value) == CX_PROPERTIES_INCOMPLETE_DATA);
+        CX_TEST_ASSERT(0 == cxPropertiesFill(&prop, str2));
+        CX_TEST_ASSERT(cxPropertiesNext(&prop, &key,  &value) == CX_PROPERTIES_NO_ERROR);
+        CX_TEST_ASSERT(!cx_strcmp(key, "key1"));
+        CX_TEST_ASSERT(!cx_strcmp(value, "value1"));
+        CX_TEST_ASSERT(cxPropertiesNext(&prop, &key,  &value) == CX_PROPERTIES_NO_ERROR);
+        CX_TEST_ASSERT(!cx_strcmp(key, "key2"));
+        CX_TEST_ASSERT(!cx_strcmp(value, "value2"));
+        CX_TEST_ASSERT(cxPropertiesNext(&prop, &key,  &value) == CX_PROPERTIES_NO_DATA);
+    }
+
+    cxPropertiesDestroy(&prop);
+}
+
 CX_TEST(test_properties_next_line_continuation) {
     const char *str = 
         "key1 = multiline \\\nvalue\n"
@@ -836,6 +862,7 @@
     cx_test_register(suite, test_properties_next_multi);
     cx_test_register(suite, test_properties_next_part);
     cx_test_register(suite, test_properties_next_long_lines);
+    cx_test_register(suite, test_properties_next_starts_with_newlines);
     cx_test_register(suite, test_properties_next_line_continuation);
     cx_test_register(suite, test_properties_next_line_continuation_part);
     cx_test_register(suite, test_properties_load);

mercurial