updated the variable tag tests to use a variadic function to do the heavy lifting to avoid code duplication and wasted effort and so on
1 #include <gplate/gplate.h>
5 #include "gplate-tag-test.h"
7 /******************************************************************************
9 *****************************************************************************/
11 gplate_variable_tag_test(GPlateTagTestFixture *fixture, gconstpointer data,
12 const gchar *template_string, const gchar *expected,
16 const gchar *name = NULL, *value = NULL;
18 fixture->template_string = template_string;
19 fixture->expected = expected;
21 va_start(vargs, expected);
22 while((name = va_arg(vargs, const gchar *))) {
23 value = va_arg(vargs, const gchar *);
25 gplate_collection_add_string(GPLATE_COLLECTION(fixture->template),
31 gplate_tag_test_output(fixture, data);
34 /******************************************************************************
36 *****************************************************************************/
38 gplate_variable_tag_test_single(GPlateTagTestFixture *fixture,
41 gplate_variable_tag_test(fixture, data,
48 gplate_variable_tag_test_double(GPlateTagTestFixture *fixture,
51 gplate_variable_tag_test(fixture, data,
52 "{{ foo }}{{ bar }}", "foobar",
59 gplate_variable_tag_test_tripple(GPlateTagTestFixture *fixture,
62 gplate_variable_tag_test(fixture, data,
63 "{{ foo }}{{ bar }}{{ baz }}", "foobarbaz",
71 gplate_variable_tag_test_newline_prefix(GPlateTagTestFixture *fixture,
74 gplate_variable_tag_test(fixture, data,
81 gplate_variable_tag_test_newline_suffix(GPlateTagTestFixture *fixture,
84 gplate_variable_tag_test(fixture, data,
91 gplate_variable_tag_test_newline_wrapped(GPlateTagTestFixture *fixture,
94 gplate_variable_tag_test(fixture, data,
100 /******************************************************************************
102 *****************************************************************************/
104 main(gint argc, gchar **argv) {
105 g_test_init(&argc, &argv, NULL);
109 gplate_config_load_default();
111 gplate_tag_test_add("/tags/variable/single",
112 gplate_variable_tag_test_single);
114 gplate_tag_test_add("/tags/variable/double",
115 gplate_variable_tag_test_double);
117 gplate_tag_test_add("/tags/variable/tripple",
118 gplate_variable_tag_test_tripple);
120 gplate_tag_test_add("/tags/variable/newline_prefix",
121 gplate_variable_tag_test_newline_prefix);
123 gplate_tag_test_add("/tags/variable/newline_suffix",
124 gplate_variable_tag_test_newline_suffix);
126 gplate_tag_test_add("/tags/variable/newline_wrapped",
127 gplate_variable_tag_test_newline_wrapped);