guess there wasn't a whole lot left for the test name standardization
authorGary Kramlich <grim@reaperworld.com>
Sun Jul 04 03:40:27 2010 -0500 (19 months ago)
changeset 402b9a2a060c766
parent 401 6611e9570ec2
child 403 13b5031b2846
guess there wasn't a whole lot left for the test name standardization

closes #15
gplate/functions/tests/CMakeLists.txt
gplate/functions/tests/test-for-function.c
gplate/functions/tests/test-gplate-for-function.c
gplate/tests/CMakeLists.txt
     1.1 --- a/gplate/functions/tests/CMakeLists.txt	Sun Jul 04 03:36:01 2010 -0500
     1.2 +++ b/gplate/functions/tests/CMakeLists.txt	Sun Jul 04 03:40:27 2010 -0500
     1.3 @@ -1,6 +1,11 @@
     1.4  enable_testing()
     1.5  
     1.6 -add_executable(test-for-function test-for-function.c)
     1.7 -target_link_libraries(test-for-function gplate)
     1.8 -add_test(GPlateForFunction test-for-function)
     1.9 +add_executable(test-gplate-for-function test-gplate-for-function.c)
    1.10 +target_link_libraries(test-gplate-for-function gplate)
    1.11 +list(APPEND FUNCTION_TESTS test-gplate-for-function)
    1.12  
    1.13 +add_test(GPlateFunctions
    1.14 +         ${GTESTER} -k --verbose -o test-gplate-function.log
    1.15 +         ${FUNCTION_TESTS}
    1.16 +)
    1.17 +
     2.1 --- a/gplate/functions/tests/test-for-function.c	Sun Jul 04 03:36:01 2010 -0500
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,188 +0,0 @@
     2.4 -/*
     2.5 - * Copyright (C) 2007-2010 Gary Kramlich <grim@reaperworld.com>
     2.6 - *
     2.7 - * This program is free software: you can redistribute it and/or modify
     2.8 - * it under the terms of the GNU General Public License as published by
     2.9 - * the Free Software Foundation, either version 3 of the License, or
    2.10 - * (at your option) any later version.
    2.11 - *
    2.12 - * This program is distributed in the hope that it will be useful,
    2.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    2.15 - * GNU General Public License for more details.
    2.16 - *
    2.17 - * You should have received a copy of the GNU General Public License
    2.18 - * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    2.19 - */
    2.20 -#include <gplate/gplate.h>
    2.21 -#include <gplate/variables/gplate-dictionary-variable.h>
    2.22 -
    2.23 -#include <glib.h>
    2.24 -
    2.25 -/******************************************************************************
    2.26 - * Structs
    2.27 - *****************************************************************************/
    2.28 -typedef struct {
    2.29 -	const gchar *name;
    2.30 -	const gchar *value;
    2.31 -} GPlateForFunctionTestData;
    2.32 -
    2.33 -typedef struct {
    2.34 -	GPlateTemplate *template;
    2.35 -
    2.36 -	GPlateVariable *dict;
    2.37 -
    2.38 -	const gchar *template_string;
    2.39 -
    2.40 -	gchar *actual;
    2.41 -	const gchar *expected;
    2.42 -
    2.43 -	GError *error;
    2.44 -
    2.45 -	GPlateForFunctionTestData *data;
    2.46 -} GPlateForFunctionTestFixture;
    2.47 -
    2.48 -/******************************************************************************
    2.49 - * Fixtures
    2.50 - *****************************************************************************/
    2.51 -static void
    2.52 -gplate_for_function_test_setup(GPlateForFunctionTestFixture *fixture,
    2.53 -                               gconstpointer d)
    2.54 -{
    2.55 -	fixture->template = gplate_template_new();
    2.56 -	fixture->dict = gplate_dictionary_variable_new("list");
    2.57 -
    2.58 -	gplate_collection_add_variable(GPLATE_COLLECTION(fixture->template),
    2.59 -	                               fixture->dict);
    2.60 -}
    2.61 -
    2.62 -static void
    2.63 -gplate_for_function_test_teardown(GPlateForFunctionTestFixture *fixture,
    2.64 -                                  gconstpointer d)
    2.65 -{
    2.66 -	g_object_unref(fixture->template);
    2.67 -	fixture->template = NULL;
    2.68 -
    2.69 -	g_object_unref(fixture->dict);
    2.70 -	fixture->dict = NULL;
    2.71 -
    2.72 -	g_free(fixture->actual);
    2.73 -	fixture->actual = NULL;
    2.74 -
    2.75 -	fixture->expected = NULL;
    2.76 -
    2.77 -	if(fixture->error) {
    2.78 -		g_error_free(fixture->error);
    2.79 -		fixture->error = NULL;
    2.80 -	}
    2.81 -}
    2.82 -
    2.83 -/******************************************************************************
    2.84 - * Helpers
    2.85 - *****************************************************************************/
    2.86 -static void
    2.87 -gplate_for_function_test(GPlateForFunctionTestFixture *fixture) {
    2.88 -	gint i = 0;
    2.89 -
    2.90 -	/* add the variables */
    2.91 -	for(i = 0; fixture->data[i].name; i++) {
    2.92 -		gplate_collection_add_string(fixture->dict,
    2.93 -		                             fixture->data[i].name,
    2.94 -		                             fixture->data[i].value);
    2.95 -	}
    2.96 -
    2.97 -	fixture->actual = gplate_template_render(fixture->template,
    2.98 -	                                         fixture->template_string,
    2.99 -	                                         &fixture->error);
   2.100 -
   2.101 -	g_assert(fixture->error == NULL);
   2.102 -
   2.103 -	g_assert_cmpstr(fixture->expected, ==, fixture->actual);
   2.104 -}
   2.105 -
   2.106 -/******************************************************************************
   2.107 - * Simple For's
   2.108 - *****************************************************************************/
   2.109 -static void
   2.110 -gplate_for_function_test_zero_elements(GPlateForFunctionTestFixture *fixture,
   2.111 -                                       gconstpointer user_data)
   2.112 -{
   2.113 -	GPlateForFunctionTestData data[] = {
   2.114 -		{ NULL, NULL },
   2.115 -	};
   2.116 -
   2.117 -	fixture->data = data;
   2.118 -	fixture->template_string = "{% for in in line %}{{ i }}{% endfor %}";
   2.119 -	fixture->expected = "";
   2.120 -
   2.121 -	gplate_for_function_test(fixture);
   2.122 -}
   2.123 -
   2.124 -static void
   2.125 -gplate_for_function_test_one_element(GPlateForFunctionTestFixture *fixture,
   2.126 -                                     gconstpointer user_data)
   2.127 -{
   2.128 -	GPlateForFunctionTestData data[] = {
   2.129 -		{ "one", "1" },
   2.130 -		{ NULL, NULL },
   2.131 -	};
   2.132 -
   2.133 -	fixture->data = data;
   2.134 -	fixture->template_string = "{% for i in list %}{{ i }}{% endfor %}";
   2.135 -	fixture->expected = "1";
   2.136 -
   2.137 -	gplate_for_function_test(fixture);
   2.138 -}
   2.139 -
   2.140 -static void
   2.141 -gplate_for_function_test_two_elements(GPlateForFunctionTestFixture *fixture,
   2.142 -                                      gconstpointer user_data)
   2.143 -{
   2.144 -	GPlateForFunctionTestData data[] = {
   2.145 -		{ "a", "A" },
   2.146 -		{ "b", "B" },
   2.147 -		{ NULL, NULL },
   2.148 -	};
   2.149 -
   2.150 -	fixture->data = data;
   2.151 -	fixture->template_string = "{% for i in list %}{{ i }}{% endfor %}";
   2.152 -	fixture->expected = "AB";
   2.153 -
   2.154 -	gplate_for_function_test(fixture);
   2.155 -}
   2.156 -
   2.157 -/******************************************************************************
   2.158 - * Main!
   2.159 - *****************************************************************************/
   2.160 -gint
   2.161 -main(gint argc, gchar **argv) {
   2.162 -	g_test_init(&argc, &argv, NULL);
   2.163 -
   2.164 -	g_type_init();
   2.165 -
   2.166 -	gplate_config_load_default();
   2.167 -
   2.168 -	g_test_add("/functions/foo/zero_elements",
   2.169 -	           GPlateForFunctionTestFixture,
   2.170 -	           NULL,
   2.171 -	           gplate_for_function_test_setup,
   2.172 -	           gplate_for_function_test_zero_elements,
   2.173 -	           gplate_for_function_test_teardown);
   2.174 -
   2.175 -	g_test_add("/functions/foo/one_element",
   2.176 -	           GPlateForFunctionTestFixture,
   2.177 -	           NULL,
   2.178 -	           gplate_for_function_test_setup,
   2.179 -	           gplate_for_function_test_one_element,
   2.180 -	           gplate_for_function_test_teardown);
   2.181 -
   2.182 -	g_test_add("/functions/foo/two_elements",
   2.183 -	           GPlateForFunctionTestFixture,
   2.184 -	           NULL,
   2.185 -	           gplate_for_function_test_setup,
   2.186 -	           gplate_for_function_test_two_elements,
   2.187 -	           gplate_for_function_test_teardown);
   2.188 -
   2.189 -	return g_test_run();
   2.190 -}
   2.191 -
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/gplate/functions/tests/test-gplate-for-function.c	Sun Jul 04 03:40:27 2010 -0500
     3.3 @@ -0,0 +1,188 @@
     3.4 +/*
     3.5 + * Copyright (C) 2007-2010 Gary Kramlich <grim@reaperworld.com>
     3.6 + *
     3.7 + * This program is free software: you can redistribute it and/or modify
     3.8 + * it under the terms of the GNU General Public License as published by
     3.9 + * the Free Software Foundation, either version 3 of the License, or
    3.10 + * (at your option) any later version.
    3.11 + *
    3.12 + * This program is distributed in the hope that it will be useful,
    3.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    3.15 + * GNU General Public License for more details.
    3.16 + *
    3.17 + * You should have received a copy of the GNU General Public License
    3.18 + * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    3.19 + */
    3.20 +#include <gplate/gplate.h>
    3.21 +#include <gplate/variables/gplate-dictionary-variable.h>
    3.22 +
    3.23 +#include <glib.h>
    3.24 +
    3.25 +/******************************************************************************
    3.26 + * Structs
    3.27 + *****************************************************************************/
    3.28 +typedef struct {
    3.29 +	const gchar *name;
    3.30 +	const gchar *value;
    3.31 +} GPlateForFunctionTestData;
    3.32 +
    3.33 +typedef struct {
    3.34 +	GPlateTemplate *template;
    3.35 +
    3.36 +	GPlateVariable *dict;
    3.37 +
    3.38 +	const gchar *template_string;
    3.39 +
    3.40 +	gchar *actual;
    3.41 +	const gchar *expected;
    3.42 +
    3.43 +	GError *error;
    3.44 +
    3.45 +	GPlateForFunctionTestData *data;
    3.46 +} GPlateForFunctionTestFixture;
    3.47 +
    3.48 +/******************************************************************************
    3.49 + * Fixtures
    3.50 + *****************************************************************************/
    3.51 +static void
    3.52 +gplate_for_function_test_setup(GPlateForFunctionTestFixture *fixture,
    3.53 +                               gconstpointer d)
    3.54 +{
    3.55 +	fixture->template = gplate_template_new();
    3.56 +	fixture->dict = gplate_dictionary_variable_new("list");
    3.57 +
    3.58 +	gplate_collection_add_variable(GPLATE_COLLECTION(fixture->template),
    3.59 +	                               fixture->dict);
    3.60 +}
    3.61 +
    3.62 +static void
    3.63 +gplate_for_function_test_teardown(GPlateForFunctionTestFixture *fixture,
    3.64 +                                  gconstpointer d)
    3.65 +{
    3.66 +	g_object_unref(fixture->template);
    3.67 +	fixture->template = NULL;
    3.68 +
    3.69 +	g_object_unref(fixture->dict);
    3.70 +	fixture->dict = NULL;
    3.71 +
    3.72 +	g_free(fixture->actual);
    3.73 +	fixture->actual = NULL;
    3.74 +
    3.75 +	fixture->expected = NULL;
    3.76 +
    3.77 +	if(fixture->error) {
    3.78 +		g_error_free(fixture->error);
    3.79 +		fixture->error = NULL;
    3.80 +	}
    3.81 +}
    3.82 +
    3.83 +/******************************************************************************
    3.84 + * Helpers
    3.85 + *****************************************************************************/
    3.86 +static void
    3.87 +gplate_for_function_test(GPlateForFunctionTestFixture *fixture) {
    3.88 +	gint i = 0;
    3.89 +
    3.90 +	/* add the variables */
    3.91 +	for(i = 0; fixture->data[i].name; i++) {
    3.92 +		gplate_collection_add_string(fixture->dict,
    3.93 +		                             fixture->data[i].name,
    3.94 +		                             fixture->data[i].value);
    3.95 +	}
    3.96 +
    3.97 +	fixture->actual = gplate_template_render(fixture->template,
    3.98 +	                                         fixture->template_string,
    3.99 +	                                         &fixture->error);
   3.100 +
   3.101 +	g_assert(fixture->error == NULL);
   3.102 +
   3.103 +	g_assert_cmpstr(fixture->expected, ==, fixture->actual);
   3.104 +}
   3.105 +
   3.106 +/******************************************************************************
   3.107 + * Simple For's
   3.108 + *****************************************************************************/
   3.109 +static void
   3.110 +gplate_for_function_test_zero_elements(GPlateForFunctionTestFixture *fixture,
   3.111 +                                       gconstpointer user_data)
   3.112 +{
   3.113 +	GPlateForFunctionTestData data[] = {
   3.114 +		{ NULL, NULL },
   3.115 +	};
   3.116 +
   3.117 +	fixture->data = data;
   3.118 +	fixture->template_string = "{% for in in line %}{{ i }}{% endfor %}";
   3.119 +	fixture->expected = "";
   3.120 +
   3.121 +	gplate_for_function_test(fixture);
   3.122 +}
   3.123 +
   3.124 +static void
   3.125 +gplate_for_function_test_one_element(GPlateForFunctionTestFixture *fixture,
   3.126 +                                     gconstpointer user_data)
   3.127 +{
   3.128 +	GPlateForFunctionTestData data[] = {
   3.129 +		{ "one", "1" },
   3.130 +		{ NULL, NULL },
   3.131 +	};
   3.132 +
   3.133 +	fixture->data = data;
   3.134 +	fixture->template_string = "{% for i in list %}{{ i }}{% endfor %}";
   3.135 +	fixture->expected = "1";
   3.136 +
   3.137 +	gplate_for_function_test(fixture);
   3.138 +}
   3.139 +
   3.140 +static void
   3.141 +gplate_for_function_test_two_elements(GPlateForFunctionTestFixture *fixture,
   3.142 +                                      gconstpointer user_data)
   3.143 +{
   3.144 +	GPlateForFunctionTestData data[] = {
   3.145 +		{ "a", "A" },
   3.146 +		{ "b", "B" },
   3.147 +		{ NULL, NULL },
   3.148 +	};
   3.149 +
   3.150 +	fixture->data = data;
   3.151 +	fixture->template_string = "{% for i in list %}{{ i }}{% endfor %}";
   3.152 +	fixture->expected = "AB";
   3.153 +
   3.154 +	gplate_for_function_test(fixture);
   3.155 +}
   3.156 +
   3.157 +/******************************************************************************
   3.158 + * Main!
   3.159 + *****************************************************************************/
   3.160 +gint
   3.161 +main(gint argc, gchar **argv) {
   3.162 +	g_test_init(&argc, &argv, NULL);
   3.163 +
   3.164 +	g_type_init();
   3.165 +
   3.166 +	gplate_config_load_default();
   3.167 +
   3.168 +	g_test_add("/functions/foo/zero_elements",
   3.169 +	           GPlateForFunctionTestFixture,
   3.170 +	           NULL,
   3.171 +	           gplate_for_function_test_setup,
   3.172 +	           gplate_for_function_test_zero_elements,
   3.173 +	           gplate_for_function_test_teardown);
   3.174 +
   3.175 +	g_test_add("/functions/foo/one_element",
   3.176 +	           GPlateForFunctionTestFixture,
   3.177 +	           NULL,
   3.178 +	           gplate_for_function_test_setup,
   3.179 +	           gplate_for_function_test_one_element,
   3.180 +	           gplate_for_function_test_teardown);
   3.181 +
   3.182 +	g_test_add("/functions/foo/two_elements",
   3.183 +	           GPlateForFunctionTestFixture,
   3.184 +	           NULL,
   3.185 +	           gplate_for_function_test_setup,
   3.186 +	           gplate_for_function_test_two_elements,
   3.187 +	           gplate_for_function_test_teardown);
   3.188 +
   3.189 +	return g_test_run();
   3.190 +}
   3.191 +
     4.1 --- a/gplate/tests/CMakeLists.txt	Sun Jul 04 03:36:01 2010 -0500
     4.2 +++ b/gplate/tests/CMakeLists.txt	Sun Jul 04 03:40:27 2010 -0500
     4.3 @@ -6,7 +6,7 @@
     4.4  add_executable(test-gplate-collection-interface test-gplate-collection-interface.c)
     4.5  target_link_libraries(test-gplate-collection-interface gplate)
     4.6  add_test(GPlateCollectionInterface
     4.7 -         gtester -k --verbose -o test-gplate-collection-interface.log
     4.8 +         ${GTESTER} -k --verbose -o test-gplate-collection-interface.log
     4.9           test-gplate-collection-interface
    4.10  )
    4.11  
    4.12 @@ -16,7 +16,7 @@
    4.13  add_executable(test-gplate-utility-functions test-gplate-utility-functions.c)
    4.14  target_link_libraries(test-gplate-utility-functions gplate)
    4.15  add_test(GPlateUtilityFunctions
    4.16 -         gtester -k --verbose -o test-gplate-utility-functions.log
    4.17 +         ${GTESTER} -k --verbose -o test-gplate-utility-functions.log
    4.18           test-gplate-utility-functions
    4.19  )
    4.20