--- a/gplate/functions/tests/CMakeLists.txt Sun Jul 04 03:36:01 2010 -0500
+++ b/gplate/functions/tests/CMakeLists.txt Sun Jul 04 03:40:27 2010 -0500
@@ -1,6 +1,11 @@
-add_executable(test-for-function test-for-function.c)
-target_link_libraries(test-for-function gplate)
-add_test(GPlateForFunction test-for-function)
+add_executable(test-gplate-for-function test-gplate-for-function.c) +target_link_libraries(test-gplate-for-function gplate) +list(APPEND FUNCTION_TESTS test-gplate-for-function) +add_test(GPlateFunctions + ${GTESTER} -k --verbose -o test-gplate-function.log --- a/gplate/functions/tests/test-for-function.c Sun Jul 04 03:36:01 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,188 +0,0 @@
- * 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>
-#include <gplate/variables/gplate-dictionary-variable.h>
-/******************************************************************************
- *****************************************************************************/
-} GPlateForFunctionTestData;
- GPlateTemplate *template;
- const gchar *template_string;
- GPlateForFunctionTestData *data;
-} GPlateForFunctionTestFixture;
-/******************************************************************************
- *****************************************************************************/
-gplate_for_function_test_setup(GPlateForFunctionTestFixture *fixture,
- fixture->template = gplate_template_new();
- fixture->dict = gplate_dictionary_variable_new("list");
- gplate_collection_add_variable(GPLATE_COLLECTION(fixture->template),
-gplate_for_function_test_teardown(GPlateForFunctionTestFixture *fixture,
- g_object_unref(fixture->template);
- fixture->template = NULL;
- g_object_unref(fixture->dict);
- g_free(fixture->actual);
- fixture->actual = NULL;
- fixture->expected = NULL;
- g_error_free(fixture->error);
-/******************************************************************************
- *****************************************************************************/
-gplate_for_function_test(GPlateForFunctionTestFixture *fixture) {
- /* add the variables */
- for(i = 0; fixture->data[i].name; i++) {
- gplate_collection_add_string(fixture->dict,
- fixture->data[i].value);
- fixture->actual = gplate_template_render(fixture->template,
- fixture->template_string,
- g_assert(fixture->error == NULL);
- g_assert_cmpstr(fixture->expected, ==, fixture->actual);
-/******************************************************************************
- *****************************************************************************/
-gplate_for_function_test_zero_elements(GPlateForFunctionTestFixture *fixture,
- gconstpointer user_data)
- GPlateForFunctionTestData data[] = {
- fixture->template_string = "{% for in in line %}{{ i }}{% endfor %}";
- fixture->expected = "";
- gplate_for_function_test(fixture);
-gplate_for_function_test_one_element(GPlateForFunctionTestFixture *fixture,
- gconstpointer user_data)
- GPlateForFunctionTestData data[] = {
- fixture->template_string = "{% for i in list %}{{ i }}{% endfor %}";
- fixture->expected = "1";
- gplate_for_function_test(fixture);
-gplate_for_function_test_two_elements(GPlateForFunctionTestFixture *fixture,
- gconstpointer user_data)
- GPlateForFunctionTestData data[] = {
- fixture->template_string = "{% for i in list %}{{ i }}{% endfor %}";
- fixture->expected = "AB";
- gplate_for_function_test(fixture);
-/******************************************************************************
- *****************************************************************************/
-main(gint argc, gchar **argv) {
- g_test_init(&argc, &argv, NULL);
- gplate_config_load_default();
- g_test_add("/functions/foo/zero_elements",
- GPlateForFunctionTestFixture,
- gplate_for_function_test_setup,
- gplate_for_function_test_zero_elements,
- gplate_for_function_test_teardown);
- g_test_add("/functions/foo/one_element",
- GPlateForFunctionTestFixture,
- gplate_for_function_test_setup,
- gplate_for_function_test_one_element,
- gplate_for_function_test_teardown);
- g_test_add("/functions/foo/two_elements",
- GPlateForFunctionTestFixture,
- gplate_for_function_test_setup,
- gplate_for_function_test_two_elements,
- gplate_for_function_test_teardown);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/functions/tests/test-gplate-for-function.c Sun Jul 04 03:40:27 2010 -0500
@@ -0,0 +1,188 @@
+ * 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> +#include <gplate/variables/gplate-dictionary-variable.h> +/****************************************************************************** + *****************************************************************************/ +} GPlateForFunctionTestData; + GPlateTemplate *template; + const gchar *template_string; + GPlateForFunctionTestData *data; +} GPlateForFunctionTestFixture; +/****************************************************************************** + *****************************************************************************/ +gplate_for_function_test_setup(GPlateForFunctionTestFixture *fixture, + fixture->template = gplate_template_new(); + fixture->dict = gplate_dictionary_variable_new("list"); + gplate_collection_add_variable(GPLATE_COLLECTION(fixture->template), +gplate_for_function_test_teardown(GPlateForFunctionTestFixture *fixture, + g_object_unref(fixture->template); + fixture->template = NULL; + g_object_unref(fixture->dict); + g_free(fixture->actual); + fixture->actual = NULL; + fixture->expected = NULL; + g_error_free(fixture->error); +/****************************************************************************** + *****************************************************************************/ +gplate_for_function_test(GPlateForFunctionTestFixture *fixture) { + /* add the variables */ + for(i = 0; fixture->data[i].name; i++) { + gplate_collection_add_string(fixture->dict, + fixture->data[i].value); + fixture->actual = gplate_template_render(fixture->template, + fixture->template_string, + g_assert(fixture->error == NULL); + g_assert_cmpstr(fixture->expected, ==, fixture->actual); +/****************************************************************************** + *****************************************************************************/ +gplate_for_function_test_zero_elements(GPlateForFunctionTestFixture *fixture, + gconstpointer user_data) + GPlateForFunctionTestData data[] = { + fixture->template_string = "{% for in in line %}{{ i }}{% endfor %}"; + fixture->expected = ""; + gplate_for_function_test(fixture); +gplate_for_function_test_one_element(GPlateForFunctionTestFixture *fixture, + gconstpointer user_data) + GPlateForFunctionTestData data[] = { + fixture->template_string = "{% for i in list %}{{ i }}{% endfor %}"; + fixture->expected = "1"; + gplate_for_function_test(fixture); +gplate_for_function_test_two_elements(GPlateForFunctionTestFixture *fixture, + gconstpointer user_data) + GPlateForFunctionTestData data[] = { + fixture->template_string = "{% for i in list %}{{ i }}{% endfor %}"; + fixture->expected = "AB"; + gplate_for_function_test(fixture); +/****************************************************************************** + *****************************************************************************/ +main(gint argc, gchar **argv) { + g_test_init(&argc, &argv, NULL); + gplate_config_load_default(); + g_test_add("/functions/foo/zero_elements", + GPlateForFunctionTestFixture, + gplate_for_function_test_setup, + gplate_for_function_test_zero_elements, + gplate_for_function_test_teardown); + g_test_add("/functions/foo/one_element", + GPlateForFunctionTestFixture, + gplate_for_function_test_setup, + gplate_for_function_test_one_element, + gplate_for_function_test_teardown); + g_test_add("/functions/foo/two_elements", + GPlateForFunctionTestFixture, + gplate_for_function_test_setup, + gplate_for_function_test_two_elements, + gplate_for_function_test_teardown); --- a/gplate/tests/CMakeLists.txt Sun Jul 04 03:36:01 2010 -0500
+++ b/gplate/tests/CMakeLists.txt Sun Jul 04 03:40:27 2010 -0500
@@ -6,7 +6,7 @@
add_executable(test-gplate-collection-interface test-gplate-collection-interface.c)
target_link_libraries(test-gplate-collection-interface gplate)
add_test(GPlateCollectionInterface
- gtester -k --verbose -o test-gplate-collection-interface.log
+ ${GTESTER} -k --verbose -o test-gplate-collection-interface.log test-gplate-collection-interface
@@ -16,7 +16,7 @@
add_executable(test-gplate-utility-functions test-gplate-utility-functions.c)
target_link_libraries(test-gplate-utility-functions gplate)
add_test(GPlateUtilityFunctions
- gtester -k --verbose -o test-gplate-utility-functions.log
+ ${GTESTER} -k --verbose -o test-gplate-utility-functions.log test-gplate-utility-functions