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 /******************************************************************************
23 *****************************************************************************/
25 GPlateTemplate *template;
27 const gchar *template_string;
30 const gchar *expected;
33 } TestGPlateIncludeFunctionFixture;
35 /******************************************************************************
37 *****************************************************************************/
39 test_gplate_include_function_setup(TestGPlateIncludeFunctionFixture *fixture,
42 fixture->template = gplate_template_new();
46 test_gplate_include_function_teardown(TestGPlateIncludeFunctionFixture *fixture,
49 g_object_unref(fixture->template);
50 fixture->template = NULL;
52 g_free(fixture->actual);
53 fixture->actual = NULL;
55 fixture->expected = NULL;
58 g_error_free(fixture->error);
59 fixture->error = NULL;
63 /******************************************************************************
65 *****************************************************************************/
67 test_gplate_include_function_simple(TestGPlateIncludeFunctionFixture *fixture,
70 fixture->expected = "including\nincluded!\ndone";
72 fixture->actual = gplate_template_render_file(fixture->template,
73 "templates/simple.gplate",
76 g_assert(fixture->error == NULL);
78 g_assert_cmpstr(fixture->expected, ==, fixture->actual);
82 test_gplate_include_function_double(TestGPlateIncludeFunctionFixture *fixture,
85 fixture->expected = " \
95 fixture->actual = gplate_template_render_file(fixture->template,
96 "templates/html.gplate",
99 g_assert(fixture->error == NULL);
101 g_assert_cmpstr(fixture->expected, ==, fixture->actual);
104 /******************************************************************************
106 *****************************************************************************/
108 main(gint argc, gchar **argv) {
109 g_test_init(&argc, &argv, NULL);
113 gplate_config_load_default();
115 g_test_add("/functions/include/simple",
116 TestGPlateIncludeFunctionFixture,
118 test_gplate_include_function_setup,
119 test_gplate_include_function_simple,
120 test_gplate_include_function_teardown);
122 g_test_add("/functions/include/double",
123 TestGPlateIncludeFunctionFixture,
125 test_gplate_include_function_setup,
126 test_gplate_include_function_double,
127 test_gplate_include_function_teardown);