|
grim@238
|
1 |
#include <gplate/gplate.h> |
|
grim@238
|
2 |
|
|
grim@238
|
3 |
static void |
|
grim@364
|
4 |
gplate_util_test_quoted_string_helper(const gchar *string, |
|
grim@364
|
5 |
const gchar *contents, gboolean value) |
|
grim@238
|
6 |
{ |
|
grim@238
|
7 |
gboolean r = FALSE; |
|
grim@238
|
8 |
gchar *c = NULL; |
|
grim@238
|
9 |
|
|
grim@238
|
10 |
r = gplate_util_is_quoted_string(string, &c); |
|
grim@364
|
11 |
g_assert_cmpint(r, ==, value); |
|
grim@238
|
12 |
|
|
grim@238
|
13 |
if(contents) |
|
grim@364
|
14 |
g_assert_cmpstr(c, ==, contents); |
|
grim@238
|
15 |
|
|
grim@238
|
16 |
g_free(c); |
|
grim@238
|
17 |
} |
|
grim@238
|
18 |
|
|
grim@364
|
19 |
static void |
|
grim@364
|
20 |
gplate_util_test_quoted_string(void) { |
|
grim@364
|
21 |
gplate_util_test_quoted_string_helper("\"abc\"", "abc", TRUE); |
|
grim@364
|
22 |
gplate_util_test_quoted_string_helper("\"abc def\"", "abc def", TRUE); |
|
grim@364
|
23 |
gplate_util_test_quoted_string_helper("\"abc\tdef\bghi\"", "abc\tdef\bghi", TRUE); |
|
grim@364
|
24 |
gplate_util_test_quoted_string_helper("abc \"def\"", NULL, FALSE); |
|
grim@364
|
25 |
gplate_util_test_quoted_string_helper("\"abc\" def", NULL, FALSE); |
|
grim@364
|
26 |
gplate_util_test_quoted_string_helper("'abc'", "abc", TRUE); |
|
grim@364
|
27 |
gplate_util_test_quoted_string_helper("'abc def'", "abc def", TRUE); |
|
grim@364
|
28 |
gplate_util_test_quoted_string_helper("'abc\tdef\bghi'", "abc\tdef\bghi", TRUE); |
|
grim@364
|
29 |
gplate_util_test_quoted_string_helper("abc 'def'", NULL, FALSE); |
|
grim@364
|
30 |
gplate_util_test_quoted_string_helper("'abc' def", NULL, FALSE); |
|
grim@364
|
31 |
gplate_util_test_quoted_string_helper("'abc\"", NULL, FALSE); |
|
grim@364
|
32 |
gplate_util_test_quoted_string_helper("\"abc'", NULL, FALSE); |
|
grim@238
|
33 |
} |
|
grim@238
|
34 |
|
|
grim@364
|
35 |
gint |
|
grim@364
|
36 |
main(gint argc, gchar **argv) { |
|
grim@364
|
37 |
g_test_init(&argc, &argv, NULL); |
|
grim@364
|
38 |
|
|
grim@364
|
39 |
g_test_add_func("/util/quoted_string", gplate_util_test_quoted_string); |
|
grim@364
|
40 |
|
|
grim@364
|
41 |
return g_test_run(); |
|
grim@364
|
42 |
} |
|
grim@364
|
43 |
|