grim/gplate

I thought I already added this.. my bad
trying_to_get_includes_working
2008-02-20, grim
545b7214a0de
Parents da0a56092894
Children e306293dcbb0
I thought I already added this.. my bad
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_include.c Wed Feb 20 01:44:53 2008 -0600
@@ -0,0 +1,89 @@
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <check.h>
+
+#include <stdio.h>
+#include <string.h>
+
+#include <gplate/gplate.h>
+
+#include "test.h"
+
+/******************************************************************************
+ * Globals
+ *****************************************************************************/
+static GPlateTemplate *tplate = NULL;
+static GError *error = NULL;
+static gchar *msg = NULL;
+
+/******************************************************************************
+ * Fixtures
+ *****************************************************************************/
+static void
+simple_setup(void) {
+ tplate = gplate_template_new();
+}
+
+static void
+simple_teardown(void) {
+ g_object_unref(G_OBJECT(tplate));
+
+ tplate = NULL;
+
+ if(error)
+ g_error_free(error);
+ error = NULL;
+
+ g_free(msg);
+ msg = NULL;
+}
+
+/******************************************************************************
+ * Simple Includes
+ *****************************************************************************/
+START_TEST(test_include_simple_static)
+ gchar *output = NULL, *e1 = NULL, *e2 = NULL;
+ const gchar *expected =
+ "before the include\n"
+ "inside the included file\n\n"
+ "after the include\n"
+ "\n";
+ gint r = 0;
+
+ output = gplate_template_render_file(tplate, "templates/simple.gplate",
+ &error);
+
+ fail_unless(error == NULL,
+ (error && error->message) ? error->message : "Unknown failed");
+
+ r = g_utf8_collate(output, expected);
+
+ e1 = g_strescape(output, NULL);
+ e2 = g_strescape(expected, NULL);
+ msg = g_strdup_printf("\ngot: '%s'\nwanted: '%s'\n", e1, e2);
+
+ g_free(output);
+ g_free(e1);
+ g_free(e2);
+
+ fail_unless(r == 0, msg);
+END_TEST
+
+/******************************************************************************
+ * Exported
+ *****************************************************************************/
+Suite *
+include_suite(void) {
+ Suite *s = suite_create("Include Function Suite");
+ TCase *tc = NULL;
+
+ tc = tcase_create("Simple Includes");
+ tcase_add_checked_fixture(tc, simple_setup, simple_teardown);
+ tcase_add_test(tc, test_include_simple_static);
+ suite_add_tcase(s, tc);
+
+ return s;
+}
+