grim/gplate

0938cb5d076b
Parents 6042cc7c5374
Children 6611e9570ec2
the start of the test name standardization

refs #15
--- a/.hgignore Sun Jul 04 02:58:33 2010 -0500
+++ b/.hgignore Sun Jul 04 03:34:39 2010 -0500
@@ -25,6 +25,4 @@
^tests/results.html$
^tests/html/results.html$
^tests/test-(util|variables)$
-tests/test-([a-zA-Z0-9-]+)(\.exe)?$
-tests/([a-zA-Z0-9-]+)-test(\.exe)?$
-tests/([a-zA-Z0-9-]+)\.log$
+tests/test-([a-zA-Z0-9-]+)(\.exe|\.log)?$
--- a/gplate/tags/tests/CMakeLists.txt Sun Jul 04 02:58:33 2010 -0500
+++ b/gplate/tags/tests/CMakeLists.txt Sun Jul 04 03:34:39 2010 -0500
@@ -1,26 +1,29 @@
enable_testing()
# define the static library for tag testing
-add_library(gplate-tag-test STATIC
- gplate-tag-test.c
+add_library(test-gplate-tag STATIC
+ test-gplate-tag.c
)
-target_link_libraries(gplate-tag-test gplate)
+target_link_libraries(test-gplate-tag gplate)
# add the text tag tests
-add_executable(gplate-text-tag-test gplate-text-tag-test.c)
-target_link_libraries(gplate-text-tag-test gplate-tag-test)
-list(APPEND TAG_TESTS gplate-text-tag-test)
+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(gplate-variable-tag-test gplate-variable-tag-test.c)
-target_link_libraries(gplate-variable-tag-test gplate-tag-test)
-list(APPEND TAG_TESTS gplate-variable-tag-test)
+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(gplate-comment-tag-test gplate-comment-tag-test.c)
-target_link_libraries(gplate-comment-tag-test gplate-tag-test)
-list(APPEND TAG_TESTS gplate-comment-tag-test)
+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
-add_test(GPlateTagTests ${GTESTER} -k --verbose -o gplate-tag-test.log ${TAG_TESTS})
+add_test(GPlateTagTests
+ ${GTESTER} -k --verbose -o test-gplate-tag.log
+ ${TAG_TESTS}
+)
--- a/gplate/tags/tests/gplate-comment-tag-test.c Sun Jul 04 02:58:33 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-#include <gplate/gplate.h>
-
-#include <glib.h>
-
-#include "gplate-tag-test.h"
-
-/******************************************************************************
- * Tests
- *****************************************************************************/
-static void
-gplate_comment_tag_test_empty(GPlateTagTestFixture *fixture,
- gconstpointer data)
-{
- gplate_tag_test_output(fixture, data, "{##}", "");
-}
-
-static void
-gplate_comment_tag_test_whitespace(GPlateTagTestFixture *fixture,
- gconstpointer data)
-{
- gplate_tag_test_output(fixture, data, "{# #}", "");
- gplate_tag_test_output(fixture, data, "{#\t#}", "");
- gplate_tag_test_output(fixture, data, "{#\n#}", "");
- gplate_tag_test_output(fixture, data, "{#\r#}", "");
- gplate_tag_test_output(fixture, data, "{#\r\n#}", "");
- gplate_tag_test_output(fixture, data, "{#\n\r#}", "");
-}
-
-static void
-gplate_comment_tag_test_simple(GPlateTagTestFixture *fixture,
- gconstpointer data)
-{
- gplate_tag_test_output(fixture, data, "{# foo#}", "");
- gplate_tag_test_output(fixture, data, "{#foo #}", "");
- gplate_tag_test_output(fixture, data, "{#\tfoo#}", "");
- gplate_tag_test_output(fixture, data, "{#foo\t#}", "");
- gplate_tag_test_output(fixture, data, "{#\nfoo#}", "");
- gplate_tag_test_output(fixture, data, "{#foo\n#}", "");
- gplate_tag_test_output(fixture, data, "{#\rfoo#}", "");
- gplate_tag_test_output(fixture, data, "{#foo\r#}", "");
- gplate_tag_test_output(fixture, data, "{#\r\nfoo#}", "");
- gplate_tag_test_output(fixture, data, "{#foo\r\n#}", "");
-}
-
-/******************************************************************************
- * Main
- *****************************************************************************/
-gint
-main(gint argc, gchar **argv) {
- g_test_init(&argc, &argv, NULL);
-
- g_type_init();
-
- gplate_config_load_default();
-
- gplate_tag_test_add("/tags/comment/empty",
- gplate_comment_tag_test_empty);
- gplate_tag_test_add("/tags/comment/whitespace",
- gplate_comment_tag_test_whitespace);
- gplate_tag_test_add("/tags/comment/simple",
- gplate_comment_tag_test_simple);
-
- return g_test_run();
-}
-
--- a/gplate/tags/tests/gplate-tag-test.c Sun Jul 04 02:58:33 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +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-tag-test.h"
-
-void
-gplate_tag_test_setup(GPlateTagTestFixture *fixture, gconstpointer data) {
- fixture->template = gplate_template_new();
-}
-
-void
-gplate_tag_test_teardown(GPlateTagTestFixture *fixture, gconstpointer data) {
- g_object_unref(fixture->template);
- fixture->template = NULL;
-
- if(fixture->error) {
- g_error_free(fixture->error);
- fixture->error = NULL;
- }
-
- g_free(fixture->actual);
- fixture->actual = NULL;
-}
-
-void
-gplate_tag_test_output(GPlateTagTestFixture *fixture,
- gconstpointer data,
- const gchar *template_string,
- const gchar *expected)
-{
- fixture->template_string = template_string;
- fixture->expected = expected;
-
- fixture->actual = gplate_template_render(fixture->template,
- fixture->template_string,
- &fixture->error);
-
- g_assert(fixture->error == NULL);
-
- g_assert_cmpstr(fixture->expected, ==, fixture->actual);
-}
-
--- a/gplate/tags/tests/gplate-tag-test.h Sun Jul 04 02:58:33 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +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/>.
- */
-#ifndef GPLATE_TAG_TEST_H
-#define GPLATE_TAG_TEST_H
-
-#include <gplate/gplate.h>
-
-#include <glib.h>
-
-#define gplate_tag_test_add(path, func) \
- g_test_add((path), GPlateTagTestFixture, NULL, gplate_tag_test_setup, (func), gplate_tag_test_teardown)
-
-typedef struct _GPlateTagTestFixture GPlateTagTestFixture;
-
-typedef void (*GPlateTagTestFixtureFunc)(GPlateTagTestFixture *fixture, gconstpointer data);
-
-struct _GPlateTagTestFixture {
- GPlateTemplate *template;
- GError *error;
-
- const gchar *template_string;
-
- const gchar *expected;
- gchar *actual;
-};
-
-G_BEGIN_DECLS
-
-void gplate_tag_test_setup(GPlateTagTestFixture *fixture, gconstpointer data);
-void gplate_tag_test_teardown(GPlateTagTestFixture *fixture, gconstpointer data);
-void gplate_tag_test_output(GPlateTagTestFixture *fixture, gconstpointer data, const gchar *template_string, const gchar *expected);
-
-G_END_DECLS
-
-#endif /* GPLATE_TAG_TEST_H */
--- a/gplate/tags/tests/gplate-text-tag-test.c Sun Jul 04 02:58:33 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +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 <glib.h>
-
-#include "gplate-tag-test.h"
-
-/******************************************************************************
- * Tests
- *****************************************************************************/
-static void
-gplate_text_tag_test_syntax_plain(GPlateTagTestFixture *fixture,
- gconstpointer data)
-{
- gplate_tag_test_output(fixture, data,
- "simple template", "simple template");
-}
-
-static void
-gplate_text_tag_test_syntax_keywords(GPlateTagTestFixture *fixture,
- gconstpointer data)
-{
- gplate_tag_test_output(fixture, data,
- "extends if else endif for endfor",
- "extends if else endif for endfor");
-}
-
-static void
-gplate_text_tag_test_syntax_keywords_case_sensitive(GPlateTagTestFixture *fixture,
- gconstpointer data)
-{
- gplate_tag_test_output(fixture, data,
- "EXteNds iF eLse enDif fOr enDFor",
- "EXteNds iF eLse enDif fOr enDFor");
-}
-
-/******************************************************************************
- * Main
- *****************************************************************************/
-gint
-main(gint argc, gchar **argv) {
- g_test_init(&argc, &argv, NULL);
-
- g_type_init();
-
- gplate_config_load_default();
-
- gplate_tag_test_add("/tags/text/plain",
- gplate_text_tag_test_syntax_plain);
- gplate_tag_test_add("/tags/text/keywords",
- gplate_text_tag_test_syntax_keywords);
- gplate_tag_test_add("/tags/text/keywords_case_sensitive",
- gplate_text_tag_test_syntax_keywords_case_sensitive);
-
- return g_test_run();
-}
-
--- a/gplate/tags/tests/gplate-variable-tag-test.c Sun Jul 04 02:58:33 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,186 +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 <glib.h>
-
-#include "gplate-tag-test.h"
-
-/******************************************************************************
- * Helpers
- *****************************************************************************/
-static void
-gplate_variable_tag_test(GPlateTagTestFixture *fixture, gconstpointer data,
- const gchar *template_string, const gchar *expected,
- ...)
-{
- va_list vargs;
- 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),
- name, value);
- }
- va_end(vargs);
-
- gplate_tag_test_output(fixture, data, template_string, expected);
-}
-
-/******************************************************************************
- * Tests
- *****************************************************************************/
-static void
-gplate_variable_tag_test_single(GPlateTagTestFixture *fixture,
- gconstpointer data)
-{
- gplate_variable_tag_test(fixture, data,
- "{{ foo }}", "foo",
- "foo", "foo",
- NULL);
-}
-
-static void
-gplate_variable_tag_test_double(GPlateTagTestFixture *fixture,
- gconstpointer data)
-{
- gplate_variable_tag_test(fixture, data,
- "{{ foo }}{{ bar }}", "foobar",
- "foo", "foo",
- "bar", "bar",
- NULL);
-}
-
-static void
-gplate_variable_tag_test_tripple(GPlateTagTestFixture *fixture,
- gconstpointer data)
-{
- gplate_variable_tag_test(fixture, data,
- "{{ foo }}{{ bar }}{{ baz }}", "foobarbaz",
- "foo", "foo",
- "bar", "bar",
- "baz", "baz",
- NULL);
-}
-
-static void
-gplate_variable_tag_test_newline_prefix(GPlateTagTestFixture *fixture,
- gconstpointer data)
-{
- gplate_variable_tag_test(fixture, data,
- "{{\nfoo}}", "foo",
- "foo", "foo",
- NULL);
-}
-
-static void
-gplate_variable_tag_test_newline_suffix(GPlateTagTestFixture *fixture,
- gconstpointer data)
-{
- gplate_variable_tag_test(fixture, data,
- "{{foo\n}}", "foo",
- "foo", "foo",
- NULL);
-}
-
-static void
-gplate_variable_tag_test_newline_wrapped(GPlateTagTestFixture *fixture,
- gconstpointer data)
-{
- gplate_variable_tag_test(fixture, data,
- "{{\nfoo\n}}", "foo",
- "foo", "foo",
- NULL);
-}
-
-static void
-gplate_variable_tag_test_single_quotes(GPlateTagTestFixture *fixture,
- gconstpointer data)
-{
- gplate_variable_tag_test(fixture, data,
- "foo '{{ bar }}' baz", "foo 'bar' baz",
- "bar", "bar",
- NULL);
-}
-
-static void
-gplate_variable_tag_test_double_quotes(GPlateTagTestFixture *fixture,
- gconstpointer data)
-{
- gplate_variable_tag_test(fixture, data,
- "foo \"{{ bar }}\" baz", "foo \"bar\" baz",
- "bar", "bar",
- NULL);
-}
-
-static void
-gplate_variable_tag_test_mixed_quotes(GPlateTagTestFixture *fixture,
- gconstpointer data)
-{
- gplate_variable_tag_test(fixture, data,
- "foo \"{{ bar }}' baz", "foo \"bar' baz",
- "bar", "bar",
- NULL);
-
- gplate_variable_tag_test(fixture, data,
- "foo '{{ bar }}\" baz", "foo 'bar\" baz",
- "bar", "bar",
- NULL);
-}
-/******************************************************************************
- * Main
- *****************************************************************************/
-gint
-main(gint argc, gchar **argv) {
- g_test_init(&argc, &argv, NULL);
-
- g_type_init();
-
- gplate_config_load_default();
-
- gplate_tag_test_add("/tags/variable/single",
- gplate_variable_tag_test_single);
-
- gplate_tag_test_add("/tags/variable/double",
- gplate_variable_tag_test_double);
-
- gplate_tag_test_add("/tags/variable/tripple",
- gplate_variable_tag_test_tripple);
-
- gplate_tag_test_add("/tags/variable/newline_prefix",
- gplate_variable_tag_test_newline_prefix);
-
- gplate_tag_test_add("/tags/variable/newline_suffix",
- gplate_variable_tag_test_newline_suffix);
-
- gplate_tag_test_add("/tags/variable/newline_wrapped",
- gplate_variable_tag_test_newline_wrapped);
-
- gplate_tag_test_add("/tags/variable/quotes/single",
- gplate_variable_tag_test_single_quotes);
-
- gplate_tag_test_add("/tags/variable/quotes/double",
- gplate_variable_tag_test_double_quotes);
-
- gplate_tag_test_add("/tags/variable/quotes/mixed",
- gplate_variable_tag_test_mixed_quotes);
-
- return g_test_run();
-}
-
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/tags/tests/test-gplate-comment-tag.c Sun Jul 04 03:34:39 2010 -0500
@@ -0,0 +1,81 @@
+/*
+ * 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 <glib.h>
+
+#include "test-gplate-tag.h"
+
+/******************************************************************************
+ * Tests
+ *****************************************************************************/
+static void
+test_gplate_comment_tag_empty(TestGPlateTagFixture *fixture,
+ gconstpointer data)
+{
+ test_gplate_tag_output(fixture, data, "{##}", "");
+}
+
+static void
+test_gplate_comment_tag_whitespace(TestGPlateTagFixture *fixture,
+ gconstpointer data)
+{
+ 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#}", "");
+}
+
+static void
+test_gplate_comment_tag_simple(TestGPlateTagFixture *fixture,
+ gconstpointer data)
+{
+ 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
+main(gint argc, gchar **argv) {
+ g_test_init(&argc, &argv, NULL);
+
+ g_type_init();
+
+ 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);
+
+ return g_test_run();
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/tags/tests/test-gplate-tag.c Sun Jul 04 03:34:39 2010 -0500
@@ -0,0 +1,55 @@
+/*
+ * 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 "test-gplate-tag.h"
+
+void
+test_gplate_tag_setup(TestGPlateTagFixture *fixture, gconstpointer data) {
+ fixture->template = gplate_template_new();
+}
+
+void
+test_gplate_tag_teardown(TestGPlateTagFixture *fixture, gconstpointer data) {
+ g_object_unref(fixture->template);
+ fixture->template = NULL;
+
+ if(fixture->error) {
+ g_error_free(fixture->error);
+ fixture->error = NULL;
+ }
+
+ g_free(fixture->actual);
+ fixture->actual = NULL;
+}
+
+void
+test_gplate_tag_output(TestGPlateTagFixture *fixture,
+ gconstpointer data,
+ const gchar *template_string,
+ const gchar *expected)
+{
+ fixture->template_string = template_string;
+ fixture->expected = expected;
+
+ fixture->actual = gplate_template_render(fixture->template,
+ fixture->template_string,
+ &fixture->error);
+
+ g_assert(fixture->error == NULL);
+
+ g_assert_cmpstr(fixture->expected, ==, fixture->actual);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/tags/tests/test-gplate-tag.h Sun Jul 04 03:34:39 2010 -0500
@@ -0,0 +1,50 @@
+/*
+ * 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/>.
+ */
+#ifndef TEST_GPLATE_TAG_H
+#define TEST_GPLATE_TAG_H
+
+#include <gplate/gplate.h>
+
+#include <glib.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;
+ GError *error;
+
+ const gchar *template_string;
+
+ const gchar *expected;
+ gchar *actual;
+};
+
+G_BEGIN_DECLS
+
+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);
+
+G_END_DECLS
+
+#endif /* TEST_GPLATE_TAG_H */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/tags/tests/test-gplate-text-tag.c Sun Jul 04 03:34:39 2010 -0500
@@ -0,0 +1,72 @@
+/*
+ * 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 <glib.h>
+
+#include "test-gplate-tag.h"
+
+/******************************************************************************
+ * Tests
+ *****************************************************************************/
+static void
+test_gplate_text_tag_syntax_plain(TestGPlateTagFixture *fixture,
+ gconstpointer data)
+{
+ test_gplate_tag_output(fixture, data,
+ "simple template", "simple template");
+}
+
+static void
+test_gplate_text_tag_syntax_keywords(TestGPlateTagFixture *fixture,
+ gconstpointer data)
+{
+ test_gplate_tag_output(fixture, data,
+ "extends if else endif for endfor",
+ "extends if else endif for endfor");
+}
+
+static void
+test_gplate_text_tag_syntax_keywords_case_sensitive(TestGPlateTagFixture *fixture,
+ gconstpointer data)
+{
+ test_gplate_tag_output(fixture, data,
+ "EXteNds iF eLse enDif fOr enDFor",
+ "EXteNds iF eLse enDif fOr enDFor");
+}
+
+/******************************************************************************
+ * Main
+ *****************************************************************************/
+gint
+main(gint argc, gchar **argv) {
+ g_test_init(&argc, &argv, NULL);
+
+ g_type_init();
+
+ 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);
+
+ return g_test_run();
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/tags/tests/test-gplate-variable-tag.c Sun Jul 04 03:34:39 2010 -0500
@@ -0,0 +1,186 @@
+/*
+ * 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 <glib.h>
+
+#include "test-gplate-tag.h"
+
+/******************************************************************************
+ * Helpers
+ *****************************************************************************/
+static void
+test_gplate_variable_tag(TestGPlateTagFixture *fixture, gconstpointer data,
+ const gchar *template_string, const gchar *expected,
+ ...)
+{
+ va_list vargs;
+ 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),
+ name, value);
+ }
+ va_end(vargs);
+
+ test_gplate_tag_output(fixture, data, template_string, expected);
+}
+
+/******************************************************************************
+ * Tests
+ *****************************************************************************/
+static void
+test_gplate_variable_tag_single(TestGPlateTagFixture *fixture,
+ gconstpointer data)
+{
+ test_gplate_variable_tag(fixture, data,
+ "{{ foo }}", "foo",
+ "foo", "foo",
+ NULL);
+}
+
+static void
+test_gplate_variable_tag_double(TestGPlateTagFixture *fixture,
+ gconstpointer data)
+{
+ test_gplate_variable_tag(fixture, data,
+ "{{ foo }}{{ bar }}", "foobar",
+ "foo", "foo",
+ "bar", "bar",
+ NULL);
+}
+
+static void
+test_gplate_variable_tag_tripple(TestGPlateTagFixture *fixture,
+ gconstpointer data)
+{
+ test_gplate_variable_tag(fixture, data,
+ "{{ foo }}{{ bar }}{{ baz }}", "foobarbaz",
+ "foo", "foo",
+ "bar", "bar",
+ "baz", "baz",
+ NULL);
+}
+
+static void
+test_gplate_variable_tag_newline_prefix(TestGPlateTagFixture *fixture,
+ gconstpointer data)
+{
+ test_gplate_variable_tag(fixture, data,
+ "{{\nfoo}}", "foo",
+ "foo", "foo",
+ NULL);
+}
+
+static void
+test_gplate_variable_tag_newline_suffix(TestGPlateTagFixture *fixture,
+ gconstpointer data)
+{
+ test_gplate_variable_tag(fixture, data,
+ "{{foo\n}}", "foo",
+ "foo", "foo",
+ NULL);
+}
+
+static void
+test_gplate_variable_tag_newline_wrapped(TestGPlateTagFixture *fixture,
+ gconstpointer data)
+{
+ test_gplate_variable_tag(fixture, data,
+ "{{\nfoo\n}}", "foo",
+ "foo", "foo",
+ NULL);
+}
+
+static void
+test_gplate_variable_tag_single_quotes(TestGPlateTagFixture *fixture,
+ gconstpointer data)
+{
+ test_gplate_variable_tag(fixture, data,
+ "foo '{{ bar }}' baz", "foo 'bar' baz",
+ "bar", "bar",
+ NULL);
+}
+
+static void
+test_gplate_variable_tag_double_quotes(TestGPlateTagFixture *fixture,
+ gconstpointer data)
+{
+ test_gplate_variable_tag(fixture, data,
+ "foo \"{{ bar }}\" baz", "foo \"bar\" baz",
+ "bar", "bar",
+ NULL);
+}
+
+static void
+test_gplate_variable_tag_mixed_quotes(TestGPlateTagFixture *fixture,
+ gconstpointer data)
+{
+ test_gplate_variable_tag(fixture, data,
+ "foo \"{{ bar }}' baz", "foo \"bar' baz",
+ "bar", "bar",
+ NULL);
+
+ test_gplate_variable_tag(fixture, data,
+ "foo '{{ bar }}\" baz", "foo 'bar\" baz",
+ "bar", "bar",
+ NULL);
+}
+/******************************************************************************
+ * Main
+ *****************************************************************************/
+gint
+main(gint argc, gchar **argv) {
+ g_test_init(&argc, &argv, NULL);
+
+ g_type_init();
+
+ 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);
+
+ return g_test_run();
+}
+
--- a/gplate/tests/CMakeLists.txt Sun Jul 04 02:58:33 2010 -0500
+++ b/gplate/tests/CMakeLists.txt Sun Jul 04 03:34:39 2010 -0500
@@ -1,10 +1,22 @@
enable_testing()
-add_executable(test-collection-interface test-collection-interface.c)
-target_link_libraries(test-collection-interface gplate)
-add_test(GPlateCollectionInterface test-collection-interface)
+###############################################################################
+# collection tests
+###############################################################################
+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-util-functions test-util-functions.c)
-target_link_libraries(test-util-functions gplate)
-add_test(GPlateUtilityFunctions test-util-functions)
+###############################################################################
+# utility tests
+###############################################################################
+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-collection-interface.c Sun Jul 04 02:58:33 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +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 <glib.h>
-
-/******************************************************************************
- * Main
- *****************************************************************************/
-gint
-main(gint argc, gchar **argv) {
- g_test_init(&argc, &argv, NULL);
-
- g_type_init();
-
- gplate_config_load_default();
-
- return g_test_run();
-}
-
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/tests/test-gplate-collection-interface.c Sun Jul 04 03:34:39 2010 -0500
@@ -0,0 +1,34 @@
+/*
+ * 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 <glib.h>
+
+/******************************************************************************
+ * Main
+ *****************************************************************************/
+gint
+main(gint argc, gchar **argv) {
+ g_test_init(&argc, &argv, NULL);
+
+ g_type_init();
+
+ gplate_config_load_default();
+
+ return g_test_run();
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/tests/test-gplate-utility-functions.c Sun Jul 04 03:34:39 2010 -0500
@@ -0,0 +1,58 @@
+/*
+ * 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>
+
+static void
+gplate_util_test_quoted_string_helper(const gchar *string,
+ const gchar *contents, gboolean value)
+{
+ gboolean r = FALSE;
+ gchar *c = NULL;
+
+ r = gplate_util_is_quoted_string(string, &c);
+ g_assert_cmpint(r, ==, value);
+
+ if(contents)
+ g_assert_cmpstr(c, ==, contents);
+
+ g_free(c);
+}
+
+static void
+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);
+}
+
+gint
+main(gint argc, gchar **argv) {
+ g_test_init(&argc, &argv, NULL);
+
+ g_test_add_func("/util/quoted_string", gplate_util_test_quoted_string);
+
+ return g_test_run();
+}
+
--- a/gplate/tests/test-util-functions.c Sun Jul 04 02:58:33 2010 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +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>
-
-static void
-gplate_util_test_quoted_string_helper(const gchar *string,
- const gchar *contents, gboolean value)
-{
- gboolean r = FALSE;
- gchar *c = NULL;
-
- r = gplate_util_is_quoted_string(string, &c);
- g_assert_cmpint(r, ==, value);
-
- if(contents)
- g_assert_cmpstr(c, ==, contents);
-
- g_free(c);
-}
-
-static void
-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);
-}
-
-gint
-main(gint argc, gchar **argv) {
- g_test_init(&argc, &argv, NULL);
-
- g_test_add_func("/util/quoted_string", gplate_util_test_quoted_string);
-
- return g_test_run();
-}
-