X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=t%2Fcore%2Fdata_test.c;h=649a7df4bece545e9689953ec31ea39e52f55018;hb=fd3b58d670103cf729f17f682174ebb60d248a63;hp=fb3b1145bac8001458b95b598a348c92dc15ca20;hpb=4f8a84025ecb0d230407d54743186c2b4d1941c9;p=sysdb.git diff --git a/t/core/data_test.c b/t/core/data_test.c index fb3b114..649a7df 100644 --- a/t/core/data_test.c +++ b/t/core/data_test.c @@ -155,6 +155,28 @@ 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); + fail_unless(! check, + "sdb_data_format(STRING) = %d; expected: 0", check); + string = sdb_strbuf_string(buf); + expected = "\"NULL\""; + fail_unless(! strcmp(string, expected), + "sdb_data_format() used wrong format: %s; expected: %s", + string, expected); + datum.type = SDB_TYPE_DATETIME; datum.data.datetime = 471147114711471100; sdb_strbuf_clear(buf); @@ -162,7 +184,7 @@ START_TEST(test_format) fail_unless(! check, "sdb_data_format(DATETIME) = %d; expected: 0", check); string = sdb_strbuf_string(buf); - expected = "1984-12-06 02:11:54 +0000"; + expected = "\"1984-12-06 02:11:54 +0000\""; fail_unless(! strcmp(string, expected), "sdb_data_format() used wrong format: %s; expected: %s", string, expected); @@ -175,7 +197,20 @@ START_TEST(test_format) fail_unless(! check, "sdb_data_format(BINARY) = %d; expected: 0", check); string = sdb_strbuf_string(buf); - expected = "\"\\62\\69\\6e\\61\\72\\79\\0\\63\\72\\61\\70\\42\""; + expected = + "\"\\x62\\x69\\x6e\\x61\\x72\\x79\\x0\\x63\\x72\\x61\\x70\\x42\""; + fail_unless(! strcmp(string, expected), + "sdb_data_format() used wrong format: %s; expected: %s", + string, expected); + + datum.data.binary.datum = NULL; + datum.data.binary.length = 0; + sdb_strbuf_clear(buf); + check = sdb_data_format(&datum, buf); + fail_unless(! check, + "sdb_data_format(BINARY) = %d; expected: 0", check); + string = sdb_strbuf_string(buf); + expected = "\"\""; fail_unless(! strcmp(string, expected), "sdb_data_format() used wrong format: %s; expected: %s", string, expected);