1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/gplate/tests/test-util-functions.c Sat Jun 26 15:25:18 2010 -0500
1.3 @@ -0,0 +1,43 @@
1.4 +#include <gplate/gplate.h>
1.5 +
1.6 +static void
1.7 +gplate_util_test_quoted_string_helper(const gchar *string,
1.8 + const gchar *contents, gboolean value)
1.9 +{
1.10 + gboolean r = FALSE;
1.11 + gchar *c = NULL;
1.12 +
1.13 + r = gplate_util_is_quoted_string(string, &c);
1.14 + g_assert_cmpint(r, ==, value);
1.15 +
1.16 + if(contents)
1.17 + g_assert_cmpstr(c, ==, contents);
1.18 +
1.19 + g_free(c);
1.20 +}
1.21 +
1.22 +static void
1.23 +gplate_util_test_quoted_string(void) {
1.24 + gplate_util_test_quoted_string_helper("\"abc\"", "abc", TRUE);
1.25 + gplate_util_test_quoted_string_helper("\"abc def\"", "abc def", TRUE);
1.26 + gplate_util_test_quoted_string_helper("\"abc\tdef\bghi\"", "abc\tdef\bghi", TRUE);
1.27 + gplate_util_test_quoted_string_helper("abc \"def\"", NULL, FALSE);
1.28 + gplate_util_test_quoted_string_helper("\"abc\" def", NULL, FALSE);
1.29 + gplate_util_test_quoted_string_helper("'abc'", "abc", TRUE);
1.30 + gplate_util_test_quoted_string_helper("'abc def'", "abc def", TRUE);
1.31 + gplate_util_test_quoted_string_helper("'abc\tdef\bghi'", "abc\tdef\bghi", TRUE);
1.32 + gplate_util_test_quoted_string_helper("abc 'def'", NULL, FALSE);
1.33 + gplate_util_test_quoted_string_helper("'abc' def", NULL, FALSE);
1.34 + gplate_util_test_quoted_string_helper("'abc\"", NULL, FALSE);
1.35 + gplate_util_test_quoted_string_helper("\"abc'", NULL, FALSE);
1.36 +}
1.37 +
1.38 +gint
1.39 +main(gint argc, gchar **argv) {
1.40 + g_test_init(&argc, &argv, NULL);
1.41 +
1.42 + g_test_add_func("/util/quoted_string", gplate_util_test_quoted_string);
1.43 +
1.44 + return g_test_run();
1.45 +}
1.46 +