1.1 --- a/.hgignore Sun Jul 04 02:58:33 2010 -0500
1.2 +++ b/.hgignore Sun Jul 04 03:34:39 2010 -0500
1.3 @@ -25,6 +25,4 @@
1.4 ^tests/results.html$
1.5 ^tests/html/results.html$
1.6 ^tests/test-(util|variables)$
1.7 -tests/test-([a-zA-Z0-9-]+)(\.exe)?$
1.8 -tests/([a-zA-Z0-9-]+)-test(\.exe)?$
1.9 -tests/([a-zA-Z0-9-]+)\.log$
1.10 +tests/test-([a-zA-Z0-9-]+)(\.exe|\.log)?$
2.1 --- a/gplate/tags/tests/CMakeLists.txt Sun Jul 04 02:58:33 2010 -0500
2.2 +++ b/gplate/tags/tests/CMakeLists.txt Sun Jul 04 03:34:39 2010 -0500
2.3 @@ -1,26 +1,29 @@
2.4 enable_testing()
2.5
2.6 # define the static library for tag testing
2.7 -add_library(gplate-tag-test STATIC
2.8 - gplate-tag-test.c
2.9 +add_library(test-gplate-tag STATIC
2.10 + test-gplate-tag.c
2.11 )
2.12 -target_link_libraries(gplate-tag-test gplate)
2.13 +target_link_libraries(test-gplate-tag gplate)
2.14
2.15 # add the text tag tests
2.16 -add_executable(gplate-text-tag-test gplate-text-tag-test.c)
2.17 -target_link_libraries(gplate-text-tag-test gplate-tag-test)
2.18 -list(APPEND TAG_TESTS gplate-text-tag-test)
2.19 +add_executable(test-gplate-text-tag test-gplate-text-tag.c)
2.20 +target_link_libraries(test-gplate-text-tag test-gplate-tag)
2.21 +list(APPEND TAG_TESTS test-gplate-text-tag)
2.22
2.23 # add the variable tag tests
2.24 -add_executable(gplate-variable-tag-test gplate-variable-tag-test.c)
2.25 -target_link_libraries(gplate-variable-tag-test gplate-tag-test)
2.26 -list(APPEND TAG_TESTS gplate-variable-tag-test)
2.27 +add_executable(test-gplate-variable-tag test-gplate-variable-tag.c)
2.28 +target_link_libraries(test-gplate-variable-tag test-gplate-tag)
2.29 +list(APPEND TAG_TESTS test-gplate-variable-tag)
2.30
2.31 # add the comment tag tests
2.32 -add_executable(gplate-comment-tag-test gplate-comment-tag-test.c)
2.33 -target_link_libraries(gplate-comment-tag-test gplate-tag-test)
2.34 -list(APPEND TAG_TESTS gplate-comment-tag-test)
2.35 +add_executable(test-gplate-comment-tag test-gplate-comment-tag.c)
2.36 +target_link_libraries(test-gplate-comment-tag test-gplate-tag)
2.37 +list(APPEND TAG_TESTS test-gplate-comment-tag)
2.38
2.39 # add the tests for gtester
2.40 -add_test(GPlateTagTests ${GTESTER} -k --verbose -o gplate-tag-test.log ${TAG_TESTS})
2.41 +add_test(GPlateTagTests
2.42 + ${GTESTER} -k --verbose -o test-gplate-tag.log
2.43 + ${TAG_TESTS}
2.44 +)
2.45
3.1 --- a/gplate/tags/tests/gplate-comment-tag-test.c Sun Jul 04 02:58:33 2010 -0500
3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
3.3 @@ -1,65 +0,0 @@
3.4 -#include <gplate/gplate.h>
3.5 -
3.6 -#include <glib.h>
3.7 -
3.8 -#include "gplate-tag-test.h"
3.9 -
3.10 -/******************************************************************************
3.11 - * Tests
3.12 - *****************************************************************************/
3.13 -static void
3.14 -gplate_comment_tag_test_empty(GPlateTagTestFixture *fixture,
3.15 - gconstpointer data)
3.16 -{
3.17 - gplate_tag_test_output(fixture, data, "{##}", "");
3.18 -}
3.19 -
3.20 -static void
3.21 -gplate_comment_tag_test_whitespace(GPlateTagTestFixture *fixture,
3.22 - gconstpointer data)
3.23 -{
3.24 - gplate_tag_test_output(fixture, data, "{# #}", "");
3.25 - gplate_tag_test_output(fixture, data, "{#\t#}", "");
3.26 - gplate_tag_test_output(fixture, data, "{#\n#}", "");
3.27 - gplate_tag_test_output(fixture, data, "{#\r#}", "");
3.28 - gplate_tag_test_output(fixture, data, "{#\r\n#}", "");
3.29 - gplate_tag_test_output(fixture, data, "{#\n\r#}", "");
3.30 -}
3.31 -
3.32 -static void
3.33 -gplate_comment_tag_test_simple(GPlateTagTestFixture *fixture,
3.34 - gconstpointer data)
3.35 -{
3.36 - gplate_tag_test_output(fixture, data, "{# foo#}", "");
3.37 - gplate_tag_test_output(fixture, data, "{#foo #}", "");
3.38 - gplate_tag_test_output(fixture, data, "{#\tfoo#}", "");
3.39 - gplate_tag_test_output(fixture, data, "{#foo\t#}", "");
3.40 - gplate_tag_test_output(fixture, data, "{#\nfoo#}", "");
3.41 - gplate_tag_test_output(fixture, data, "{#foo\n#}", "");
3.42 - gplate_tag_test_output(fixture, data, "{#\rfoo#}", "");
3.43 - gplate_tag_test_output(fixture, data, "{#foo\r#}", "");
3.44 - gplate_tag_test_output(fixture, data, "{#\r\nfoo#}", "");
3.45 - gplate_tag_test_output(fixture, data, "{#foo\r\n#}", "");
3.46 -}
3.47 -
3.48 -/******************************************************************************
3.49 - * Main
3.50 - *****************************************************************************/
3.51 -gint
3.52 -main(gint argc, gchar **argv) {
3.53 - g_test_init(&argc, &argv, NULL);
3.54 -
3.55 - g_type_init();
3.56 -
3.57 - gplate_config_load_default();
3.58 -
3.59 - gplate_tag_test_add("/tags/comment/empty",
3.60 - gplate_comment_tag_test_empty);
3.61 - gplate_tag_test_add("/tags/comment/whitespace",
3.62 - gplate_comment_tag_test_whitespace);
3.63 - gplate_tag_test_add("/tags/comment/simple",
3.64 - gplate_comment_tag_test_simple);
3.65 -
3.66 - return g_test_run();
3.67 -}
3.68 -
4.1 --- a/gplate/tags/tests/gplate-tag-test.c Sun Jul 04 02:58:33 2010 -0500
4.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
4.3 @@ -1,55 +0,0 @@
4.4 -/*
4.5 - * Copyright (C) 2007-2010 Gary Kramlich <grim@reaperworld.com>
4.6 - *
4.7 - * This program is free software: you can redistribute it and/or modify
4.8 - * it under the terms of the GNU General Public License as published by
4.9 - * the Free Software Foundation, either version 3 of the License, or
4.10 - * (at your option) any later version.
4.11 - *
4.12 - * This program is distributed in the hope that it will be useful,
4.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
4.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4.15 - * GNU General Public License for more details.
4.16 - *
4.17 - * You should have received a copy of the GNU General Public License
4.18 - * along with this program. If not, see <http://www.gnu.org/licenses/>.
4.19 - */
4.20 -#include "gplate-tag-test.h"
4.21 -
4.22 -void
4.23 -gplate_tag_test_setup(GPlateTagTestFixture *fixture, gconstpointer data) {
4.24 - fixture->template = gplate_template_new();
4.25 -}
4.26 -
4.27 -void
4.28 -gplate_tag_test_teardown(GPlateTagTestFixture *fixture, gconstpointer data) {
4.29 - g_object_unref(fixture->template);
4.30 - fixture->template = NULL;
4.31 -
4.32 - if(fixture->error) {
4.33 - g_error_free(fixture->error);
4.34 - fixture->error = NULL;
4.35 - }
4.36 -
4.37 - g_free(fixture->actual);
4.38 - fixture->actual = NULL;
4.39 -}
4.40 -
4.41 -void
4.42 -gplate_tag_test_output(GPlateTagTestFixture *fixture,
4.43 - gconstpointer data,
4.44 - const gchar *template_string,
4.45 - const gchar *expected)
4.46 -{
4.47 - fixture->template_string = template_string;
4.48 - fixture->expected = expected;
4.49 -
4.50 - fixture->actual = gplate_template_render(fixture->template,
4.51 - fixture->template_string,
4.52 - &fixture->error);
4.53 -
4.54 - g_assert(fixture->error == NULL);
4.55 -
4.56 - g_assert_cmpstr(fixture->expected, ==, fixture->actual);
4.57 -}
4.58 -
5.1 --- a/gplate/tags/tests/gplate-tag-test.h Sun Jul 04 02:58:33 2010 -0500
5.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
5.3 @@ -1,49 +0,0 @@
5.4 -/*
5.5 - * Copyright (C) 2007-2010 Gary Kramlich <grim@reaperworld.com>
5.6 - *
5.7 - * This program is free software: you can redistribute it and/or modify
5.8 - * it under the terms of the GNU General Public License as published by
5.9 - * the Free Software Foundation, either version 3 of the License, or
5.10 - * (at your option) any later version.
5.11 - *
5.12 - * This program is distributed in the hope that it will be useful,
5.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
5.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5.15 - * GNU General Public License for more details.
5.16 - *
5.17 - * You should have received a copy of the GNU General Public License
5.18 - * along with this program. If not, see <http://www.gnu.org/licenses/>.
5.19 - */
5.20 -#ifndef GPLATE_TAG_TEST_H
5.21 -#define GPLATE_TAG_TEST_H
5.22 -
5.23 -#include <gplate/gplate.h>
5.24 -
5.25 -#include <glib.h>
5.26 -
5.27 -#define gplate_tag_test_add(path, func) \
5.28 - g_test_add((path), GPlateTagTestFixture, NULL, gplate_tag_test_setup, (func), gplate_tag_test_teardown)
5.29 -
5.30 -typedef struct _GPlateTagTestFixture GPlateTagTestFixture;
5.31 -
5.32 -typedef void (*GPlateTagTestFixtureFunc)(GPlateTagTestFixture *fixture, gconstpointer data);
5.33 -
5.34 -struct _GPlateTagTestFixture {
5.35 - GPlateTemplate *template;
5.36 - GError *error;
5.37 -
5.38 - const gchar *template_string;
5.39 -
5.40 - const gchar *expected;
5.41 - gchar *actual;
5.42 -};
5.43 -
5.44 -G_BEGIN_DECLS
5.45 -
5.46 -void gplate_tag_test_setup(GPlateTagTestFixture *fixture, gconstpointer data);
5.47 -void gplate_tag_test_teardown(GPlateTagTestFixture *fixture, gconstpointer data);
5.48 -void gplate_tag_test_output(GPlateTagTestFixture *fixture, gconstpointer data, const gchar *template_string, const gchar *expected);
5.49 -
5.50 -G_END_DECLS
5.51 -
5.52 -#endif /* GPLATE_TAG_TEST_H */
6.1 --- a/gplate/tags/tests/gplate-text-tag-test.c Sun Jul 04 02:58:33 2010 -0500
6.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
6.3 @@ -1,72 +0,0 @@
6.4 -/*
6.5 - * Copyright (C) 2007-2010 Gary Kramlich <grim@reaperworld.com>
6.6 - *
6.7 - * This program is free software: you can redistribute it and/or modify
6.8 - * it under the terms of the GNU General Public License as published by
6.9 - * the Free Software Foundation, either version 3 of the License, or
6.10 - * (at your option) any later version.
6.11 - *
6.12 - * This program is distributed in the hope that it will be useful,
6.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
6.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6.15 - * GNU General Public License for more details.
6.16 - *
6.17 - * You should have received a copy of the GNU General Public License
6.18 - * along with this program. If not, see <http://www.gnu.org/licenses/>.
6.19 - */
6.20 -#include <gplate/gplate.h>
6.21 -
6.22 -#include <glib.h>
6.23 -
6.24 -#include "gplate-tag-test.h"
6.25 -
6.26 -/******************************************************************************
6.27 - * Tests
6.28 - *****************************************************************************/
6.29 -static void
6.30 -gplate_text_tag_test_syntax_plain(GPlateTagTestFixture *fixture,
6.31 - gconstpointer data)
6.32 -{
6.33 - gplate_tag_test_output(fixture, data,
6.34 - "simple template", "simple template");
6.35 -}
6.36 -
6.37 -static void
6.38 -gplate_text_tag_test_syntax_keywords(GPlateTagTestFixture *fixture,
6.39 - gconstpointer data)
6.40 -{
6.41 - gplate_tag_test_output(fixture, data,
6.42 - "extends if else endif for endfor",
6.43 - "extends if else endif for endfor");
6.44 -}
6.45 -
6.46 -static void
6.47 -gplate_text_tag_test_syntax_keywords_case_sensitive(GPlateTagTestFixture *fixture,
6.48 - gconstpointer data)
6.49 -{
6.50 - gplate_tag_test_output(fixture, data,
6.51 - "EXteNds iF eLse enDif fOr enDFor",
6.52 - "EXteNds iF eLse enDif fOr enDFor");
6.53 -}
6.54 -
6.55 -/******************************************************************************
6.56 - * Main
6.57 - *****************************************************************************/
6.58 -gint
6.59 -main(gint argc, gchar **argv) {
6.60 - g_test_init(&argc, &argv, NULL);
6.61 -
6.62 - g_type_init();
6.63 -
6.64 - gplate_config_load_default();
6.65 -
6.66 - gplate_tag_test_add("/tags/text/plain",
6.67 - gplate_text_tag_test_syntax_plain);
6.68 - gplate_tag_test_add("/tags/text/keywords",
6.69 - gplate_text_tag_test_syntax_keywords);
6.70 - gplate_tag_test_add("/tags/text/keywords_case_sensitive",
6.71 - gplate_text_tag_test_syntax_keywords_case_sensitive);
6.72 -
6.73 - return g_test_run();
6.74 -}
6.75 -
7.1 --- a/gplate/tags/tests/gplate-variable-tag-test.c Sun Jul 04 02:58:33 2010 -0500
7.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
7.3 @@ -1,186 +0,0 @@
7.4 -/*
7.5 - * Copyright (C) 2007-2010 Gary Kramlich <grim@reaperworld.com>
7.6 - *
7.7 - * This program is free software: you can redistribute it and/or modify
7.8 - * it under the terms of the GNU General Public License as published by
7.9 - * the Free Software Foundation, either version 3 of the License, or
7.10 - * (at your option) any later version.
7.11 - *
7.12 - * This program is distributed in the hope that it will be useful,
7.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
7.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7.15 - * GNU General Public License for more details.
7.16 - *
7.17 - * You should have received a copy of the GNU General Public License
7.18 - * along with this program. If not, see <http://www.gnu.org/licenses/>.
7.19 - */
7.20 -#include <gplate/gplate.h>
7.21 -
7.22 -#include <glib.h>
7.23 -
7.24 -#include "gplate-tag-test.h"
7.25 -
7.26 -/******************************************************************************
7.27 - * Helpers
7.28 - *****************************************************************************/
7.29 -static void
7.30 -gplate_variable_tag_test(GPlateTagTestFixture *fixture, gconstpointer data,
7.31 - const gchar *template_string, const gchar *expected,
7.32 - ...)
7.33 -{
7.34 - va_list vargs;
7.35 - const gchar *name = NULL, *value = NULL;
7.36 -
7.37 - va_start(vargs, expected);
7.38 - while((name = va_arg(vargs, const gchar *))) {
7.39 - value = va_arg(vargs, const gchar *);
7.40 -
7.41 - gplate_collection_add_string(GPLATE_COLLECTION(fixture->template),
7.42 - name, value);
7.43 - }
7.44 - va_end(vargs);
7.45 -
7.46 - gplate_tag_test_output(fixture, data, template_string, expected);
7.47 -}
7.48 -
7.49 -/******************************************************************************
7.50 - * Tests
7.51 - *****************************************************************************/
7.52 -static void
7.53 -gplate_variable_tag_test_single(GPlateTagTestFixture *fixture,
7.54 - gconstpointer data)
7.55 -{
7.56 - gplate_variable_tag_test(fixture, data,
7.57 - "{{ foo }}", "foo",
7.58 - "foo", "foo",
7.59 - NULL);
7.60 -}
7.61 -
7.62 -static void
7.63 -gplate_variable_tag_test_double(GPlateTagTestFixture *fixture,
7.64 - gconstpointer data)
7.65 -{
7.66 - gplate_variable_tag_test(fixture, data,
7.67 - "{{ foo }}{{ bar }}", "foobar",
7.68 - "foo", "foo",
7.69 - "bar", "bar",
7.70 - NULL);
7.71 -}
7.72 -
7.73 -static void
7.74 -gplate_variable_tag_test_tripple(GPlateTagTestFixture *fixture,
7.75 - gconstpointer data)
7.76 -{
7.77 - gplate_variable_tag_test(fixture, data,
7.78 - "{{ foo }}{{ bar }}{{ baz }}", "foobarbaz",
7.79 - "foo", "foo",
7.80 - "bar", "bar",
7.81 - "baz", "baz",
7.82 - NULL);
7.83 -}
7.84 -
7.85 -static void
7.86 -gplate_variable_tag_test_newline_prefix(GPlateTagTestFixture *fixture,
7.87 - gconstpointer data)
7.88 -{
7.89 - gplate_variable_tag_test(fixture, data,
7.90 - "{{\nfoo}}", "foo",
7.91 - "foo", "foo",
7.92 - NULL);
7.93 -}
7.94 -
7.95 -static void
7.96 -gplate_variable_tag_test_newline_suffix(GPlateTagTestFixture *fixture,
7.97 - gconstpointer data)
7.98 -{
7.99 - gplate_variable_tag_test(fixture, data,
7.100 - "{{foo\n}}", "foo",
7.101 - "foo", "foo",
7.102 - NULL);
7.103 -}
7.104 -
7.105 -static void
7.106 -gplate_variable_tag_test_newline_wrapped(GPlateTagTestFixture *fixture,
7.107 - gconstpointer data)
7.108 -{
7.109 - gplate_variable_tag_test(fixture, data,
7.110 - "{{\nfoo\n}}", "foo",
7.111 - "foo", "foo",
7.112 - NULL);
7.113 -}
7.114 -
7.115 -static void
7.116 -gplate_variable_tag_test_single_quotes(GPlateTagTestFixture *fixture,
7.117 - gconstpointer data)
7.118 -{
7.119 - gplate_variable_tag_test(fixture, data,
7.120 - "foo '{{ bar }}' baz", "foo 'bar' baz",
7.121 - "bar", "bar",
7.122 - NULL);
7.123 -}
7.124 -
7.125 -static void
7.126 -gplate_variable_tag_test_double_quotes(GPlateTagTestFixture *fixture,
7.127 - gconstpointer data)
7.128 -{
7.129 - gplate_variable_tag_test(fixture, data,
7.130 - "foo \"{{ bar }}\" baz", "foo \"bar\" baz",
7.131 - "bar", "bar",
7.132 - NULL);
7.133 -}
7.134 -
7.135 -static void
7.136 -gplate_variable_tag_test_mixed_quotes(GPlateTagTestFixture *fixture,
7.137 - gconstpointer data)
7.138 -{
7.139 - gplate_variable_tag_test(fixture, data,
7.140 - "foo \"{{ bar }}' baz", "foo \"bar' baz",
7.141 - "bar", "bar",
7.142 - NULL);
7.143 -
7.144 - gplate_variable_tag_test(fixture, data,
7.145 - "foo '{{ bar }}\" baz", "foo 'bar\" baz",
7.146 - "bar", "bar",
7.147 - NULL);
7.148 -}
7.149 -/******************************************************************************
7.150 - * Main
7.151 - *****************************************************************************/
7.152 -gint
7.153 -main(gint argc, gchar **argv) {
7.154 - g_test_init(&argc, &argv, NULL);
7.155 -
7.156 - g_type_init();
7.157 -
7.158 - gplate_config_load_default();
7.159 -
7.160 - gplate_tag_test_add("/tags/variable/single",
7.161 - gplate_variable_tag_test_single);
7.162 -
7.163 - gplate_tag_test_add("/tags/variable/double",
7.164 - gplate_variable_tag_test_double);
7.165 -
7.166 - gplate_tag_test_add("/tags/variable/tripple",
7.167 - gplate_variable_tag_test_tripple);
7.168 -
7.169 - gplate_tag_test_add("/tags/variable/newline_prefix",
7.170 - gplate_variable_tag_test_newline_prefix);
7.171 -
7.172 - gplate_tag_test_add("/tags/variable/newline_suffix",
7.173 - gplate_variable_tag_test_newline_suffix);
7.174 -
7.175 - gplate_tag_test_add("/tags/variable/newline_wrapped",
7.176 - gplate_variable_tag_test_newline_wrapped);
7.177 -
7.178 - gplate_tag_test_add("/tags/variable/quotes/single",
7.179 - gplate_variable_tag_test_single_quotes);
7.180 -
7.181 - gplate_tag_test_add("/tags/variable/quotes/double",
7.182 - gplate_variable_tag_test_double_quotes);
7.183 -
7.184 - gplate_tag_test_add("/tags/variable/quotes/mixed",
7.185 - gplate_variable_tag_test_mixed_quotes);
7.186 -
7.187 - return g_test_run();
7.188 -}
7.189 -
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/gplate/tags/tests/test-gplate-comment-tag.c Sun Jul 04 03:34:39 2010 -0500
8.3 @@ -0,0 +1,81 @@
8.4 +/*
8.5 + * Copyright (C) 2007-2010 Gary Kramlich <grim@reaperworld.com>
8.6 + *
8.7 + * This program is free software: you can redistribute it and/or modify
8.8 + * it under the terms of the GNU General Public License as published by
8.9 + * the Free Software Foundation, either version 3 of the License, or
8.10 + * (at your option) any later version.
8.11 + *
8.12 + * This program is distributed in the hope that it will be useful,
8.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
8.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8.15 + * GNU General Public License for more details.
8.16 + *
8.17 + * You should have received a copy of the GNU General Public License
8.18 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
8.19 + */
8.20 +#include <gplate/gplate.h>
8.21 +
8.22 +#include <glib.h>
8.23 +
8.24 +#include "test-gplate-tag.h"
8.25 +
8.26 +/******************************************************************************
8.27 + * Tests
8.28 + *****************************************************************************/
8.29 +static void
8.30 +test_gplate_comment_tag_empty(TestGPlateTagFixture *fixture,
8.31 + gconstpointer data)
8.32 +{
8.33 + test_gplate_tag_output(fixture, data, "{##}", "");
8.34 +}
8.35 +
8.36 +static void
8.37 +test_gplate_comment_tag_whitespace(TestGPlateTagFixture *fixture,
8.38 + gconstpointer data)
8.39 +{
8.40 + test_gplate_tag_output(fixture, data, "{# #}", "");
8.41 + test_gplate_tag_output(fixture, data, "{#\t#}", "");
8.42 + test_gplate_tag_output(fixture, data, "{#\n#}", "");
8.43 + test_gplate_tag_output(fixture, data, "{#\r#}", "");
8.44 + test_gplate_tag_output(fixture, data, "{#\r\n#}", "");
8.45 + test_gplate_tag_output(fixture, data, "{#\n\r#}", "");
8.46 +}
8.47 +
8.48 +static void
8.49 +test_gplate_comment_tag_simple(TestGPlateTagFixture *fixture,
8.50 + gconstpointer data)
8.51 +{
8.52 + test_gplate_tag_output(fixture, data, "{# foo#}", "");
8.53 + test_gplate_tag_output(fixture, data, "{#foo #}", "");
8.54 + test_gplate_tag_output(fixture, data, "{#\tfoo#}", "");
8.55 + test_gplate_tag_output(fixture, data, "{#foo\t#}", "");
8.56 + test_gplate_tag_output(fixture, data, "{#\nfoo#}", "");
8.57 + test_gplate_tag_output(fixture, data, "{#foo\n#}", "");
8.58 + test_gplate_tag_output(fixture, data, "{#\rfoo#}", "");
8.59 + test_gplate_tag_output(fixture, data, "{#foo\r#}", "");
8.60 + test_gplate_tag_output(fixture, data, "{#\r\nfoo#}", "");
8.61 + test_gplate_tag_output(fixture, data, "{#foo\r\n#}", "");
8.62 +}
8.63 +
8.64 +/******************************************************************************
8.65 + * Main
8.66 + *****************************************************************************/
8.67 +gint
8.68 +main(gint argc, gchar **argv) {
8.69 + g_test_init(&argc, &argv, NULL);
8.70 +
8.71 + g_type_init();
8.72 +
8.73 + gplate_config_load_default();
8.74 +
8.75 + test_gplate_tag_add("/tags/comment/empty",
8.76 + test_gplate_comment_tag_empty);
8.77 + test_gplate_tag_add("/tags/comment/whitespace",
8.78 + test_gplate_comment_tag_whitespace);
8.79 + test_gplate_tag_add("/tags/comment/simple",
8.80 + test_gplate_comment_tag_simple);
8.81 +
8.82 + return g_test_run();
8.83 +}
8.84 +
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
9.2 +++ b/gplate/tags/tests/test-gplate-tag.c Sun Jul 04 03:34:39 2010 -0500
9.3 @@ -0,0 +1,55 @@
9.4 +/*
9.5 + * Copyright (C) 2007-2010 Gary Kramlich <grim@reaperworld.com>
9.6 + *
9.7 + * This program is free software: you can redistribute it and/or modify
9.8 + * it under the terms of the GNU General Public License as published by
9.9 + * the Free Software Foundation, either version 3 of the License, or
9.10 + * (at your option) any later version.
9.11 + *
9.12 + * This program is distributed in the hope that it will be useful,
9.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
9.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9.15 + * GNU General Public License for more details.
9.16 + *
9.17 + * You should have received a copy of the GNU General Public License
9.18 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
9.19 + */
9.20 +#include "test-gplate-tag.h"
9.21 +
9.22 +void
9.23 +test_gplate_tag_setup(TestGPlateTagFixture *fixture, gconstpointer data) {
9.24 + fixture->template = gplate_template_new();
9.25 +}
9.26 +
9.27 +void
9.28 +test_gplate_tag_teardown(TestGPlateTagFixture *fixture, gconstpointer data) {
9.29 + g_object_unref(fixture->template);
9.30 + fixture->template = NULL;
9.31 +
9.32 + if(fixture->error) {
9.33 + g_error_free(fixture->error);
9.34 + fixture->error = NULL;
9.35 + }
9.36 +
9.37 + g_free(fixture->actual);
9.38 + fixture->actual = NULL;
9.39 +}
9.40 +
9.41 +void
9.42 +test_gplate_tag_output(TestGPlateTagFixture *fixture,
9.43 + gconstpointer data,
9.44 + const gchar *template_string,
9.45 + const gchar *expected)
9.46 +{
9.47 + fixture->template_string = template_string;
9.48 + fixture->expected = expected;
9.49 +
9.50 + fixture->actual = gplate_template_render(fixture->template,
9.51 + fixture->template_string,
9.52 + &fixture->error);
9.53 +
9.54 + g_assert(fixture->error == NULL);
9.55 +
9.56 + g_assert_cmpstr(fixture->expected, ==, fixture->actual);
9.57 +}
9.58 +
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
10.2 +++ b/gplate/tags/tests/test-gplate-tag.h Sun Jul 04 03:34:39 2010 -0500
10.3 @@ -0,0 +1,50 @@
10.4 +/*
10.5 + * Copyright (C) 2007-2010 Gary Kramlich <grim@reaperworld.com>
10.6 + *
10.7 + * This program is free software: you can redistribute it and/or modify
10.8 + * it under the terms of the GNU General Public License as published by
10.9 + * the Free Software Foundation, either version 3 of the License, or
10.10 + * (at your option) any later version.
10.11 + *
10.12 + * This program is distributed in the hope that it will be useful,
10.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
10.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10.15 + * GNU General Public License for more details.
10.16 + *
10.17 + * You should have received a copy of the GNU General Public License
10.18 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
10.19 + */
10.20 +#ifndef TEST_GPLATE_TAG_H
10.21 +#define TEST_GPLATE_TAG_H
10.22 +
10.23 +#include <gplate/gplate.h>
10.24 +
10.25 +#include <glib.h>
10.26 +
10.27 +#define test_gplate_tag_add(path, func) \
10.28 + g_test_add((path), TestGPlateTagFixture, NULL, test_gplate_tag_setup, (func), test_gplate_tag_teardown)
10.29 +
10.30 +typedef struct _TestGPlateTagFixture TestGPlateTagFixture;
10.31 +
10.32 +typedef void (*TestGPlateTagFixtureFunc)(TestGPlateTagFixture *fixture, gconstpointer data);
10.33 +
10.34 +struct _TestGPlateTagFixture {
10.35 + GPlateTemplate *template;
10.36 + GError *error;
10.37 +
10.38 + const gchar *template_string;
10.39 +
10.40 + const gchar *expected;
10.41 + gchar *actual;
10.42 +};
10.43 +
10.44 +G_BEGIN_DECLS
10.45 +
10.46 +void test_gplate_tag_setup(TestGPlateTagFixture *fixture, gconstpointer data);
10.47 +void test_gplate_tag_teardown(TestGPlateTagFixture *fixture, gconstpointer data);
10.48 +void test_gplate_tag_output(TestGPlateTagFixture *fixture, gconstpointer data, const gchar *template_string, const gchar *expected);
10.49 +
10.50 +G_END_DECLS
10.51 +
10.52 +#endif /* TEST_GPLATE_TAG_H */
10.53 +
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
11.2 +++ b/gplate/tags/tests/test-gplate-text-tag.c Sun Jul 04 03:34:39 2010 -0500
11.3 @@ -0,0 +1,72 @@
11.4 +/*
11.5 + * Copyright (C) 2007-2010 Gary Kramlich <grim@reaperworld.com>
11.6 + *
11.7 + * This program is free software: you can redistribute it and/or modify
11.8 + * it under the terms of the GNU General Public License as published by
11.9 + * the Free Software Foundation, either version 3 of the License, or
11.10 + * (at your option) any later version.
11.11 + *
11.12 + * This program is distributed in the hope that it will be useful,
11.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
11.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11.15 + * GNU General Public License for more details.
11.16 + *
11.17 + * You should have received a copy of the GNU General Public License
11.18 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
11.19 + */
11.20 +#include <gplate/gplate.h>
11.21 +
11.22 +#include <glib.h>
11.23 +
11.24 +#include "test-gplate-tag.h"
11.25 +
11.26 +/******************************************************************************
11.27 + * Tests
11.28 + *****************************************************************************/
11.29 +static void
11.30 +test_gplate_text_tag_syntax_plain(TestGPlateTagFixture *fixture,
11.31 + gconstpointer data)
11.32 +{
11.33 + test_gplate_tag_output(fixture, data,
11.34 + "simple template", "simple template");
11.35 +}
11.36 +
11.37 +static void
11.38 +test_gplate_text_tag_syntax_keywords(TestGPlateTagFixture *fixture,
11.39 + gconstpointer data)
11.40 +{
11.41 + test_gplate_tag_output(fixture, data,
11.42 + "extends if else endif for endfor",
11.43 + "extends if else endif for endfor");
11.44 +}
11.45 +
11.46 +static void
11.47 +test_gplate_text_tag_syntax_keywords_case_sensitive(TestGPlateTagFixture *fixture,
11.48 + gconstpointer data)
11.49 +{
11.50 + test_gplate_tag_output(fixture, data,
11.51 + "EXteNds iF eLse enDif fOr enDFor",
11.52 + "EXteNds iF eLse enDif fOr enDFor");
11.53 +}
11.54 +
11.55 +/******************************************************************************
11.56 + * Main
11.57 + *****************************************************************************/
11.58 +gint
11.59 +main(gint argc, gchar **argv) {
11.60 + g_test_init(&argc, &argv, NULL);
11.61 +
11.62 + g_type_init();
11.63 +
11.64 + gplate_config_load_default();
11.65 +
11.66 + test_gplate_tag_add("/tags/text/plain",
11.67 + test_gplate_text_tag_syntax_plain);
11.68 + test_gplate_tag_add("/tags/text/keywords",
11.69 + test_gplate_text_tag_syntax_keywords);
11.70 + test_gplate_tag_add("/tags/text/keywords_case_sensitive",
11.71 + test_gplate_text_tag_syntax_keywords_case_sensitive);
11.72 +
11.73 + return g_test_run();
11.74 +}
11.75 +
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
12.2 +++ b/gplate/tags/tests/test-gplate-variable-tag.c Sun Jul 04 03:34:39 2010 -0500
12.3 @@ -0,0 +1,186 @@
12.4 +/*
12.5 + * Copyright (C) 2007-2010 Gary Kramlich <grim@reaperworld.com>
12.6 + *
12.7 + * This program is free software: you can redistribute it and/or modify
12.8 + * it under the terms of the GNU General Public License as published by
12.9 + * the Free Software Foundation, either version 3 of the License, or
12.10 + * (at your option) any later version.
12.11 + *
12.12 + * This program is distributed in the hope that it will be useful,
12.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
12.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12.15 + * GNU General Public License for more details.
12.16 + *
12.17 + * You should have received a copy of the GNU General Public License
12.18 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
12.19 + */
12.20 +#include <gplate/gplate.h>
12.21 +
12.22 +#include <glib.h>
12.23 +
12.24 +#include "test-gplate-tag.h"
12.25 +
12.26 +/******************************************************************************
12.27 + * Helpers
12.28 + *****************************************************************************/
12.29 +static void
12.30 +test_gplate_variable_tag(TestGPlateTagFixture *fixture, gconstpointer data,
12.31 + const gchar *template_string, const gchar *expected,
12.32 + ...)
12.33 +{
12.34 + va_list vargs;
12.35 + const gchar *name = NULL, *value = NULL;
12.36 +
12.37 + va_start(vargs, expected);
12.38 + while((name = va_arg(vargs, const gchar *))) {
12.39 + value = va_arg(vargs, const gchar *);
12.40 +
12.41 + gplate_collection_add_string(GPLATE_COLLECTION(fixture->template),
12.42 + name, value);
12.43 + }
12.44 + va_end(vargs);
12.45 +
12.46 + test_gplate_tag_output(fixture, data, template_string, expected);
12.47 +}
12.48 +
12.49 +/******************************************************************************
12.50 + * Tests
12.51 + *****************************************************************************/
12.52 +static void
12.53 +test_gplate_variable_tag_single(TestGPlateTagFixture *fixture,
12.54 + gconstpointer data)
12.55 +{
12.56 + test_gplate_variable_tag(fixture, data,
12.57 + "{{ foo }}", "foo",
12.58 + "foo", "foo",
12.59 + NULL);
12.60 +}
12.61 +
12.62 +static void
12.63 +test_gplate_variable_tag_double(TestGPlateTagFixture *fixture,
12.64 + gconstpointer data)
12.65 +{
12.66 + test_gplate_variable_tag(fixture, data,
12.67 + "{{ foo }}{{ bar }}", "foobar",
12.68 + "foo", "foo",
12.69 + "bar", "bar",
12.70 + NULL);
12.71 +}
12.72 +
12.73 +static void
12.74 +test_gplate_variable_tag_tripple(TestGPlateTagFixture *fixture,
12.75 + gconstpointer data)
12.76 +{
12.77 + test_gplate_variable_tag(fixture, data,
12.78 + "{{ foo }}{{ bar }}{{ baz }}", "foobarbaz",
12.79 + "foo", "foo",
12.80 + "bar", "bar",
12.81 + "baz", "baz",
12.82 + NULL);
12.83 +}
12.84 +
12.85 +static void
12.86 +test_gplate_variable_tag_newline_prefix(TestGPlateTagFixture *fixture,
12.87 + gconstpointer data)
12.88 +{
12.89 + test_gplate_variable_tag(fixture, data,
12.90 + "{{\nfoo}}", "foo",
12.91 + "foo", "foo",
12.92 + NULL);
12.93 +}
12.94 +
12.95 +static void
12.96 +test_gplate_variable_tag_newline_suffix(TestGPlateTagFixture *fixture,
12.97 + gconstpointer data)
12.98 +{
12.99 + test_gplate_variable_tag(fixture, data,
12.100 + "{{foo\n}}", "foo",
12.101 + "foo", "foo",
12.102 + NULL);
12.103 +}
12.104 +
12.105 +static void
12.106 +test_gplate_variable_tag_newline_wrapped(TestGPlateTagFixture *fixture,
12.107 + gconstpointer data)
12.108 +{
12.109 + test_gplate_variable_tag(fixture, data,
12.110 + "{{\nfoo\n}}", "foo",
12.111 + "foo", "foo",
12.112 + NULL);
12.113 +}
12.114 +
12.115 +static void
12.116 +test_gplate_variable_tag_single_quotes(TestGPlateTagFixture *fixture,
12.117 + gconstpointer data)
12.118 +{
12.119 + test_gplate_variable_tag(fixture, data,
12.120 + "foo '{{ bar }}' baz", "foo 'bar' baz",
12.121 + "bar", "bar",
12.122 + NULL);
12.123 +}
12.124 +
12.125 +static void
12.126 +test_gplate_variable_tag_double_quotes(TestGPlateTagFixture *fixture,
12.127 + gconstpointer data)
12.128 +{
12.129 + test_gplate_variable_tag(fixture, data,
12.130 + "foo \"{{ bar }}\" baz", "foo \"bar\" baz",
12.131 + "bar", "bar",
12.132 + NULL);
12.133 +}
12.134 +
12.135 +static void
12.136 +test_gplate_variable_tag_mixed_quotes(TestGPlateTagFixture *fixture,
12.137 + gconstpointer data)
12.138 +{
12.139 + test_gplate_variable_tag(fixture, data,
12.140 + "foo \"{{ bar }}' baz", "foo \"bar' baz",
12.141 + "bar", "bar",
12.142 + NULL);
12.143 +
12.144 + test_gplate_variable_tag(fixture, data,
12.145 + "foo '{{ bar }}\" baz", "foo 'bar\" baz",
12.146 + "bar", "bar",
12.147 + NULL);
12.148 +}
12.149 +/******************************************************************************
12.150 + * Main
12.151 + *****************************************************************************/
12.152 +gint
12.153 +main(gint argc, gchar **argv) {
12.154 + g_test_init(&argc, &argv, NULL);
12.155 +
12.156 + g_type_init();
12.157 +
12.158 + gplate_config_load_default();
12.159 +
12.160 + test_gplate_tag_add("/tags/variable/single",
12.161 + test_gplate_variable_tag_single);
12.162 +
12.163 + test_gplate_tag_add("/tags/variable/double",
12.164 + test_gplate_variable_tag_double);
12.165 +
12.166 + test_gplate_tag_add("/tags/variable/tripple",
12.167 + test_gplate_variable_tag_tripple);
12.168 +
12.169 + test_gplate_tag_add("/tags/variable/newline_prefix",
12.170 + test_gplate_variable_tag_newline_prefix);
12.171 +
12.172 + test_gplate_tag_add("/tags/variable/newline_suffix",
12.173 + test_gplate_variable_tag_newline_suffix);
12.174 +
12.175 + test_gplate_tag_add("/tags/variable/newline_wrapped",
12.176 + test_gplate_variable_tag_newline_wrapped);
12.177 +
12.178 + test_gplate_tag_add("/tags/variable/quotes/single",
12.179 + test_gplate_variable_tag_single_quotes);
12.180 +
12.181 + test_gplate_tag_add("/tags/variable/quotes/double",
12.182 + test_gplate_variable_tag_double_quotes);
12.183 +
12.184 + test_gplate_tag_add("/tags/variable/quotes/mixed",
12.185 + test_gplate_variable_tag_mixed_quotes);
12.186 +
12.187 + return g_test_run();
12.188 +}
12.189 +
13.1 --- a/gplate/tests/CMakeLists.txt Sun Jul 04 02:58:33 2010 -0500
13.2 +++ b/gplate/tests/CMakeLists.txt Sun Jul 04 03:34:39 2010 -0500
13.3 @@ -1,10 +1,22 @@
13.4 enable_testing()
13.5
13.6 -add_executable(test-collection-interface test-collection-interface.c)
13.7 -target_link_libraries(test-collection-interface gplate)
13.8 -add_test(GPlateCollectionInterface test-collection-interface)
13.9 +###############################################################################
13.10 +# collection tests
13.11 +###############################################################################
13.12 +add_executable(test-gplate-collection-interface test-gplate-collection-interface.c)
13.13 +target_link_libraries(test-gplate-collection-interface gplate)
13.14 +add_test(GPlateCollectionInterface
13.15 + gtester -k --verbose -o test-gplate-collection-interface.log
13.16 + test-gplate-collection-interface
13.17 +)
13.18
13.19 -add_executable(test-util-functions test-util-functions.c)
13.20 -target_link_libraries(test-util-functions gplate)
13.21 -add_test(GPlateUtilityFunctions test-util-functions)
13.22 +###############################################################################
13.23 +# utility tests
13.24 +###############################################################################
13.25 +add_executable(test-gplate-utility-functions test-gplate-utility-functions.c)
13.26 +target_link_libraries(test-gplate-utility-functions gplate)
13.27 +add_test(GPlateUtilityFunctions
13.28 + gtester -k --verbose -o test-gplate-utility-functions.log
13.29 + test-gplate-utility-functions
13.30 +)
13.31
14.1 --- a/gplate/tests/test-collection-interface.c Sun Jul 04 02:58:33 2010 -0500
14.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
14.3 @@ -1,34 +0,0 @@
14.4 -/*
14.5 - * Copyright (C) 2007-2010 Gary Kramlich <grim@reaperworld.com>
14.6 - *
14.7 - * This program is free software: you can redistribute it and/or modify
14.8 - * it under the terms of the GNU General Public License as published by
14.9 - * the Free Software Foundation, either version 3 of the License, or
14.10 - * (at your option) any later version.
14.11 - *
14.12 - * This program is distributed in the hope that it will be useful,
14.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
14.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14.15 - * GNU General Public License for more details.
14.16 - *
14.17 - * You should have received a copy of the GNU General Public License
14.18 - * along with this program. If not, see <http://www.gnu.org/licenses/>.
14.19 - */
14.20 -#include <gplate/gplate.h>
14.21 -
14.22 -#include <glib.h>
14.23 -
14.24 -/******************************************************************************
14.25 - * Main
14.26 - *****************************************************************************/
14.27 -gint
14.28 -main(gint argc, gchar **argv) {
14.29 - g_test_init(&argc, &argv, NULL);
14.30 -
14.31 - g_type_init();
14.32 -
14.33 - gplate_config_load_default();
14.34 -
14.35 - return g_test_run();
14.36 -}
14.37 -
15.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
15.2 +++ b/gplate/tests/test-gplate-collection-interface.c Sun Jul 04 03:34:39 2010 -0500
15.3 @@ -0,0 +1,34 @@
15.4 +/*
15.5 + * Copyright (C) 2007-2010 Gary Kramlich <grim@reaperworld.com>
15.6 + *
15.7 + * This program is free software: you can redistribute it and/or modify
15.8 + * it under the terms of the GNU General Public License as published by
15.9 + * the Free Software Foundation, either version 3 of the License, or
15.10 + * (at your option) any later version.
15.11 + *
15.12 + * This program is distributed in the hope that it will be useful,
15.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
15.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15.15 + * GNU General Public License for more details.
15.16 + *
15.17 + * You should have received a copy of the GNU General Public License
15.18 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
15.19 + */
15.20 +#include <gplate/gplate.h>
15.21 +
15.22 +#include <glib.h>
15.23 +
15.24 +/******************************************************************************
15.25 + * Main
15.26 + *****************************************************************************/
15.27 +gint
15.28 +main(gint argc, gchar **argv) {
15.29 + g_test_init(&argc, &argv, NULL);
15.30 +
15.31 + g_type_init();
15.32 +
15.33 + gplate_config_load_default();
15.34 +
15.35 + return g_test_run();
15.36 +}
15.37 +
16.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
16.2 +++ b/gplate/tests/test-gplate-utility-functions.c Sun Jul 04 03:34:39 2010 -0500
16.3 @@ -0,0 +1,58 @@
16.4 +/*
16.5 + * Copyright (C) 2007-2010 Gary Kramlich <grim@reaperworld.com>
16.6 + * * This program is free software: you can redistribute it and/or modify
16.7 + * it under the terms of the GNU General Public License as published by
16.8 + * the Free Software Foundation, either version 3 of the License, or
16.9 + * (at your option) any later version.
16.10 + *
16.11 + * This program is distributed in the hope that it will be useful,
16.12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
16.13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16.14 + * GNU General Public License for more details.
16.15 + *
16.16 + * You should have received a copy of the GNU General Public License
16.17 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
16.18 + */
16.19 +#include <gplate/gplate.h>
16.20 +
16.21 +static void
16.22 +gplate_util_test_quoted_string_helper(const gchar *string,
16.23 + const gchar *contents, gboolean value)
16.24 +{
16.25 + gboolean r = FALSE;
16.26 + gchar *c = NULL;
16.27 +
16.28 + r = gplate_util_is_quoted_string(string, &c);
16.29 + g_assert_cmpint(r, ==, value);
16.30 +
16.31 + if(contents)
16.32 + g_assert_cmpstr(c, ==, contents);
16.33 +
16.34 + g_free(c);
16.35 +}
16.36 +
16.37 +static void
16.38 +gplate_util_test_quoted_string(void) {
16.39 + gplate_util_test_quoted_string_helper("\"abc\"", "abc", TRUE);
16.40 + gplate_util_test_quoted_string_helper("\"abc def\"", "abc def", TRUE);
16.41 + gplate_util_test_quoted_string_helper("\"abc\tdef\bghi\"", "abc\tdef\bghi", TRUE);
16.42 + gplate_util_test_quoted_string_helper("abc \"def\"", NULL, FALSE);
16.43 + gplate_util_test_quoted_string_helper("\"abc\" def", NULL, FALSE);
16.44 + gplate_util_test_quoted_string_helper("'abc'", "abc", TRUE);
16.45 + gplate_util_test_quoted_string_helper("'abc def'", "abc def", TRUE);
16.46 + gplate_util_test_quoted_string_helper("'abc\tdef\bghi'", "abc\tdef\bghi", TRUE);
16.47 + gplate_util_test_quoted_string_helper("abc 'def'", NULL, FALSE);
16.48 + gplate_util_test_quoted_string_helper("'abc' def", NULL, FALSE);
16.49 + gplate_util_test_quoted_string_helper("'abc\"", NULL, FALSE);
16.50 + gplate_util_test_quoted_string_helper("\"abc'", NULL, FALSE);
16.51 +}
16.52 +
16.53 +gint
16.54 +main(gint argc, gchar **argv) {
16.55 + g_test_init(&argc, &argv, NULL);
16.56 +
16.57 + g_test_add_func("/util/quoted_string", gplate_util_test_quoted_string);
16.58 +
16.59 + return g_test_run();
16.60 +}
16.61 +
17.1 --- a/gplate/tests/test-util-functions.c Sun Jul 04 02:58:33 2010 -0500
17.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
17.3 @@ -1,58 +0,0 @@
17.4 -/*
17.5 - * Copyright (C) 2007-2010 Gary Kramlich <grim@reaperworld.com>
17.6 - * * This program is free software: you can redistribute it and/or modify
17.7 - * it under the terms of the GNU General Public License as published by
17.8 - * the Free Software Foundation, either version 3 of the License, or
17.9 - * (at your option) any later version.
17.10 - *
17.11 - * This program is distributed in the hope that it will be useful,
17.12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
17.13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17.14 - * GNU General Public License for more details.
17.15 - *
17.16 - * You should have received a copy of the GNU General Public License
17.17 - * along with this program. If not, see <http://www.gnu.org/licenses/>.
17.18 - */
17.19 -#include <gplate/gplate.h>
17.20 -
17.21 -static void
17.22 -gplate_util_test_quoted_string_helper(const gchar *string,
17.23 - const gchar *contents, gboolean value)
17.24 -{
17.25 - gboolean r = FALSE;
17.26 - gchar *c = NULL;
17.27 -
17.28 - r = gplate_util_is_quoted_string(string, &c);
17.29 - g_assert_cmpint(r, ==, value);
17.30 -
17.31 - if(contents)
17.32 - g_assert_cmpstr(c, ==, contents);
17.33 -
17.34 - g_free(c);
17.35 -}
17.36 -
17.37 -static void
17.38 -gplate_util_test_quoted_string(void) {
17.39 - gplate_util_test_quoted_string_helper("\"abc\"", "abc", TRUE);
17.40 - gplate_util_test_quoted_string_helper("\"abc def\"", "abc def", TRUE);
17.41 - gplate_util_test_quoted_string_helper("\"abc\tdef\bghi\"", "abc\tdef\bghi", TRUE);
17.42 - gplate_util_test_quoted_string_helper("abc \"def\"", NULL, FALSE);
17.43 - gplate_util_test_quoted_string_helper("\"abc\" def", NULL, FALSE);
17.44 - gplate_util_test_quoted_string_helper("'abc'", "abc", TRUE);
17.45 - gplate_util_test_quoted_string_helper("'abc def'", "abc def", TRUE);
17.46 - gplate_util_test_quoted_string_helper("'abc\tdef\bghi'", "abc\tdef\bghi", TRUE);
17.47 - gplate_util_test_quoted_string_helper("abc 'def'", NULL, FALSE);
17.48 - gplate_util_test_quoted_string_helper("'abc' def", NULL, FALSE);
17.49 - gplate_util_test_quoted_string_helper("'abc\"", NULL, FALSE);
17.50 - gplate_util_test_quoted_string_helper("\"abc'", NULL, FALSE);
17.51 -}
17.52 -
17.53 -gint
17.54 -main(gint argc, gchar **argv) {
17.55 - g_test_init(&argc, &argv, NULL);
17.56 -
17.57 - g_test_add_func("/util/quoted_string", gplate_util_test_quoted_string);
17.58 -
17.59 - return g_test_run();
17.60 -}
17.61 -