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 "test-gplate-tag.h"
23 /******************************************************************************
25 *****************************************************************************/
27 test_gplate_variable_tag(TestGPlateTagFixture *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 test_gplate_tag_output(fixture, data, template_string, expected);
46 /******************************************************************************
48 *****************************************************************************/
50 test_gplate_variable_tag_single(TestGPlateTagFixture *fixture,
53 test_gplate_variable_tag(fixture, data,
60 test_gplate_variable_tag_double(TestGPlateTagFixture *fixture,
63 test_gplate_variable_tag(fixture, data,
64 "{{ foo }}{{ bar }}", "foobar",
71 test_gplate_variable_tag_tripple(TestGPlateTagFixture *fixture,
74 test_gplate_variable_tag(fixture, data,
75 "{{ foo }}{{ bar }}{{ baz }}", "foobarbaz",
83 test_gplate_variable_tag_newline_prefix(TestGPlateTagFixture *fixture,
86 test_gplate_variable_tag(fixture, data,
93 test_gplate_variable_tag_newline_suffix(TestGPlateTagFixture *fixture,
96 test_gplate_variable_tag(fixture, data,
103 test_gplate_variable_tag_newline_wrapped(TestGPlateTagFixture *fixture,
106 test_gplate_variable_tag(fixture, data,
107 "{{\nfoo\n}}", "foo",
113 test_gplate_variable_tag_single_quotes(TestGPlateTagFixture *fixture,
116 test_gplate_variable_tag(fixture, data,
117 "foo '{{ bar }}' baz", "foo 'bar' baz",
123 test_gplate_variable_tag_double_quotes(TestGPlateTagFixture *fixture,
126 test_gplate_variable_tag(fixture, data,
127 "foo \"{{ bar }}\" baz", "foo \"bar\" baz",
133 test_gplate_variable_tag_mixed_quotes(TestGPlateTagFixture *fixture,
136 test_gplate_variable_tag(fixture, data,
137 "foo \"{{ bar }}' baz", "foo \"bar' baz",
141 test_gplate_variable_tag(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 test_gplate_tag_add("/tags/variable/single",
158 test_gplate_variable_tag_single);
160 test_gplate_tag_add("/tags/variable/double",
161 test_gplate_variable_tag_double);
163 test_gplate_tag_add("/tags/variable/tripple",
164 test_gplate_variable_tag_tripple);
166 test_gplate_tag_add("/tags/variable/newline_prefix",
167 test_gplate_variable_tag_newline_prefix);
169 test_gplate_tag_add("/tags/variable/newline_suffix",
170 test_gplate_variable_tag_newline_suffix);
172 test_gplate_tag_add("/tags/variable/newline_wrapped",
173 test_gplate_variable_tag_newline_wrapped);
175 test_gplate_tag_add("/tags/variable/quotes/single",
176 test_gplate_variable_tag_single_quotes);
178 test_gplate_tag_add("/tags/variable/quotes/double",
179 test_gplate_variable_tag_double_quotes);
181 test_gplate_tag_add("/tags/variable/quotes/mixed",
182 test_gplate_variable_tag_mixed_quotes);