consolidated all of the tests to /tests and made them get run by default. There's a ton of work to do here yet, since some are still in "check" format and others fail
--- a/CMakeLists.txt Mon Sep 03 17:52:20 2012 -0500
+++ b/CMakeLists.txt Mon Sep 03 18:45:07 2012 -0500
@@ -63,6 +63,7 @@
###############################################################################
###############################################################################
--- a/gplate/CMakeLists.txt Mon Sep 03 17:52:20 2012 -0500
+++ b/gplate/CMakeLists.txt Mon Sep 03 18:45:07 2012 -0500
@@ -1,10 +1,7 @@
add_subdirectory(functions)
add_subdirectory(variables)
--- a/gplate/functions/CMakeLists.txt Mon Sep 03 17:52:20 2012 -0500
+++ b/gplate/functions/CMakeLists.txt Mon Sep 03 18:45:07 2012 -0500
@@ -1,7 +1,3 @@
set(GPLATE_FUNCTIONS_HEADERS
gplate-include-function.h
--- a/gplate/functions/tests/CMakeLists.txt Mon Sep 03 17:52:20 2012 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-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_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)
-add_test(GPlateFunctions
- ${GTESTER} -k --verbose -o test-gplate-function.log
--- a/gplate/functions/tests/templates/footer.gplate Mon Sep 03 17:52:20 2012 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
--- a/gplate/functions/tests/templates/header.gplate Mon Sep 03 17:52:20 2012 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
--- a/gplate/functions/tests/templates/html.gplate Mon Sep 03 17:52:20 2012 -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/gplate/functions/tests/templates/simple-include.gplate Mon Sep 03 17:52:20 2012 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
--- a/gplate/functions/tests/templates/simple.gplate Mon Sep 03 17:52:20 2012 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-{% include "simple-include.gplate" %}
--- a/gplate/functions/tests/test-gplate-for-function.c Mon Sep 03 17:52:20 2012 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,189 +0,0 @@
- * GPlate - GObject based templating library
- * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com>
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This library 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 Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
-#include <gplate/gplate.h>
-#include <gplate/variables/gplate-dictionary-variable.h>
-/******************************************************************************
- *****************************************************************************/
-} TestGPlateForFunctionData;
- GPlateTemplate *template;
- const gchar *template_string;
- TestGPlateForFunctionData *data;
-} TestGPlateForFunctionFixture;
-/******************************************************************************
- *****************************************************************************/
-test_gplate_for_function_setup(TestGPlateForFunctionFixture *fixture,
- fixture->template = gplate_template_new();
- fixture->dict = gplate_dictionary_variable_new("list");
- gplate_collection_add_variable(GPLATE_COLLECTION(fixture->template),
-test_gplate_for_function_teardown(TestGPlateForFunctionFixture *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);
-/******************************************************************************
- *****************************************************************************/
-test_gplate_for_function(TestGPlateForFunctionFixture *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);
-/******************************************************************************
- *****************************************************************************/
-test_gplate_for_function_zero_elements(TestGPlateForFunctionFixture *fixture,
- gconstpointer user_data)
- TestGPlateForFunctionData data[] = {
- fixture->template_string = "{% for in in line %}{{ i }}{% endfor %}";
- fixture->expected = "";
- test_gplate_for_function(fixture);
-test_gplate_for_function_one_element(TestGPlateForFunctionFixture *fixture,
- gconstpointer user_data)
- TestGPlateForFunctionData data[] = {
- fixture->template_string = "{% for i in list %}{{ i }}{% endfor %}";
- fixture->expected = "1";
- test_gplate_for_function(fixture);
-test_gplate_for_function_two_elements(TestGPlateForFunctionFixture *fixture,
- gconstpointer user_data)
- TestGPlateForFunctionData data[] = {
- fixture->template_string = "{% for i in list %}{{ i }}{% endfor %}";
- fixture->expected = "AB";
- test_gplate_for_function(fixture);
-/******************************************************************************
- *****************************************************************************/
-main(gint argc, gchar **argv) {
- g_test_init(&argc, &argv, NULL);
- gplate_config_load_default();
- g_test_add("/functions/foo/zero_elements",
- TestGPlateForFunctionFixture,
- test_gplate_for_function_setup,
- test_gplate_for_function_zero_elements,
- test_gplate_for_function_teardown);
- g_test_add("/functions/foo/one_element",
- TestGPlateForFunctionFixture,
- test_gplate_for_function_setup,
- test_gplate_for_function_one_element,
- test_gplate_for_function_teardown);
- g_test_add("/functions/foo/two_elements",
- TestGPlateForFunctionFixture,
- test_gplate_for_function_setup,
- test_gplate_for_function_two_elements,
- test_gplate_for_function_teardown);
--- a/gplate/functions/tests/test-gplate-include-function.c Mon Sep 03 17:52:20 2012 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,132 +0,0 @@
- * GPlate - GObject based templating library
- * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com>
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This library 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 Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library. 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/gplate/tags/CMakeLists.txt Mon Sep 03 17:52:20 2012 -0500
+++ b/gplate/tags/CMakeLists.txt Mon Sep 03 18:45:07 2012 -0500
@@ -1,7 +1,3 @@
--- a/gplate/tags/tests/CMakeLists.txt Mon Sep 03 17:52:20 2012 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-# define the static library for tag testing
-add_library(test-gplate-tag STATIC
-target_link_libraries(test-gplate-tag gplate)
-# add the text tag tests
-add_executable(test-gplate-text-tag test-gplate-text-tag.c)
-target_link_libraries(test-gplate-text-tag test-gplate-tag)
-list(APPEND TAG_TESTS test-gplate-text-tag)
-# add the variable tag tests
-add_executable(test-gplate-variable-tag test-gplate-variable-tag.c)
-target_link_libraries(test-gplate-variable-tag test-gplate-tag)
-list(APPEND TAG_TESTS test-gplate-variable-tag)
-# add the comment tag tests
-add_executable(test-gplate-comment-tag test-gplate-comment-tag.c)
-target_link_libraries(test-gplate-comment-tag test-gplate-tag)
-list(APPEND TAG_TESTS test-gplate-comment-tag)
-# add the tests for gtester
- ${GTESTER} -k --verbose -o test-gplate-tag.log
--- a/gplate/tags/tests/test-gplate-comment-tag.c Mon Sep 03 17:52:20 2012 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
- * GPlate - GObject based templating library
- * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com>
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This library 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 Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
-#include <gplate/gplate.h>
-#include "test-gplate-tag.h"
-/******************************************************************************
- *****************************************************************************/
-test_gplate_comment_tag_empty(TestGPlateTagFixture *fixture,
- test_gplate_tag_output(fixture, data, "{##}", "");
-test_gplate_comment_tag_whitespace(TestGPlateTagFixture *fixture,
- test_gplate_tag_output(fixture, data, "{# #}", "");
- test_gplate_tag_output(fixture, data, "{#\t#}", "");
- test_gplate_tag_output(fixture, data, "{#\n#}", "");
- test_gplate_tag_output(fixture, data, "{#\r#}", "");
- test_gplate_tag_output(fixture, data, "{#\r\n#}", "");
- test_gplate_tag_output(fixture, data, "{#\n\r#}", "");
-test_gplate_comment_tag_simple(TestGPlateTagFixture *fixture,
- test_gplate_tag_output(fixture, data, "{# foo#}", "");
- test_gplate_tag_output(fixture, data, "{#foo #}", "");
- test_gplate_tag_output(fixture, data, "{#\tfoo#}", "");
- test_gplate_tag_output(fixture, data, "{#foo\t#}", "");
- test_gplate_tag_output(fixture, data, "{#\nfoo#}", "");
- test_gplate_tag_output(fixture, data, "{#foo\n#}", "");
- test_gplate_tag_output(fixture, data, "{#\rfoo#}", "");
- test_gplate_tag_output(fixture, data, "{#foo\r#}", "");
- test_gplate_tag_output(fixture, data, "{#\r\nfoo#}", "");
- test_gplate_tag_output(fixture, data, "{#foo\r\n#}", "");
-/******************************************************************************
- *****************************************************************************/
-main(gint argc, gchar **argv) {
- g_test_init(&argc, &argv, NULL);
- gplate_config_load_default();
- test_gplate_tag_add("/tags/comment/empty",
- test_gplate_comment_tag_empty);
- test_gplate_tag_add("/tags/comment/whitespace",
- test_gplate_comment_tag_whitespace);
- test_gplate_tag_add("/tags/comment/simple",
- test_gplate_comment_tag_simple);
--- a/gplate/tags/tests/test-gplate-tag.c Mon Sep 03 17:52:20 2012 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
- * GPlate - GObject based templating library
- * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com>
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This library 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 Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
-#include "test-gplate-tag.h"
-test_gplate_tag_setup(TestGPlateTagFixture *fixture, gconstpointer data) {
- fixture->template = gplate_template_new();
-test_gplate_tag_teardown(TestGPlateTagFixture *fixture, gconstpointer data) {
- g_object_unref(fixture->template);
- fixture->template = NULL;
- g_error_free(fixture->error);
- g_free(fixture->actual);
- fixture->actual = NULL;
-test_gplate_tag_output(TestGPlateTagFixture *fixture,
- const gchar *template_string,
- fixture->template_string = template_string;
- fixture->expected = expected;
- fixture->actual = gplate_template_render(fixture->template,
- fixture->template_string,
- g_assert(fixture->error == NULL);
- g_assert_cmpstr(fixture->expected, ==, fixture->actual);
--- a/gplate/tags/tests/test-gplate-tag.h Mon Sep 03 17:52:20 2012 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
- * GPlate - GObject based templating library
- * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com>
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This library 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 Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
-#ifndef TEST_GPLATE_TAG_H
-#define TEST_GPLATE_TAG_H
-#include <gplate/gplate.h>
-#define test_gplate_tag_add(path, func) \
- g_test_add((path), TestGPlateTagFixture, NULL, test_gplate_tag_setup, (func), test_gplate_tag_teardown)
-typedef struct _TestGPlateTagFixture TestGPlateTagFixture;
-typedef void (*TestGPlateTagFixtureFunc)(TestGPlateTagFixture *fixture, gconstpointer data);
-struct _TestGPlateTagFixture {
- GPlateTemplate *template;
- const gchar *template_string;
-void test_gplate_tag_setup(TestGPlateTagFixture *fixture, gconstpointer data);
-void test_gplate_tag_teardown(TestGPlateTagFixture *fixture, gconstpointer data);
-void test_gplate_tag_output(TestGPlateTagFixture *fixture, gconstpointer data, const gchar *template_string, const gchar *expected);
-#endif /* TEST_GPLATE_TAG_H */
--- a/gplate/tags/tests/test-gplate-text-tag.c Mon Sep 03 17:52:20 2012 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
- * GPlate - GObject based templating library
- * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com>
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This library 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 Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
-#include <gplate/gplate.h>
-#include "test-gplate-tag.h"
-/******************************************************************************
- *****************************************************************************/
-test_gplate_text_tag_syntax_plain(TestGPlateTagFixture *fixture,
- test_gplate_tag_output(fixture, data,
- "simple template", "simple template");
-test_gplate_text_tag_syntax_keywords(TestGPlateTagFixture *fixture,
- test_gplate_tag_output(fixture, data,
- "extends if else endif for endfor",
- "extends if else endif for endfor");
-test_gplate_text_tag_syntax_keywords_case_sensitive(TestGPlateTagFixture *fixture,
- test_gplate_tag_output(fixture, data,
- "EXteNds iF eLse enDif fOr enDFor",
- "EXteNds iF eLse enDif fOr enDFor");
-/******************************************************************************
- *****************************************************************************/
-main(gint argc, gchar **argv) {
- g_test_init(&argc, &argv, NULL);
- gplate_config_load_default();
- test_gplate_tag_add("/tags/text/plain",
- test_gplate_text_tag_syntax_plain);
- test_gplate_tag_add("/tags/text/keywords",
- test_gplate_text_tag_syntax_keywords);
- test_gplate_tag_add("/tags/text/keywords_case_sensitive",
- test_gplate_text_tag_syntax_keywords_case_sensitive);
--- a/gplate/tags/tests/test-gplate-variable-tag.c Mon Sep 03 17:52:20 2012 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,237 +0,0 @@
- * GPlate - GObject based templating library
- * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com>
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This library 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 Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
-#include <gplate/gplate.h>
-#include "test-gplate-tag.h"
-/******************************************************************************
- *****************************************************************************/
-test_gplate_variable_tag(TestGPlateTagFixture *fixture, gconstpointer data,
- const gchar *template_string, const gchar *expected,
- const gchar *name = NULL, *value = NULL;
- va_start(vargs, expected);
- while((name = va_arg(vargs, const gchar *))) {
- value = va_arg(vargs, const gchar *);
- gplate_collection_add_string(GPLATE_COLLECTION(fixture->template),
- test_gplate_tag_output(fixture, data, template_string, expected);
-/******************************************************************************
- *****************************************************************************/
-test_gplate_variable_tag_single(TestGPlateTagFixture *fixture,
- test_gplate_variable_tag(fixture, data,
-test_gplate_variable_tag_double(TestGPlateTagFixture *fixture,
- test_gplate_variable_tag(fixture, data,
- "{{ foo }}{{ bar }}", "foobar",
-test_gplate_variable_tag_tripple(TestGPlateTagFixture *fixture,
- test_gplate_variable_tag(fixture, data,
- "{{ foo }}{{ bar }}{{ baz }}", "foobarbaz",
-test_gplate_variable_tag_newline_prefix(TestGPlateTagFixture *fixture,
- test_gplate_variable_tag(fixture, data,
-test_gplate_variable_tag_newline_suffix(TestGPlateTagFixture *fixture,
- test_gplate_variable_tag(fixture, data,
-test_gplate_variable_tag_newline_wrapped(TestGPlateTagFixture *fixture,
- test_gplate_variable_tag(fixture, data,
-test_gplate_variable_tag_single_quotes(TestGPlateTagFixture *fixture,
- test_gplate_variable_tag(fixture, data,
- "foo '{{ bar }}' baz", "foo 'bar' baz",
-test_gplate_variable_tag_double_quotes(TestGPlateTagFixture *fixture,
- test_gplate_variable_tag(fixture, data,
- "foo \"{{ bar }}\" baz", "foo \"bar\" baz",
-test_gplate_variable_tag_mixed_quotes(TestGPlateTagFixture *fixture,
- test_gplate_variable_tag(fixture, data,
- "foo \"{{ bar }}' baz", "foo \"bar' baz",
- test_gplate_variable_tag(fixture, data,
- "foo '{{ bar }}\" baz", "foo 'bar\" baz",
-test_gplate_variable_tag_two_vars_one_block(TestGPlateTagFixture *fixture,
- test_gplate_variable_tag(fixture, data,
- "one {{ two five }} three",
-test_gplate_variable_tag_nested_single(TestGPlateTagFixture *fixture,
- GPlateVariable *dict = gplate_dictionary_variable_new("foo");
- gplate_collection_add_string(GPLATE_COLLECTION(dict),
- test_gplate_tag_output(fixture, data, "{{ foo.bar }}", "baz");
-test_gplate_variable_tag_nested_double(TestGPlateTagFixture *fixture,
- GPlateVariable *dict1 = gplate_dictionary_variable_new("foo");
- GPlateVariable *dict2 = gplate_dictionary_variable_new("bar");
- gplate_collection_add_variable(GPLATE_COLLECTION(fixture->template),
- gplate_collection_add_variable(GPLATE_COLLECTION(dict1), dict2);
- gplate_collection_add_string(GPLATE_COLLECTION(dict2),
- test_gplate_tag_output(fixture, data, "{{ foo.bar.baz }}", "42");
-/******************************************************************************
- *****************************************************************************/
-main(gint argc, gchar **argv) {
- g_test_init(&argc, &argv, NULL);
- gplate_config_load_default();
- test_gplate_tag_add("/tags/variable/single",
- test_gplate_variable_tag_single);
- test_gplate_tag_add("/tags/variable/double",
- test_gplate_variable_tag_double);
- test_gplate_tag_add("/tags/variable/tripple",
- test_gplate_variable_tag_tripple);
- test_gplate_tag_add("/tags/variable/newline_prefix",
- test_gplate_variable_tag_newline_prefix);
- test_gplate_tag_add("/tags/variable/newline_suffix",
- test_gplate_variable_tag_newline_suffix);
- test_gplate_tag_add("/tags/variable/newline_wrapped",
- test_gplate_variable_tag_newline_wrapped);
- test_gplate_tag_add("/tags/variable/quotes/single",
- test_gplate_variable_tag_single_quotes);
- test_gplate_tag_add("/tags/variable/quotes/double",
- test_gplate_variable_tag_double_quotes);
- test_gplate_tag_add("/tags/variable/quotes/mixed",
- test_gplate_variable_tag_mixed_quotes);
- test_gplate_tag_add("/tags/variable/two_vars_one_block",
- test_gplate_variable_tag_two_vars_one_block);
- test_gplate_tag_add("/tags/variables/nested/single",
- test_gplate_variable_tag_nested_single);
- test_gplate_tag_add("/tags/variable/nested/double",
- test_gplate_variable_tag_nested_double);
--- a/gplate/tests/CMakeLists.txt Mon Sep 03 17:52:20 2012 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-###############################################################################
-###############################################################################
-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
- test-gplate-collection-interface
-###############################################################################
-###############################################################################
-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
- test-gplate-utility-functions
--- a/gplate/tests/test-gplate-collection-interface.c Mon Sep 03 17:52:20 2012 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
- * GPlate - GObject based templating library
- * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com>
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This library 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 Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
-#include <gplate/gplate.h>
-/******************************************************************************
- *****************************************************************************/
-main(gint argc, gchar **argv) {
- g_test_init(&argc, &argv, NULL);
- gplate_config_load_default();
--- a/gplate/tests/test-gplate-utility-functions.c Mon Sep 03 17:52:20 2012 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
- * GPlate - GObject based templating library
- * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com>
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This library 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 Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
-#include <gplate/gplate.h>
-gplate_util_test_quoted_string_helper(const gchar *string,
- const gchar *contents, gboolean value)
- r = gplate_util_is_quoted_string(string, &c);
- g_assert_cmpint(r, ==, value);
- g_assert_cmpstr(c, ==, contents);
-gplate_util_test_quoted_string(void) {
- gplate_util_test_quoted_string_helper("\"abc\"", "abc", TRUE);
- gplate_util_test_quoted_string_helper("\"abc def\"", "abc def", TRUE);
- gplate_util_test_quoted_string_helper("\"abc\tdef\bghi\"", "abc\tdef\bghi", TRUE);
- gplate_util_test_quoted_string_helper("abc \"def\"", NULL, FALSE);
- gplate_util_test_quoted_string_helper("\"abc\" def", NULL, FALSE);
- gplate_util_test_quoted_string_helper("'abc'", "abc", TRUE);
- gplate_util_test_quoted_string_helper("'abc def'", "abc def", TRUE);
- gplate_util_test_quoted_string_helper("'abc\tdef\bghi'", "abc\tdef\bghi", TRUE);
- gplate_util_test_quoted_string_helper("abc 'def'", NULL, FALSE);
- gplate_util_test_quoted_string_helper("'abc' def", NULL, FALSE);
- gplate_util_test_quoted_string_helper("'abc\"", NULL, FALSE);
- gplate_util_test_quoted_string_helper("\"abc'", NULL, FALSE);
-main(gint argc, gchar **argv) {
- g_test_init(&argc, &argv, NULL);
- g_test_add_func("/util/quoted_string", gplate_util_test_quoted_string);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/CMakeLists.txt Mon Sep 03 18:45:07 2012 -0500
@@ -0,0 +1,30 @@
+ add_executable(${target} ${target}.c) + target_link_libraries(${target} ${GLIB_LIBRARIES} gplate) + get_target_property(_output_name ${target} RUNTIME_OUTPUT_NAME) + get_target_property(_output_name ${target} LOCATION) + list(APPEND TESTS ${_output_name}) +add_gtest(test-gplate-collection-interface) +add_gtest(test-gplate-utility-functions) +add_gtest(test-gplate-for-function) +add_gtest(test-gplate-include-function) +add_gtest(test-gplate-comment-tag) +add_gtest(test-gplate-text-tag) +add_gtest(test-gplate-variable-tag) +add_gtest(test-variables) +set(GTESTER_TESTS "${TESTS}") +set(GTESTER_LOG "testgplate.log") +add_custom_target(tests ALL + COMMAND ${GTESTER} -k -verbose -o ${GTESTER_LOG} ${GTESTER_TESTS} + DEPENDS ${GTESTER_TESTS} --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/templates/footer.gplate Mon Sep 03 18:45:07 2012 -0500
@@ -0,0 +1,2 @@
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/templates/header.gplate Mon Sep 03 18:45:07 2012 -0500
@@ -0,0 +1,5 @@
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/templates/html.gplate Mon Sep 03 18:45:07 2012 -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/tests/templates/simple-include.gplate Mon Sep 03 18:45:07 2012 -0500
@@ -0,0 +1,1 @@
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/templates/simple.gplate Mon Sep 03 18:45:07 2012 -0500
@@ -0,0 +1,4 @@
+{% include "simple-include.gplate" %} --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-gplate-collection-interface.c Mon Sep 03 18:45:07 2012 -0500
@@ -0,0 +1,35 @@
+ * GPlate - GObject based templating library + * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com> + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This library 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 Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see <http://www.gnu.org/licenses/>. +#include <gplate/gplate.h> +/****************************************************************************** + *****************************************************************************/ +main(gint argc, gchar **argv) { + g_test_init(&argc, &argv, NULL); + gplate_config_load_default(); --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-gplate-comment-tag.c Mon Sep 03 18:45:07 2012 -0500
@@ -0,0 +1,82 @@
+ * GPlate - GObject based templating library + * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com> + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This library 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 Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see <http://www.gnu.org/licenses/>. +#include <gplate/gplate.h> +#include "test-gplate-tag.h" +/****************************************************************************** + *****************************************************************************/ +test_gplate_comment_tag_empty(TestGPlateTagFixture *fixture, + test_gplate_tag_output(fixture, data, "{##}", ""); +test_gplate_comment_tag_whitespace(TestGPlateTagFixture *fixture, + test_gplate_tag_output(fixture, data, "{# #}", ""); + test_gplate_tag_output(fixture, data, "{#\t#}", ""); + test_gplate_tag_output(fixture, data, "{#\n#}", ""); + test_gplate_tag_output(fixture, data, "{#\r#}", ""); + test_gplate_tag_output(fixture, data, "{#\r\n#}", ""); + test_gplate_tag_output(fixture, data, "{#\n\r#}", ""); +test_gplate_comment_tag_simple(TestGPlateTagFixture *fixture, + test_gplate_tag_output(fixture, data, "{# foo#}", ""); + test_gplate_tag_output(fixture, data, "{#foo #}", ""); + test_gplate_tag_output(fixture, data, "{#\tfoo#}", ""); + test_gplate_tag_output(fixture, data, "{#foo\t#}", ""); + test_gplate_tag_output(fixture, data, "{#\nfoo#}", ""); + test_gplate_tag_output(fixture, data, "{#foo\n#}", ""); + test_gplate_tag_output(fixture, data, "{#\rfoo#}", ""); + test_gplate_tag_output(fixture, data, "{#foo\r#}", ""); + test_gplate_tag_output(fixture, data, "{#\r\nfoo#}", ""); + test_gplate_tag_output(fixture, data, "{#foo\r\n#}", ""); +/****************************************************************************** + *****************************************************************************/ +main(gint argc, gchar **argv) { + g_test_init(&argc, &argv, NULL); + gplate_config_load_default(); + test_gplate_tag_add("/tags/comment/empty", + test_gplate_comment_tag_empty); + test_gplate_tag_add("/tags/comment/whitespace", + test_gplate_comment_tag_whitespace); + test_gplate_tag_add("/tags/comment/simple", + test_gplate_comment_tag_simple); --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-gplate-for-function.c Mon Sep 03 18:45:07 2012 -0500
@@ -0,0 +1,189 @@
+ * GPlate - GObject based templating library + * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com> + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This library 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 Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see <http://www.gnu.org/licenses/>. +#include <gplate/gplate.h> +#include <gplate/variables/gplate-dictionary-variable.h> +/****************************************************************************** + *****************************************************************************/ +} TestGPlateForFunctionData; + GPlateTemplate *template; + const gchar *template_string; + TestGPlateForFunctionData *data; +} TestGPlateForFunctionFixture; +/****************************************************************************** + *****************************************************************************/ +test_gplate_for_function_setup(TestGPlateForFunctionFixture *fixture, + fixture->template = gplate_template_new(); + fixture->dict = gplate_dictionary_variable_new("list"); + gplate_collection_add_variable(GPLATE_COLLECTION(fixture->template), +test_gplate_for_function_teardown(TestGPlateForFunctionFixture *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); +/****************************************************************************** + *****************************************************************************/ +test_gplate_for_function(TestGPlateForFunctionFixture *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); +/****************************************************************************** + *****************************************************************************/ +test_gplate_for_function_zero_elements(TestGPlateForFunctionFixture *fixture, + gconstpointer user_data) + TestGPlateForFunctionData data[] = { + fixture->template_string = "{% for in in line %}{{ i }}{% endfor %}"; + fixture->expected = ""; + test_gplate_for_function(fixture); +test_gplate_for_function_one_element(TestGPlateForFunctionFixture *fixture, + gconstpointer user_data) + TestGPlateForFunctionData data[] = { + fixture->template_string = "{% for i in list %}{{ i }}{% endfor %}"; + fixture->expected = "1"; + test_gplate_for_function(fixture); +test_gplate_for_function_two_elements(TestGPlateForFunctionFixture *fixture, + gconstpointer user_data) + TestGPlateForFunctionData data[] = { + fixture->template_string = "{% for i in list %}{{ i }}{% endfor %}"; + fixture->expected = "AB"; + test_gplate_for_function(fixture); +/****************************************************************************** + *****************************************************************************/ +main(gint argc, gchar **argv) { + g_test_init(&argc, &argv, NULL); + gplate_config_load_default(); + g_test_add("/functions/foo/zero_elements", + TestGPlateForFunctionFixture, + test_gplate_for_function_setup, + test_gplate_for_function_zero_elements, + test_gplate_for_function_teardown); + g_test_add("/functions/foo/one_element", + TestGPlateForFunctionFixture, + test_gplate_for_function_setup, + test_gplate_for_function_one_element, + test_gplate_for_function_teardown); + g_test_add("/functions/foo/two_elements", + TestGPlateForFunctionFixture, + test_gplate_for_function_setup, + test_gplate_for_function_two_elements, + test_gplate_for_function_teardown); --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-gplate-include-function.c Mon Sep 03 18:45:07 2012 -0500
@@ -0,0 +1,132 @@
+ * GPlate - GObject based templating library + * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com> + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This library 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 Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with this library. 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); --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-gplate-tag.c Mon Sep 03 18:45:07 2012 -0500
@@ -0,0 +1,56 @@
+ * GPlate - GObject based templating library + * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com> + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This library 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 Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see <http://www.gnu.org/licenses/>. +#include "test-gplate-tag.h" +test_gplate_tag_setup(TestGPlateTagFixture *fixture, gconstpointer data) { + fixture->template = gplate_template_new(); +test_gplate_tag_teardown(TestGPlateTagFixture *fixture, gconstpointer data) { + g_object_unref(fixture->template); + fixture->template = NULL; + g_error_free(fixture->error); + g_free(fixture->actual); + fixture->actual = NULL; +test_gplate_tag_output(TestGPlateTagFixture *fixture, + const gchar *template_string, + fixture->template_string = template_string; + fixture->expected = expected; + fixture->actual = gplate_template_render(fixture->template, + fixture->template_string, + g_assert(fixture->error == NULL); + g_assert_cmpstr(fixture->expected, ==, fixture->actual); --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-gplate-tag.h Mon Sep 03 18:45:07 2012 -0500
@@ -0,0 +1,51 @@
+ * GPlate - GObject based templating library + * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com> + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This library 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 Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see <http://www.gnu.org/licenses/>. +#ifndef TEST_GPLATE_TAG_H +#define TEST_GPLATE_TAG_H +#include <gplate/gplate.h> +#define test_gplate_tag_add(path, func) \ + g_test_add((path), TestGPlateTagFixture, NULL, test_gplate_tag_setup, (func), test_gplate_tag_teardown) +typedef struct _TestGPlateTagFixture TestGPlateTagFixture; +typedef void (*TestGPlateTagFixtureFunc)(TestGPlateTagFixture *fixture, gconstpointer data); +struct _TestGPlateTagFixture { + GPlateTemplate *template; + const gchar *template_string; +void test_gplate_tag_setup(TestGPlateTagFixture *fixture, gconstpointer data); +void test_gplate_tag_teardown(TestGPlateTagFixture *fixture, gconstpointer data); +void test_gplate_tag_output(TestGPlateTagFixture *fixture, gconstpointer data, const gchar *template_string, const gchar *expected); +#endif /* TEST_GPLATE_TAG_H */ --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-gplate-text-tag.c Mon Sep 03 18:45:07 2012 -0500
@@ -0,0 +1,73 @@
+ * GPlate - GObject based templating library + * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com> + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This library 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 Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see <http://www.gnu.org/licenses/>. +#include <gplate/gplate.h> +#include "test-gplate-tag.h" +/****************************************************************************** + *****************************************************************************/ +test_gplate_text_tag_syntax_plain(TestGPlateTagFixture *fixture, + test_gplate_tag_output(fixture, data, + "simple template", "simple template"); +test_gplate_text_tag_syntax_keywords(TestGPlateTagFixture *fixture, + test_gplate_tag_output(fixture, data, + "extends if else endif for endfor", + "extends if else endif for endfor"); +test_gplate_text_tag_syntax_keywords_case_sensitive(TestGPlateTagFixture *fixture, + test_gplate_tag_output(fixture, data, + "EXteNds iF eLse enDif fOr enDFor", + "EXteNds iF eLse enDif fOr enDFor"); +/****************************************************************************** + *****************************************************************************/ +main(gint argc, gchar **argv) { + g_test_init(&argc, &argv, NULL); + gplate_config_load_default(); + test_gplate_tag_add("/tags/text/plain", + test_gplate_text_tag_syntax_plain); + test_gplate_tag_add("/tags/text/keywords", + test_gplate_text_tag_syntax_keywords); + test_gplate_tag_add("/tags/text/keywords_case_sensitive", + test_gplate_text_tag_syntax_keywords_case_sensitive); --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-gplate-utility-functions.c Mon Sep 03 18:45:07 2012 -0500
@@ -0,0 +1,60 @@
+ * GPlate - GObject based templating library + * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com> + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This library 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 Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see <http://www.gnu.org/licenses/>. +#include <gplate/gplate.h> +gplate_util_test_quoted_string_helper(const gchar *string, + const gchar *contents, gboolean value) + r = gplate_util_is_quoted_string(string, &c); + g_assert_cmpint(r, ==, value); + g_assert_cmpstr(c, ==, contents); +gplate_util_test_quoted_string(void) { + gplate_util_test_quoted_string_helper("\"abc\"", "abc", TRUE); + gplate_util_test_quoted_string_helper("\"abc def\"", "abc def", TRUE); + gplate_util_test_quoted_string_helper("\"abc\tdef\bghi\"", "abc\tdef\bghi", TRUE); + gplate_util_test_quoted_string_helper("abc \"def\"", NULL, FALSE); + gplate_util_test_quoted_string_helper("\"abc\" def", NULL, FALSE); + gplate_util_test_quoted_string_helper("'abc'", "abc", TRUE); + gplate_util_test_quoted_string_helper("'abc def'", "abc def", TRUE); + gplate_util_test_quoted_string_helper("'abc\tdef\bghi'", "abc\tdef\bghi", TRUE); + gplate_util_test_quoted_string_helper("abc 'def'", NULL, FALSE); + gplate_util_test_quoted_string_helper("'abc' def", NULL, FALSE); + gplate_util_test_quoted_string_helper("'abc\"", NULL, FALSE); + gplate_util_test_quoted_string_helper("\"abc'", NULL, FALSE); +main(gint argc, gchar **argv) { + g_test_init(&argc, &argv, NULL); + g_test_add_func("/util/quoted_string", gplate_util_test_quoted_string); --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-gplate-variable-tag.c Mon Sep 03 18:45:07 2012 -0500
@@ -0,0 +1,237 @@
+ * GPlate - GObject based templating library + * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com> + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This library 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 Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see <http://www.gnu.org/licenses/>. +#include <gplate/gplate.h> +#include "test-gplate-tag.h" +/****************************************************************************** + *****************************************************************************/ +test_gplate_variable_tag(TestGPlateTagFixture *fixture, gconstpointer data, + const gchar *template_string, const gchar *expected, + const gchar *name = NULL, *value = NULL; + va_start(vargs, expected); + while((name = va_arg(vargs, const gchar *))) { + value = va_arg(vargs, const gchar *); + gplate_collection_add_string(GPLATE_COLLECTION(fixture->template), + test_gplate_tag_output(fixture, data, template_string, expected); +/****************************************************************************** + *****************************************************************************/ +test_gplate_variable_tag_single(TestGPlateTagFixture *fixture, + test_gplate_variable_tag(fixture, data, +test_gplate_variable_tag_double(TestGPlateTagFixture *fixture, + test_gplate_variable_tag(fixture, data, + "{{ foo }}{{ bar }}", "foobar", +test_gplate_variable_tag_tripple(TestGPlateTagFixture *fixture, + test_gplate_variable_tag(fixture, data, + "{{ foo }}{{ bar }}{{ baz }}", "foobarbaz", +test_gplate_variable_tag_newline_prefix(TestGPlateTagFixture *fixture, + test_gplate_variable_tag(fixture, data, +test_gplate_variable_tag_newline_suffix(TestGPlateTagFixture *fixture, + test_gplate_variable_tag(fixture, data, +test_gplate_variable_tag_newline_wrapped(TestGPlateTagFixture *fixture, + test_gplate_variable_tag(fixture, data, +test_gplate_variable_tag_single_quotes(TestGPlateTagFixture *fixture, + test_gplate_variable_tag(fixture, data, + "foo '{{ bar }}' baz", "foo 'bar' baz", +test_gplate_variable_tag_double_quotes(TestGPlateTagFixture *fixture, + test_gplate_variable_tag(fixture, data, + "foo \"{{ bar }}\" baz", "foo \"bar\" baz", +test_gplate_variable_tag_mixed_quotes(TestGPlateTagFixture *fixture, + test_gplate_variable_tag(fixture, data, + "foo \"{{ bar }}' baz", "foo \"bar' baz", + test_gplate_variable_tag(fixture, data, + "foo '{{ bar }}\" baz", "foo 'bar\" baz", +test_gplate_variable_tag_two_vars_one_block(TestGPlateTagFixture *fixture, + test_gplate_variable_tag(fixture, data, + "one {{ two five }} three", +test_gplate_variable_tag_nested_single(TestGPlateTagFixture *fixture, + GPlateVariable *dict = gplate_dictionary_variable_new("foo"); + gplate_collection_add_string(GPLATE_COLLECTION(dict), + test_gplate_tag_output(fixture, data, "{{ foo.bar }}", "baz"); +test_gplate_variable_tag_nested_double(TestGPlateTagFixture *fixture, + GPlateVariable *dict1 = gplate_dictionary_variable_new("foo"); + GPlateVariable *dict2 = gplate_dictionary_variable_new("bar"); + gplate_collection_add_variable(GPLATE_COLLECTION(fixture->template), + gplate_collection_add_variable(GPLATE_COLLECTION(dict1), dict2); + gplate_collection_add_string(GPLATE_COLLECTION(dict2), + test_gplate_tag_output(fixture, data, "{{ foo.bar.baz }}", "42"); +/****************************************************************************** + *****************************************************************************/ +main(gint argc, gchar **argv) { + g_test_init(&argc, &argv, NULL); + gplate_config_load_default(); + test_gplate_tag_add("/tags/variable/single", + test_gplate_variable_tag_single); + test_gplate_tag_add("/tags/variable/double", + test_gplate_variable_tag_double); + test_gplate_tag_add("/tags/variable/tripple", + test_gplate_variable_tag_tripple); + test_gplate_tag_add("/tags/variable/newline_prefix", + test_gplate_variable_tag_newline_prefix); + test_gplate_tag_add("/tags/variable/newline_suffix", + test_gplate_variable_tag_newline_suffix); + test_gplate_tag_add("/tags/variable/newline_wrapped", + test_gplate_variable_tag_newline_wrapped); + test_gplate_tag_add("/tags/variable/quotes/single", + test_gplate_variable_tag_single_quotes); + test_gplate_tag_add("/tags/variable/quotes/double", + test_gplate_variable_tag_double_quotes); + test_gplate_tag_add("/tags/variable/quotes/mixed", + test_gplate_variable_tag_mixed_quotes); + test_gplate_tag_add("/tags/variable/two_vars_one_block", + test_gplate_variable_tag_two_vars_one_block); + test_gplate_tag_add("/tags/variables/nested/single", + test_gplate_variable_tag_nested_single); + test_gplate_tag_add("/tags/variable/nested/double", + test_gplate_variable_tag_nested_double);