summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0cba919)
raw | patch | inline | side by side (parent: 0cba919)
author | Florian Forster <octo@collectd.org> | |
Sun, 28 Jun 2015 12:08:02 +0000 (14:08 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Sun, 28 Jun 2015 12:08:02 +0000 (14:08 +0200) |
src/daemon/common_test.c | patch | blob | history |
index ff33c9eb4794014e7c1bb662ea3260a8365127fb..f40b2b1a50defda7e9e859a4bd74e8c7f08afa6b 100644 (file)
--- a/src/daemon/common_test.c
+++ b/src/daemon/common_test.c
return 0;
}
+DEF_TEST(escape_string)
+{
+ struct {
+ char *str;
+ char *want;
+ } cases[] = {
+ {"foobar", "foobar"},
+ {"f00bar", "f00bar"},
+ {"foo bar", "\"foo bar\""},
+ {"foo \"bar\"", "\"foo \\\"bar\\\"\""},
+ {"012345678901234", "012345678901234"},
+ {"012345 78901234", "\"012345 789012\""},
+ {"012345 78901\"34", "\"012345 78901\""},
+ };
+ size_t i;
+
+ for (i = 0; i < STATIC_ARRAY_SIZE (cases); i++) {
+ char buffer[16];
+
+ strncpy (buffer, cases[i].str, sizeof (buffer));
+ OK(escape_string (buffer, sizeof (buffer)) == 0);
+ STREQ(cases[i].want, buffer);
+ }
+
+ return 0;
+}
+
DEF_TEST(strunescape)
{
char buffer[16];
RUN_TEST(strsplit);
RUN_TEST(strjoin);
RUN_TEST(escape_slashes);
+ RUN_TEST(escape_string);
RUN_TEST(strunescape);
RUN_TEST(parse_values);