2 * Copyright (C) 2007-2010 Gary Kramlich <grim@reaperworld.com>
3 * * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #include <gplate/gplate.h>
19 gplate_util_test_quoted_string_helper(const gchar *string,
20 const gchar *contents, gboolean value)
25 r = gplate_util_is_quoted_string(string, &c);
26 g_assert_cmpint(r, ==, value);
29 g_assert_cmpstr(c, ==, contents);
35 gplate_util_test_quoted_string(void) {
36 gplate_util_test_quoted_string_helper("\"abc\"", "abc", TRUE);
37 gplate_util_test_quoted_string_helper("\"abc def\"", "abc def", TRUE);
38 gplate_util_test_quoted_string_helper("\"abc\tdef\bghi\"", "abc\tdef\bghi", TRUE);
39 gplate_util_test_quoted_string_helper("abc \"def\"", NULL, FALSE);
40 gplate_util_test_quoted_string_helper("\"abc\" def", NULL, FALSE);
41 gplate_util_test_quoted_string_helper("'abc'", "abc", TRUE);
42 gplate_util_test_quoted_string_helper("'abc def'", "abc def", TRUE);
43 gplate_util_test_quoted_string_helper("'abc\tdef\bghi'", "abc\tdef\bghi", TRUE);
44 gplate_util_test_quoted_string_helper("abc 'def'", NULL, FALSE);
45 gplate_util_test_quoted_string_helper("'abc' def", NULL, FALSE);
46 gplate_util_test_quoted_string_helper("'abc\"", NULL, FALSE);
47 gplate_util_test_quoted_string_helper("\"abc'", NULL, FALSE);
51 main(gint argc, gchar **argv) {
52 g_test_init(&argc, &argv, NULL);
54 g_test_add_func("/util/quoted_string", gplate_util_test_quoted_string);