grim/gplate

Added the tests for comment tags

2010-07-04, Gary Kramlich
2771744219bd
Parents 2a257237a0ef
Children d2679801cf3a
Added the tests for comment tags
--- a/gplate/tags/tests/CMakeLists.txt Sun Jul 04 02:02:59 2010 -0500
+++ b/gplate/tags/tests/CMakeLists.txt Sun Jul 04 02:53:53 2010 -0500
@@ -9,10 +9,18 @@
# add the text tag tests
add_executable(test-text-tag gplate-text-tag-test.c)
target_link_libraries(test-text-tag gplate-tag-test)
-add_test(GPlateTextTag test-text-tag)
+list(APPEND TAG_TESTS test-text-tag)
# add the variable tag tests
add_executable(test-variable-tag gplate-variable-tag-test.c)
target_link_libraries(test-variable-tag gplate-tag-test)
-add_test(GPlateVariableTag test-variable-tag)
+list(APPEND TAG_TESTS test-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 the tests for gtester
+add_test(GPlateTagTests ${GTESTER} -k --verbose ${TAG_TESTS})
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/tags/tests/gplate-comment-tag-test.c Sun Jul 04 02:53:53 2010 -0500
@@ -0,0 +1,65 @@
+#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();
+}
+