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 fixture->template_string = template_string;
35 fixture->expected = expected;
37 va_start(vargs, expected);
38 while((name = va_arg(vargs, const gchar *))) {
39 value = va_arg(vargs, const gchar *);
41 gplate_collection_add_string(GPLATE_COLLECTION(fixture->template),
47 gplate_tag_test_output(fixture, data);
50 /******************************************************************************
52 *****************************************************************************/
54 gplate_variable_tag_test_single(GPlateTagTestFixture *fixture,
57 gplate_variable_tag_test(fixture, data,
64 gplate_variable_tag_test_double(GPlateTagTestFixture *fixture,
67 gplate_variable_tag_test(fixture, data,
68 "{{ foo }}{{ bar }}", "foobar",
75 gplate_variable_tag_test_tripple(GPlateTagTestFixture *fixture,
78 gplate_variable_tag_test(fixture, data,
79 "{{ foo }}{{ bar }}{{ baz }}", "foobarbaz",
87 gplate_variable_tag_test_newline_prefix(GPlateTagTestFixture *fixture,
90 gplate_variable_tag_test(fixture, data,
97 gplate_variable_tag_test_newline_suffix(GPlateTagTestFixture *fixture,
100 gplate_variable_tag_test(fixture, data,
107 gplate_variable_tag_test_newline_wrapped(GPlateTagTestFixture *fixture,
110 gplate_variable_tag_test(fixture, data,
111 "{{\nfoo\n}}", "foo",
117 gplate_variable_tag_test_single_quotes(GPlateTagTestFixture *fixture,
120 gplate_variable_tag_test(fixture, data,
121 "foo '{{ bar }}' baz", "foo 'bar' baz",
127 gplate_variable_tag_test_double_quotes(GPlateTagTestFixture *fixture,
130 gplate_variable_tag_test(fixture, data,
131 "foo \"{{ bar }}\" baz", "foo \"bar\" baz",
137 gplate_variable_tag_test_mixed_quotes(GPlateTagTestFixture *fixture,
140 gplate_variable_tag_test(fixture, data,
141 "foo \"{{ bar }}' baz", "foo \"bar' baz",
145 gplate_variable_tag_test(fixture, data,
146 "foo '{{ bar }}\" baz", "foo 'bar\" baz",
150 /******************************************************************************
152 *****************************************************************************/
154 main(gint argc, gchar **argv) {
155 g_test_init(&argc, &argv, NULL);
159 gplate_config_load_default();
161 gplate_tag_test_add("/tags/variable/single",
162 gplate_variable_tag_test_single);
164 gplate_tag_test_add("/tags/variable/double",
165 gplate_variable_tag_test_double);
167 gplate_tag_test_add("/tags/variable/tripple",
168 gplate_variable_tag_test_tripple);
170 gplate_tag_test_add("/tags/variable/newline_prefix",
171 gplate_variable_tag_test_newline_prefix);
173 gplate_tag_test_add("/tags/variable/newline_suffix",
174 gplate_variable_tag_test_newline_suffix);
176 gplate_tag_test_add("/tags/variable/newline_wrapped",
177 gplate_variable_tag_test_newline_wrapped);
179 gplate_tag_test_add("/tags/variable/quotes/single",
180 gplate_variable_tag_test_single_quotes);
182 gplate_tag_test_add("/tags/variable/quotes/double",
183 gplate_variable_tag_test_double_quotes);
185 gplate_tag_test_add("/tags/variable/quotes/mixed",
186 gplate_variable_tag_test_mixed_quotes);