1.1 --- a/gplate/tags/tests/gplate-variable-tag-test.c Fri Jul 02 03:00:15 2010 -0500
1.2 +++ b/gplate/tags/tests/gplate-variable-tag-test.c Fri Jul 02 03:13:36 2010 -0500
1.3 @@ -5,90 +5,96 @@
1.4 #include "gplate-tag-test.h"
1.5
1.6 /******************************************************************************
1.7 + * Helpers
1.8 + *****************************************************************************/
1.9 +static void
1.10 +gplate_variable_tag_test(GPlateTagTestFixture *fixture, gconstpointer data,
1.11 + const gchar *template_string, const gchar *expected,
1.12 + ...)
1.13 +{
1.14 + va_list vargs;
1.15 + const gchar *name = NULL, *value = NULL;
1.16 +
1.17 + fixture->template_string = template_string;
1.18 + fixture->expected = expected;
1.19 +
1.20 + va_start(vargs, expected);
1.21 + while((name = va_arg(vargs, const gchar *))) {
1.22 + value = va_arg(vargs, const gchar *);
1.23 +
1.24 + gplate_collection_add_string(GPLATE_COLLECTION(fixture->template),
1.25 + name, value);
1.26 + }
1.27 +
1.28 + va_end(vargs);
1.29 +
1.30 + gplate_tag_test_output(fixture, data);
1.31 +}
1.32 +
1.33 +/******************************************************************************
1.34 * Tests
1.35 *****************************************************************************/
1.36 static void
1.37 gplate_variable_tag_test_single(GPlateTagTestFixture *fixture,
1.38 gconstpointer data)
1.39 {
1.40 - gplate_collection_add_string(GPLATE_COLLECTION(fixture->template),
1.41 - "foo", "bar");
1.42 -
1.43 - fixture->template_string = "{{ foo }}";
1.44 - fixture->expected = "bar";
1.45 -
1.46 - gplate_tag_test_output(fixture, data);
1.47 + gplate_variable_tag_test(fixture, data,
1.48 + "{{ foo }}", "foo",
1.49 + "foo", "foo",
1.50 + NULL);
1.51 }
1.52
1.53 static void
1.54 gplate_variable_tag_test_double(GPlateTagTestFixture *fixture,
1.55 gconstpointer data)
1.56 {
1.57 - gplate_collection_add_string(GPLATE_COLLECTION(fixture->template),
1.58 - "foo", "foo");
1.59 - gplate_collection_add_string(GPLATE_COLLECTION(fixture->template),
1.60 - "bar", "bar");
1.61 -
1.62 - fixture->template_string = "{{ foo }}{{ bar }}";
1.63 - fixture->expected = "foobar";
1.64 -
1.65 - gplate_tag_test_output(fixture, data);
1.66 + gplate_variable_tag_test(fixture, data,
1.67 + "{{ foo }}{{ bar }}", "foobar",
1.68 + "foo", "foo",
1.69 + "bar", "bar",
1.70 + NULL);
1.71 }
1.72
1.73 static void
1.74 gplate_variable_tag_test_tripple(GPlateTagTestFixture *fixture,
1.75 gconstpointer data)
1.76 {
1.77 - gplate_collection_add_string(GPLATE_COLLECTION(fixture->template),
1.78 - "foo", "foo");
1.79 - gplate_collection_add_string(GPLATE_COLLECTION(fixture->template),
1.80 - "bar", "bar");
1.81 - gplate_collection_add_string(GPLATE_COLLECTION(fixture->template),
1.82 - "baz", "baz");
1.83 -
1.84 - fixture->template_string = "{{ foo }}{{ bar }}{{ baz }}";
1.85 - fixture->expected = "foobarbaz";
1.86 -
1.87 - gplate_tag_test_output(fixture, data);
1.88 + gplate_variable_tag_test(fixture, data,
1.89 + "{{ foo }}{{ bar }}{{ baz }}", "foobarbaz",
1.90 + "foo", "foo",
1.91 + "bar", "bar",
1.92 + "baz", "baz",
1.93 + NULL);
1.94 }
1.95
1.96 static void
1.97 gplate_variable_tag_test_newline_prefix(GPlateTagTestFixture *fixture,
1.98 gconstpointer data)
1.99 {
1.100 - gplate_collection_add_string(GPLATE_COLLECTION(fixture->template),
1.101 - "foo", "bar");
1.102 -
1.103 - fixture->template_string = "{{\nfoo}}";
1.104 - fixture->expected = "bar";
1.105 -
1.106 - gplate_tag_test_output(fixture, data);
1.107 + gplate_variable_tag_test(fixture, data,
1.108 + "{{\nfoo}}", "foo",
1.109 + "foo", "foo",
1.110 + NULL);
1.111 }
1.112
1.113 static void
1.114 gplate_variable_tag_test_newline_suffix(GPlateTagTestFixture *fixture,
1.115 gconstpointer data)
1.116 {
1.117 - gplate_collection_add_string(GPLATE_COLLECTION(fixture->template),
1.118 - "foo", "bar");
1.119 -
1.120 - fixture->template_string = "{{foo\n}}";
1.121 - fixture->expected = "bar";
1.122 -
1.123 - gplate_tag_test_output(fixture, data);
1.124 + gplate_variable_tag_test(fixture, data,
1.125 + "{{foo\n}}", "foo",
1.126 + "foo", "foo",
1.127 + NULL);
1.128 }
1.129
1.130 static void
1.131 gplate_variable_tag_test_newline_wrapped(GPlateTagTestFixture *fixture,
1.132 gconstpointer data)
1.133 {
1.134 - gplate_collection_add_string(GPLATE_COLLECTION(fixture->template),
1.135 - "foo", "bar");
1.136 -
1.137 - fixture->template_string = "{{\nfoo\n}}";
1.138 - fixture->expected = "bar";
1.139 -
1.140 - gplate_tag_test_output(fixture, data);
1.141 + gplate_variable_tag_test(fixture, data,
1.142 + "{{\nfoo\n}}", "foo",
1.143 + "foo", "foo",
1.144 + NULL);
1.145 }
1.146
1.147 /******************************************************************************