1.1 --- a/gplate/tags/tests/gplate-variable-tag-test.c Sun Jul 04 02:58:33 2010 -0500
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,186 +0,0 @@
1.4 -/*
1.5 - * Copyright (C) 2007-2010 Gary Kramlich <grim@reaperworld.com>
1.6 - *
1.7 - * This program is free software: you can redistribute it and/or modify
1.8 - * it under the terms of the GNU General Public License as published by
1.9 - * the Free Software Foundation, either version 3 of the License, or
1.10 - * (at your option) any later version.
1.11 - *
1.12 - * This program is distributed in the hope that it will be useful,
1.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.15 - * GNU General Public License for more details.
1.16 - *
1.17 - * You should have received a copy of the GNU General Public License
1.18 - * along with this program. If not, see <http://www.gnu.org/licenses/>.
1.19 - */
1.20 -#include <gplate/gplate.h>
1.21 -
1.22 -#include <glib.h>
1.23 -
1.24 -#include "gplate-tag-test.h"
1.25 -
1.26 -/******************************************************************************
1.27 - * Helpers
1.28 - *****************************************************************************/
1.29 -static void
1.30 -gplate_variable_tag_test(GPlateTagTestFixture *fixture, gconstpointer data,
1.31 - const gchar *template_string, const gchar *expected,
1.32 - ...)
1.33 -{
1.34 - va_list vargs;
1.35 - const gchar *name = NULL, *value = NULL;
1.36 -
1.37 - va_start(vargs, expected);
1.38 - while((name = va_arg(vargs, const gchar *))) {
1.39 - value = va_arg(vargs, const gchar *);
1.40 -
1.41 - gplate_collection_add_string(GPLATE_COLLECTION(fixture->template),
1.42 - name, value);
1.43 - }
1.44 - va_end(vargs);
1.45 -
1.46 - gplate_tag_test_output(fixture, data, template_string, expected);
1.47 -}
1.48 -
1.49 -/******************************************************************************
1.50 - * Tests
1.51 - *****************************************************************************/
1.52 -static void
1.53 -gplate_variable_tag_test_single(GPlateTagTestFixture *fixture,
1.54 - gconstpointer data)
1.55 -{
1.56 - gplate_variable_tag_test(fixture, data,
1.57 - "{{ foo }}", "foo",
1.58 - "foo", "foo",
1.59 - NULL);
1.60 -}
1.61 -
1.62 -static void
1.63 -gplate_variable_tag_test_double(GPlateTagTestFixture *fixture,
1.64 - gconstpointer data)
1.65 -{
1.66 - gplate_variable_tag_test(fixture, data,
1.67 - "{{ foo }}{{ bar }}", "foobar",
1.68 - "foo", "foo",
1.69 - "bar", "bar",
1.70 - NULL);
1.71 -}
1.72 -
1.73 -static void
1.74 -gplate_variable_tag_test_tripple(GPlateTagTestFixture *fixture,
1.75 - gconstpointer data)
1.76 -{
1.77 - gplate_variable_tag_test(fixture, data,
1.78 - "{{ foo }}{{ bar }}{{ baz }}", "foobarbaz",
1.79 - "foo", "foo",
1.80 - "bar", "bar",
1.81 - "baz", "baz",
1.82 - NULL);
1.83 -}
1.84 -
1.85 -static void
1.86 -gplate_variable_tag_test_newline_prefix(GPlateTagTestFixture *fixture,
1.87 - gconstpointer data)
1.88 -{
1.89 - gplate_variable_tag_test(fixture, data,
1.90 - "{{\nfoo}}", "foo",
1.91 - "foo", "foo",
1.92 - NULL);
1.93 -}
1.94 -
1.95 -static void
1.96 -gplate_variable_tag_test_newline_suffix(GPlateTagTestFixture *fixture,
1.97 - gconstpointer data)
1.98 -{
1.99 - gplate_variable_tag_test(fixture, data,
1.100 - "{{foo\n}}", "foo",
1.101 - "foo", "foo",
1.102 - NULL);
1.103 -}
1.104 -
1.105 -static void
1.106 -gplate_variable_tag_test_newline_wrapped(GPlateTagTestFixture *fixture,
1.107 - gconstpointer data)
1.108 -{
1.109 - gplate_variable_tag_test(fixture, data,
1.110 - "{{\nfoo\n}}", "foo",
1.111 - "foo", "foo",
1.112 - NULL);
1.113 -}
1.114 -
1.115 -static void
1.116 -gplate_variable_tag_test_single_quotes(GPlateTagTestFixture *fixture,
1.117 - gconstpointer data)
1.118 -{
1.119 - gplate_variable_tag_test(fixture, data,
1.120 - "foo '{{ bar }}' baz", "foo 'bar' baz",
1.121 - "bar", "bar",
1.122 - NULL);
1.123 -}
1.124 -
1.125 -static void
1.126 -gplate_variable_tag_test_double_quotes(GPlateTagTestFixture *fixture,
1.127 - gconstpointer data)
1.128 -{
1.129 - gplate_variable_tag_test(fixture, data,
1.130 - "foo \"{{ bar }}\" baz", "foo \"bar\" baz",
1.131 - "bar", "bar",
1.132 - NULL);
1.133 -}
1.134 -
1.135 -static void
1.136 -gplate_variable_tag_test_mixed_quotes(GPlateTagTestFixture *fixture,
1.137 - gconstpointer data)
1.138 -{
1.139 - gplate_variable_tag_test(fixture, data,
1.140 - "foo \"{{ bar }}' baz", "foo \"bar' baz",
1.141 - "bar", "bar",
1.142 - NULL);
1.143 -
1.144 - gplate_variable_tag_test(fixture, data,
1.145 - "foo '{{ bar }}\" baz", "foo 'bar\" baz",
1.146 - "bar", "bar",
1.147 - NULL);
1.148 -}
1.149 -/******************************************************************************
1.150 - * Main
1.151 - *****************************************************************************/
1.152 -gint
1.153 -main(gint argc, gchar **argv) {
1.154 - g_test_init(&argc, &argv, NULL);
1.155 -
1.156 - g_type_init();
1.157 -
1.158 - gplate_config_load_default();
1.159 -
1.160 - gplate_tag_test_add("/tags/variable/single",
1.161 - gplate_variable_tag_test_single);
1.162 -
1.163 - gplate_tag_test_add("/tags/variable/double",
1.164 - gplate_variable_tag_test_double);
1.165 -
1.166 - gplate_tag_test_add("/tags/variable/tripple",
1.167 - gplate_variable_tag_test_tripple);
1.168 -
1.169 - gplate_tag_test_add("/tags/variable/newline_prefix",
1.170 - gplate_variable_tag_test_newline_prefix);
1.171 -
1.172 - gplate_tag_test_add("/tags/variable/newline_suffix",
1.173 - gplate_variable_tag_test_newline_suffix);
1.174 -
1.175 - gplate_tag_test_add("/tags/variable/newline_wrapped",
1.176 - gplate_variable_tag_test_newline_wrapped);
1.177 -
1.178 - gplate_tag_test_add("/tags/variable/quotes/single",
1.179 - gplate_variable_tag_test_single_quotes);
1.180 -
1.181 - gplate_tag_test_add("/tags/variable/quotes/double",
1.182 - gplate_variable_tag_test_double_quotes);
1.183 -
1.184 - gplate_tag_test_add("/tags/variable/quotes/mixed",
1.185 - gplate_variable_tag_test_mixed_quotes);
1.186 -
1.187 - return g_test_run();
1.188 -}
1.189 -