finally got all of the tests in here moved to the new format
authorGary Kramlich <grim@reaperworld.com>
Sun Jul 04 15:35:33 2010 -0500 (19 months ago)
changeset 404ce6fd664bf5d
parent 403 13b5031b2846
child 405 b90b9411363f
finally got all of the tests in here moved to the new format

refs #16
tests/test-syntax.c
     1.1 --- a/tests/test-syntax.c	Sun Jul 04 15:34:45 2010 -0500
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,212 +0,0 @@
     1.4 -#ifdef HAVE_CONFIG_H
     1.5 -# include <config.h>
     1.6 -#endif /* HAVE_CONFIG_H */
     1.7 -
     1.8 -#include <check.h>
     1.9 -
    1.10 -#include <stdio.h>
    1.11 -#include <string.h>
    1.12 -
    1.13 -#include <gplate/gplate.h>
    1.14 -
    1.15 -#include "test.h"
    1.16 -
    1.17 -#define OUTPUT_TEST(tplate, input, output) { \
    1.18 -	gchar *o = NULL, *msg = NULL; \
    1.19 -	\
    1.20 -	o = gplate_template_render(tplate, input, NULL); \
    1.21 -	\
    1.22 -	msg = g_strdup_printf("\ngot:    '%s'\nwanted: '%s'\n", \
    1.23 -						  g_strescape(o, NULL), g_strescape(output, NULL)); \
    1.24 -	\
    1.25 -	fail_unless(g_ascii_strcasecmp(o, output) == 0, msg); \
    1.26 -}
    1.27 -
    1.28 -#define SIMPLE_OUTPUT_TEST(input, output) { \
    1.29 -	GPlateTemplate *tplate = gplate_template_new(); \
    1.30 -	OUTPUT_TEST(tplate, input, output); \
    1.31 -}
    1.32 -
    1.33 -/******************************************************************************
    1.34 - * Text Tags
    1.35 - *****************************************************************************/
    1.36 -START_TEST(test_syntax_no_keywords_no_variables)
    1.37 -	SIMPLE_OUTPUT_TEST("simple template",
    1.38 -					   "simple template");
    1.39 -END_TEST
    1.40 -
    1.41 -START_TEST(test_syntax_keywords_no_subst)
    1.42 -	SIMPLE_OUTPUT_TEST("extends if else endif for endfor",
    1.43 -					   "extends if else endif for endfor");
    1.44 -END_TEST
    1.45 -
    1.46 -START_TEST(test_syntax_keywords_no_subst_case)
    1.47 -	SIMPLE_OUTPUT_TEST("EXteNds iF eLse enDif fOr enDFor",
    1.48 -					   "EXteNds iF eLse enDif fOr enDFor");
    1.49 -END_TEST
    1.50 -
    1.51 -/******************************************************************************
    1.52 - * Variable Tags
    1.53 - *****************************************************************************/
    1.54 -START_TEST(test_syntax_one_var)
    1.55 -	GPlateTemplate *tplate = gplate_template_new();
    1.56 -
    1.57 -	gplate_collection_add_integer(tplate, "two", 2);
    1.58 -
    1.59 -	OUTPUT_TEST(tplate, "one {{ two }} three", "one 2 three");
    1.60 -END_TEST
    1.61 -
    1.62 -START_TEST(test_variable_newline_prefix)
    1.63 -	GPlateTemplate *tplate = gplate_template_new();
    1.64 -	
    1.65 -	gplate_collection_add_string(tplate, "bar", "|");
    1.66 -
    1.67 -	OUTPUT_TEST(tplate, "{{\nbar}}", "|");
    1.68 -END_TEST
    1.69 -
    1.70 -START_TEST(test_variable_newline_suffix)
    1.71 -	GPlateTemplate *tplate = gplate_template_new();
    1.72 -
    1.73 -	gplate_collection_add_string(tplate, "bar", "|");
    1.74 -
    1.75 -	OUTPUT_TEST(tplate, "{{bar\n}}", "|");
    1.76 -END_TEST
    1.77 -
    1.78 -START_TEST(test_variable_newline_wrapped)
    1.79 -	GPlateTemplate *tplate = gplate_template_new();
    1.80 -
    1.81 -	gplate_collection_add_string(tplate, "bar", "|");
    1.82 -
    1.83 -	OUTPUT_TEST(tplate, "{{\nbar\n}}", "|");
    1.84 -END_TEST
    1.85 -
    1.86 -START_TEST(test_syntax_var_in_single_quotes)
    1.87 -	GPlateTemplate *tplate = gplate_template_new();
    1.88 -
    1.89 -	gplate_collection_add_string(tplate, "quoted", "in quotes");
    1.90 -
    1.91 -	OUTPUT_TEST(tplate, "abc '{{ quoted }}' xyz", "abc 'in quotes' xyz");
    1.92 -END_TEST
    1.93 -
    1.94 -START_TEST(test_syntax_var_in_double_quotes)
    1.95 -	GPlateTemplate *tplate = gplate_template_new();
    1.96 -
    1.97 -	gplate_collection_add_string(tplate, "quoted", "in quotes");
    1.98 -
    1.99 -	OUTPUT_TEST(tplate, "abc \"{{ quoted }}\" xyz", "abc \"in quotes\" xyz");
   1.100 -END_TEST
   1.101 -
   1.102 -START_TEST(test_syntax_var_in_anchor_tag)
   1.103 -	GPlateTemplate *tplate = gplate_template_new();
   1.104 -
   1.105 -	gplate_collection_add_string(tplate, "href", "http://guifications.org");
   1.106 -
   1.107 -	OUTPUT_TEST(tplate,
   1.108 -				"<a href=\"{{ href }}\">{{ href }}</a>",
   1.109 -				"<a href=\"http://guifications.org\">http://guifications.org</a>");
   1.110 -END_TEST
   1.111 -
   1.112 -START_TEST(test_syntax_two_vars_one_block)
   1.113 -	GPlateTemplate *tplate = gplate_template_new();
   1.114 -
   1.115 -	gplate_collection_add_integer(tplate, "two", 2);
   1.116 -	gplate_collection_add_integer(tplate, "three", 3);
   1.117 -
   1.118 -	OUTPUT_TEST(tplate, "one {{ two three }} four", "one 2 four");
   1.119 -END_TEST
   1.120 -
   1.121 -START_TEST(test_syntax_one_var_nested)
   1.122 -	GPlateTemplate *tplate = gplate_template_new();
   1.123 -	GPlateVariable *dict = NULL;
   1.124 -
   1.125 -	dict = gplate_dictionary_variable_new("two");
   1.126 -	gplate_collection_add_variable(GPLATE_COLLECTION(tplate), dict);
   1.127 -
   1.128 -	gplate_collection_add_integer(dict, "too", 2);
   1.129 -
   1.130 -	OUTPUT_TEST(tplate, "one {{ two.too }} three", "one 2 three");
   1.131 -END_TEST
   1.132 -
   1.133 -START_TEST(test_syntax_one_var_double_nested)
   1.134 -	GPlateTemplate *tplate = gplate_template_new();
   1.135 -	GPlateVariable *dict1 = NULL, *dict2 = NULL;
   1.136 -
   1.137 -	dict1 = gplate_dictionary_variable_new("one");
   1.138 -	gplate_collection_add_variable(GPLATE_COLLECTION(tplate), dict1);
   1.139 -
   1.140 -	dict2 = gplate_dictionary_variable_new("two");
   1.141 -	gplate_collection_add_variable(GPLATE_COLLECTION(dict1), dict2);
   1.142 -
   1.143 -	gplate_collection_add_string(dict2, "five", "three sir!");
   1.144 -
   1.145 -	OUTPUT_TEST(tplate,
   1.146 -				"one, two, five! {{ one.two.five }}",
   1.147 -				"one, two, five! three sir!");
   1.148 -END_TEST
   1.149 -
   1.150 -/******************************************************************************
   1.151 - * Comment Tags
   1.152 - *****************************************************************************/
   1.153 -START_TEST(test_comment_empty)
   1.154 -	SIMPLE_OUTPUT_TEST("{##}", "");
   1.155 -END_TEST
   1.156 -
   1.157 -START_TEST(test_comment_simple)
   1.158 -	SIMPLE_OUTPUT_TEST("{#simple#}", "");
   1.159 -END_TEST
   1.160 -
   1.161 -START_TEST(test_comment_simple_with_whitespace)
   1.162 -	SIMPLE_OUTPUT_TEST("{# simple #}", "");
   1.163 -END_TEST
   1.164 -
   1.165 -START_TEST(test_comment_newline_prefix)
   1.166 -	SIMPLE_OUTPUT_TEST("{#\n1#}", "");
   1.167 -END_TEST
   1.168 -
   1.169 -START_TEST(test_comment_newline_suffix)
   1.170 -	SIMPLE_OUTPUT_TEST("{#1\n#}", "");
   1.171 -END_TEST
   1.172 -
   1.173 -START_TEST(test_comment_newline_wrapped)
   1.174 -	SIMPLE_OUTPUT_TEST("{#\n1\n#}", "");
   1.175 -END_TEST
   1.176 -
   1.177 -/******************************************************************************
   1.178 - * Exported
   1.179 - *****************************************************************************/
   1.180 -Suite *
   1.181 -syntax_suite(void) {
   1.182 -	Suite *s = suite_create("Tag Suite");
   1.183 -	TCase *tc = NULL;
   1.184 -
   1.185 -	tc = tcase_create("Text Tag");
   1.186 -	tcase_add_test(tc, test_syntax_no_keywords_no_variables);
   1.187 -	tcase_add_test(tc, test_syntax_keywords_no_subst);
   1.188 -	tcase_add_test(tc, test_syntax_keywords_no_subst_case);
   1.189 -	suite_add_tcase(s, tc);
   1.190 -	
   1.191 -	tc = tcase_create("Variable Tag");
   1.192 -	tcase_add_test(tc, test_syntax_one_var);
   1.193 -	tcase_add_test(tc, test_variable_newline_prefix);
   1.194 -	tcase_add_test(tc, test_variable_newline_suffix);
   1.195 -	tcase_add_test(tc, test_variable_newline_wrapped);
   1.196 -	tcase_add_test(tc, test_syntax_var_in_single_quotes);
   1.197 -	tcase_add_test(tc, test_syntax_var_in_double_quotes);
   1.198 -	tcase_add_test(tc, test_syntax_var_in_anchor_tag);
   1.199 -	tcase_add_test(tc, test_syntax_two_vars_one_block);
   1.200 -	tcase_add_test(tc, test_syntax_one_var_nested);
   1.201 -	tcase_add_test(tc, test_syntax_one_var_double_nested);
   1.202 -	suite_add_tcase(s, tc);
   1.203 -
   1.204 -	tc = tcase_create("Comment Tag");
   1.205 -	tcase_add_test(tc, test_comment_empty);
   1.206 -	tcase_add_test(tc, test_comment_simple);
   1.207 -	tcase_add_test(tc, test_comment_simple_with_whitespace);
   1.208 -	tcase_add_test(tc, test_comment_newline_prefix);
   1.209 -	tcase_add_test(tc, test_comment_newline_suffix);
   1.210 -	tcase_add_test(tc, test_comment_newline_wrapped);
   1.211 -	suite_add_tcase(s, tc);
   1.212 -
   1.213 -	return s;
   1.214 -}
   1.215 -