Code

data: Escape \ and " in strings when formatting them.
[sysdb.git] / t / core / data_test.c
index a16d7fef891a287cec3444d0e5d74872097376f8..649a7df4bece545e9689953ec31ea39e52f55018 100644 (file)
@@ -155,6 +155,17 @@ START_TEST(test_format)
                        "sdb_data_format() used wrong format: %s; expected: %s",
                        string, expected);
 
+       datum.data.string = "now using special \\ \" characters";
+       sdb_strbuf_clear(buf);
+       check = sdb_data_format(&datum, buf);
+       fail_unless(! check,
+                       "sdb_data_format(STRING) = %d; expected: 0", check);
+       string = sdb_strbuf_string(buf);
+       expected = "\"now using special \\\\ \\\" characters\"";
+       fail_unless(! strcmp(string, expected),
+                       "sdb_data_format() used wrong format: %s; expected: %s",
+                       string, expected);
+
        datum.data.string = NULL;
        sdb_strbuf_clear(buf);
        check = sdb_data_format(&datum, buf);