tests/test-include.c
changeset 405 b90b9411363f
parent 404 ce6fd664bf5d
child 406 9b903d04907a
     1.1 --- a/tests/test-include.c	Sun Jul 04 15:35:33 2010 -0500
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,122 +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 -/******************************************************************************
    1.18 - * Globals
    1.19 - *****************************************************************************/
    1.20 -static GPlateTemplate *tplate = NULL;
    1.21 -static GError *error = NULL;
    1.22 -static gchar *msg = NULL;
    1.23 -
    1.24 -/******************************************************************************
    1.25 - * Fixtures
    1.26 - *****************************************************************************/
    1.27 -static void
    1.28 -simple_setup(void) {
    1.29 -	tplate = gplate_template_new();
    1.30 -}
    1.31 -
    1.32 -static void
    1.33 -simple_teardown(void) {
    1.34 -	g_object_unref(G_OBJECT(tplate));
    1.35 -
    1.36 -	tplate = NULL;
    1.37 -
    1.38 -	if(error)
    1.39 -		g_error_free(error);
    1.40 -	error = NULL;
    1.41 -
    1.42 -	g_free(msg);
    1.43 -	msg = NULL;
    1.44 -}
    1.45 -
    1.46 -/******************************************************************************
    1.47 - * Simple Includes
    1.48 - *****************************************************************************/
    1.49 -START_TEST(test_include_simple_static)
    1.50 -	gchar *output = NULL, *e1 = NULL, *e2 = NULL;
    1.51 -	const gchar *expected =
    1.52 -		"before the include\n"
    1.53 -		"inside the included file\n\n"
    1.54 -		"after the include\n"
    1.55 -		"\n";
    1.56 -	gint r = 0;
    1.57 -	
    1.58 -	output = gplate_template_render_file(tplate, "templates/simple.gplate",
    1.59 -										 &error);
    1.60 -
    1.61 -	fail_unless(error == NULL,
    1.62 -				(error && error->message) ? error->message : "Unknown failed");
    1.63 -
    1.64 -	r = g_utf8_collate(output, expected);
    1.65 -
    1.66 -	e1 = g_strescape(output, NULL);
    1.67 -	e2 = g_strescape(expected, NULL);
    1.68 -	msg = g_strdup_printf("\ngot:    '%s'\nwanted: '%s'\n", e1, e2);
    1.69 -
    1.70 -	g_free(output);
    1.71 -	g_free(e1);
    1.72 -	g_free(e2);
    1.73 -
    1.74 -	fail_unless(r == 0, msg);
    1.75 -END_TEST
    1.76 -
    1.77 -START_TEST(test_include_html_header_footer)
    1.78 -	gchar *output = NULL, *e1 = NULL, *e2 = NULL;
    1.79 -	const gchar *expected =
    1.80 -		"<html>\n"
    1.81 -		"\t<head>\n"
    1.82 -		"\t\t<title>test</title>\n"
    1.83 -		"\t</head>\n"
    1.84 -		"\t<body>\n"
    1.85 -		"in the body"
    1.86 -		"\t</body>\n"
    1.87 -		"</html>\n\n";
    1.88 -	gint r = 0;
    1.89 -
    1.90 -	output = gplate_template_render_file(tplate, "templates/html.gplate",
    1.91 -										 &error);
    1.92 -
    1.93 -	fail_unless(error == NULL,
    1.94 -				(error && error->message) ? error->message : "Unknown failure");
    1.95 -
    1.96 -	r = g_utf8_collate(output, expected);
    1.97 -
    1.98 -	e1 = g_strescape(output, NULL);
    1.99 -	e2 = g_strescape(expected, NULL);
   1.100 -	msg = g_strdup_printf("\ngot:    '%s'\nwanted: '%s'\n", e1, e2);
   1.101 -
   1.102 -	g_free(output);
   1.103 -	g_free(e1);
   1.104 -	g_free(e2);
   1.105 -
   1.106 -	fail_unless(r == 0, msg);
   1.107 -END_TEST
   1.108 -
   1.109 -/******************************************************************************
   1.110 - * Exported
   1.111 - *****************************************************************************/
   1.112 -Suite *
   1.113 -include_suite(void) {
   1.114 -	Suite *s = suite_create("Include Function Suite");
   1.115 -	TCase *tc = NULL;
   1.116 -
   1.117 -	tc = tcase_create("Simple Includes");
   1.118 -	tcase_add_checked_fixture(tc, simple_setup, simple_teardown);
   1.119 -	tcase_add_test(tc, test_include_simple_static);
   1.120 -	tcase_add_test(tc, test_include_html_header_footer);
   1.121 -	suite_add_tcase(s, tc);
   1.122 -	
   1.123 -	return s;
   1.124 -}
   1.125 -