grim/gplate

13b5031b2846
Parents b9a2a060c766
Children ce6fd664bf5d
added a few more tests for gplate-variable-tag
--- a/gplate/tags/tests/test-gplate-variable-tag.c Sun Jul 04 03:40:27 2010 -0500
+++ b/gplate/tags/tests/test-gplate-variable-tag.c Sun Jul 04 15:34:45 2010 -0500
@@ -143,6 +143,47 @@
"bar", "bar",
NULL);
}
+
+static void
+test_gplate_variable_tag_two_vars_one_block(TestGPlateTagFixture *fixture,
+ gconstpointer data)
+{
+ test_gplate_variable_tag(fixture, data,
+ "one {{ two five }} three",
+ "one 2 three",
+ "two", "2",
+ "five", "5",
+ NULL);
+}
+
+static void
+test_gplate_variable_tag_nested_single(TestGPlateTagFixture *fixture,
+ gconstpointer data)
+{
+ GPlateVariable *dict = gplate_dictionary_variable_new("foo");
+
+ gplate_collection_add_string(GPLATE_COLLECTION(dict),
+ "bar", "baz");
+
+ test_gplate_tag_output(fixture, data, "{{ foo.bar }}", "baz");
+}
+
+static void
+test_gplate_variable_tag_nested_double(TestGPlateTagFixture *fixture,
+ gconstpointer data)
+{
+ GPlateVariable *dict1 = gplate_dictionary_variable_new("foo");
+ GPlateVariable *dict2 = gplate_dictionary_variable_new("bar");
+
+ gplate_collection_add_variable(GPLATE_COLLECTION(fixture->template),
+ dict1);
+ gplate_collection_add_variable(GPLATE_COLLECTION(dict1), dict2);
+ gplate_collection_add_string(GPLATE_COLLECTION(dict2),
+ "baz", "42");
+
+ test_gplate_tag_output(fixture, data, "{{ foo.bar.baz }}", "42");
+}
+
/******************************************************************************
* Main
*****************************************************************************/
@@ -181,6 +222,15 @@
test_gplate_tag_add("/tags/variable/quotes/mixed",
test_gplate_variable_tag_mixed_quotes);
+ test_gplate_tag_add("/tags/variable/two_vars_one_block",
+ test_gplate_variable_tag_two_vars_one_block);
+
+ test_gplate_tag_add("/tags/variables/nested/single",
+ test_gplate_variable_tag_nested_single);
+
+ test_gplate_tag_add("/tags/variable/nested/double",
+ test_gplate_variable_tag_nested_double);
+
return g_test_run();
}