1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/gplate/tests/test-gplate-utility-functions.c Sun Jul 04 03:34:39 2010 -0500
1.3 @@ -0,0 +1,58 @@
1.4 +/*
1.5 + * Copyright (C) 2007-2010 Gary Kramlich <grim@reaperworld.com>
1.6 + * * This program is free software: you can redistribute it and/or modify
1.7 + * it under the terms of the GNU General Public License as published by
1.8 + * the Free Software Foundation, either version 3 of the License, or
1.9 + * (at your option) any later version.
1.10 + *
1.11 + * This program is distributed in the hope that it will be useful,
1.12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.14 + * GNU General Public License for more details.
1.15 + *
1.16 + * You should have received a copy of the GNU General Public License
1.17 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
1.18 + */
1.19 +#include <gplate/gplate.h>
1.20 +
1.21 +static void
1.22 +gplate_util_test_quoted_string_helper(const gchar *string,
1.23 + const gchar *contents, gboolean value)
1.24 +{
1.25 + gboolean r = FALSE;
1.26 + gchar *c = NULL;
1.27 +
1.28 + r = gplate_util_is_quoted_string(string, &c);
1.29 + g_assert_cmpint(r, ==, value);
1.30 +
1.31 + if(contents)
1.32 + g_assert_cmpstr(c, ==, contents);
1.33 +
1.34 + g_free(c);
1.35 +}
1.36 +
1.37 +static void
1.38 +gplate_util_test_quoted_string(void) {
1.39 + gplate_util_test_quoted_string_helper("\"abc\"", "abc", TRUE);
1.40 + gplate_util_test_quoted_string_helper("\"abc def\"", "abc def", TRUE);
1.41 + gplate_util_test_quoted_string_helper("\"abc\tdef\bghi\"", "abc\tdef\bghi", TRUE);
1.42 + gplate_util_test_quoted_string_helper("abc \"def\"", NULL, FALSE);
1.43 + gplate_util_test_quoted_string_helper("\"abc\" def", NULL, FALSE);
1.44 + gplate_util_test_quoted_string_helper("'abc'", "abc", TRUE);
1.45 + gplate_util_test_quoted_string_helper("'abc def'", "abc def", TRUE);
1.46 + gplate_util_test_quoted_string_helper("'abc\tdef\bghi'", "abc\tdef\bghi", TRUE);
1.47 + gplate_util_test_quoted_string_helper("abc 'def'", NULL, FALSE);
1.48 + gplate_util_test_quoted_string_helper("'abc' def", NULL, FALSE);
1.49 + gplate_util_test_quoted_string_helper("'abc\"", NULL, FALSE);
1.50 + gplate_util_test_quoted_string_helper("\"abc'", NULL, FALSE);
1.51 +}
1.52 +
1.53 +gint
1.54 +main(gint argc, gchar **argv) {
1.55 + g_test_init(&argc, &argv, NULL);
1.56 +
1.57 + g_test_add_func("/util/quoted_string", gplate_util_test_quoted_string);
1.58 +
1.59 + return g_test_run();
1.60 +}
1.61 +