moved the include function tests to the new format
refs #16
--- a/gplate/functions/tests/CMakeLists.txt Sun Jul 04 15:35:33 2010 -0500
+++ b/gplate/functions/tests/CMakeLists.txt Sun Jul 04 16:09:43 2010 -0500
@@ -4,6 +4,10 @@
target_link_libraries(test-gplate-for-function gplate)
list(APPEND FUNCTION_TESTS test-gplate-for-function)
+add_executable(test-gplate-include-function test-gplate-include-function.c) +target_link_libraries(test-gplate-include-function gplate) +list(APPEND FUNCTION_TESTS test-gplate-for-function) ${GTESTER} -k --verbose -o test-gplate-function.log
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/functions/tests/templates/footer.gplate Sun Jul 04 16:09:43 2010 -0500
@@ -0,0 +1,2 @@
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/functions/tests/templates/header.gplate Sun Jul 04 16:09:43 2010 -0500
@@ -0,0 +1,5 @@
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/functions/tests/templates/html.gplate Sun Jul 04 16:09:43 2010 -0500
@@ -0,0 +1,1 @@
+{% include "header.gplate" %}in the body{% include "footer.gplate" %} --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/functions/tests/templates/simple-include.gplate Sun Jul 04 16:09:43 2010 -0500
@@ -0,0 +1,1 @@
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/functions/tests/templates/simple.gplate Sun Jul 04 16:09:43 2010 -0500
@@ -0,0 +1,4 @@
+{% include "simple-include.gplate" %} --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/functions/tests/test-gplate-include-function.c Sun Jul 04 16:09:43 2010 -0500
@@ -0,0 +1,131 @@
+ * Copyright (C) 2007-2010 Gary Kramlich <grim@reaperworld.com> + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +#include <gplate/gplate.h> +/****************************************************************************** + *****************************************************************************/ + GPlateTemplate *template; + const gchar *template_string; +} TestGPlateIncludeFunctionFixture; +/****************************************************************************** + *****************************************************************************/ +test_gplate_include_function_setup(TestGPlateIncludeFunctionFixture *fixture, + fixture->template = gplate_template_new(); +test_gplate_include_function_teardown(TestGPlateIncludeFunctionFixture *fixture, + g_object_unref(fixture->template); + fixture->template = NULL; + g_free(fixture->actual); + fixture->actual = NULL; + fixture->expected = NULL; + g_error_free(fixture->error); +/****************************************************************************** + *****************************************************************************/ +test_gplate_include_function_simple(TestGPlateIncludeFunctionFixture *fixture, + fixture->expected = "including\nincluded!\ndone"; + fixture->actual = gplate_template_render_file(fixture->template, + "templates/simple.gplate", + g_assert(fixture->error == NULL); + g_assert_cmpstr(fixture->expected, ==, fixture->actual); +test_gplate_include_function_double(TestGPlateIncludeFunctionFixture *fixture, + fixture->expected = " \ + fixture->actual = gplate_template_render_file(fixture->template, + "templates/html.gplate", + g_assert(fixture->error == NULL); + g_assert_cmpstr(fixture->expected, ==, fixture->actual); +/****************************************************************************** + *****************************************************************************/ +main(gint argc, gchar **argv) { + g_test_init(&argc, &argv, NULL); + gplate_config_load_default(); + g_test_add("/functions/include/simple", + TestGPlateIncludeFunctionFixture, + test_gplate_include_function_setup, + test_gplate_include_function_simple, + test_gplate_include_function_teardown); + g_test_add("/functions/include/double", + TestGPlateIncludeFunctionFixture, + test_gplate_include_function_setup, + test_gplate_include_function_double, + test_gplate_include_function_teardown); --- a/tests/templates/Makefile.am Sun Jul 04 15:35:33 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
--- a/tests/templates/footer.gplate Sun Jul 04 15:35:33 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
--- a/tests/templates/header.gplate Sun Jul 04 15:35:33 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
--- a/tests/templates/html.gplate Sun Jul 04 15:35:33 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-{% include "header.gplate" %}in the body{% include "footer.gplate" %}
--- a/tests/templates/simple-include.gplate Sun Jul 04 15:35:33 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-inside the included file
--- a/tests/templates/simple.gplate Sun Jul 04 15:35:33 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-{% include "simple-include.gplate" %}
--- a/tests/test-include.c Sun Jul 04 15:35:33 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,122 +0,0 @@
-#endif /* HAVE_CONFIG_H */
-#include <gplate/gplate.h>
-/******************************************************************************
- *****************************************************************************/
-static GPlateTemplate *tplate = NULL;
-static GError *error = NULL;
-static gchar *msg = NULL;
-/******************************************************************************
- *****************************************************************************/
- tplate = gplate_template_new();
- g_object_unref(G_OBJECT(tplate));
-/******************************************************************************
- *****************************************************************************/
-START_TEST(test_include_simple_static)
- gchar *output = NULL, *e1 = NULL, *e2 = NULL;
- const gchar *expected =
- "inside the included file\n\n"
- output = gplate_template_render_file(tplate, "templates/simple.gplate",
- fail_unless(error == NULL,
- (error && error->message) ? error->message : "Unknown failed");
- r = g_utf8_collate(output, expected);
- e1 = g_strescape(output, NULL);
- e2 = g_strescape(expected, NULL);
- msg = g_strdup_printf("\ngot: '%s'\nwanted: '%s'\n", e1, e2);
- fail_unless(r == 0, msg);
-START_TEST(test_include_html_header_footer)
- gchar *output = NULL, *e1 = NULL, *e2 = NULL;
- const gchar *expected =
- "\t\t<title>test</title>\n"
- output = gplate_template_render_file(tplate, "templates/html.gplate",
- fail_unless(error == NULL,
- (error && error->message) ? error->message : "Unknown failure");
- r = g_utf8_collate(output, expected);
- e1 = g_strescape(output, NULL);
- e2 = g_strescape(expected, NULL);
- msg = g_strdup_printf("\ngot: '%s'\nwanted: '%s'\n", e1, e2);
- fail_unless(r == 0, msg);
-/******************************************************************************
- *****************************************************************************/
- Suite *s = suite_create("Include Function Suite");
- tc = tcase_create("Simple Includes");
- tcase_add_checked_fixture(tc, simple_setup, simple_teardown);
- tcase_add_test(tc, test_include_simple_static);
- tcase_add_test(tc, test_include_html_header_footer);
- suite_add_tcase(s, tc);