2 * Copyright (C) 2007-2010 Gary Kramlich <grim@reaperworld.com>
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include <gplate/gplate.h>
21 #include "gplate-tag-test.h"
23 /******************************************************************************
25 *****************************************************************************/
27 gplate_variable_tag_test(GPlateTagTestFixture *fixture, gconstpointer data,
28 const gchar *template_string, const gchar *expected,
32 const gchar *name = NULL, *value = NULL;
34 va_start(vargs, expected);
35 while((name = va_arg(vargs, const gchar *))) {
36 value = va_arg(vargs, const gchar *);
38 gplate_collection_add_string(GPLATE_COLLECTION(fixture->template),
43 gplate_tag_test_output(fixture, data, template_string, expected);
46 /******************************************************************************
48 *****************************************************************************/
50 gplate_variable_tag_test_single(GPlateTagTestFixture *fixture,
53 gplate_variable_tag_test(fixture, data,
60 gplate_variable_tag_test_double(GPlateTagTestFixture *fixture,
63 gplate_variable_tag_test(fixture, data,
64 "{{ foo }}{{ bar }}", "foobar",
71 gplate_variable_tag_test_tripple(GPlateTagTestFixture *fixture,
74 gplate_variable_tag_test(fixture, data,
75 "{{ foo }}{{ bar }}{{ baz }}", "foobarbaz",
83 gplate_variable_tag_test_newline_prefix(GPlateTagTestFixture *fixture,
86 gplate_variable_tag_test(fixture, data,
93 gplate_variable_tag_test_newline_suffix(GPlateTagTestFixture *fixture,
96 gplate_variable_tag_test(fixture, data,
103 gplate_variable_tag_test_newline_wrapped(GPlateTagTestFixture *fixture,
106 gplate_variable_tag_test(fixture, data,
107 "{{\nfoo\n}}", "foo",
113 gplate_variable_tag_test_single_quotes(GPlateTagTestFixture *fixture,
116 gplate_variable_tag_test(fixture, data,
117 "foo '{{ bar }}' baz", "foo 'bar' baz",
123 gplate_variable_tag_test_double_quotes(GPlateTagTestFixture *fixture,
126 gplate_variable_tag_test(fixture, data,
127 "foo \"{{ bar }}\" baz", "foo \"bar\" baz",
133 gplate_variable_tag_test_mixed_quotes(GPlateTagTestFixture *fixture,
136 gplate_variable_tag_test(fixture, data,
137 "foo \"{{ bar }}' baz", "foo \"bar' baz",
141 gplate_variable_tag_test(fixture, data,
142 "foo '{{ bar }}\" baz", "foo 'bar\" baz",
146 /******************************************************************************
148 *****************************************************************************/
150 main(gint argc, gchar **argv) {
151 g_test_init(&argc, &argv, NULL);
155 gplate_config_load_default();
157 gplate_tag_test_add("/tags/variable/single",
158 gplate_variable_tag_test_single);
160 gplate_tag_test_add("/tags/variable/double",
161 gplate_variable_tag_test_double);
163 gplate_tag_test_add("/tags/variable/tripple",
164 gplate_variable_tag_test_tripple);
166 gplate_tag_test_add("/tags/variable/newline_prefix",
167 gplate_variable_tag_test_newline_prefix);
169 gplate_tag_test_add("/tags/variable/newline_suffix",
170 gplate_variable_tag_test_newline_suffix);
172 gplate_tag_test_add("/tags/variable/newline_wrapped",
173 gplate_variable_tag_test_newline_wrapped);
175 gplate_tag_test_add("/tags/variable/quotes/single",
176 gplate_variable_tag_test_single_quotes);
178 gplate_tag_test_add("/tags/variable/quotes/double",
179 gplate_variable_tag_test_double_quotes);
181 gplate_tag_test_add("/tags/variable/quotes/mixed",
182 gplate_variable_tag_test_mixed_quotes);