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