grim/gplate

Parents 5b365cf2b4e2
Children c3bc9bb574d6
make test-variables actually work. We're not checking floats and doubles right now, but thats not a big deal at the moment. To do it, we'll need to use a union or something in the fixture...
--- a/tests/Makefile.am Sun Nov 15 00:24:16 2009 -0600
+++ b/tests/Makefile.am Sun Nov 15 00:25:30 2009 -0600
@@ -1,45 +1,33 @@
-EXTRA_DIST=\
- check.xsl \
- test.h \
- test-collection.h \
- test-object.h
+EXTRA_DIST =
SUBDIRS=templates
-CLEANFILES=
-
-TESTS=test
-
-check_PROGRAMS=test
-
-LDADDS=\
+LDADDS = \
$(top_builddir)/gplate/libgplate.la \
- $(CHECK_LIBS) \
$(GLIB_LIBS)
-INCLUDES=\
- -I$(top_srcdir)
+INCLUDES = \
+ -I$(top_srcdir) \
+ -I$(top_builddir)/gplate/
-test_LDADD=$(LDADDS)
-test_SOURCES=\
- test.c \
- test-collection.c \
- test-dictionary-variable.c \
- test-file-variable.c \
- test-for-function.c \
- test-include.c \
- test-object.c \
- test-syntax.c \
- test-util.c \
- test-variables.c
+noinst_PROGRAMS = \
+ test-variables
+
+TEST_PROGS =
+
+TEST_PROGS += test-variables
+test_variables_SOURCES = test-variables.c
+test_variables_LDADD = $(LDADDS)
AM_CPPFLAGS=\
- $(CHECK_CFLAGS) \
- $(GLIB_CFLAGS)
+ $(DEBUG_CFLAGS) \
+ $(GLIB_CFLAGS) \
+ $(INCLUDES)
-CLEANFILES +=\
- *.gcda \
- *.gcno \
- $(test_SOURCES:%=%.gcov.html) \
- index.html
+test: $(TEST_PROGS)
+ @test -z "$(TEST_PROGS)" || gtester --verbose $(TEST_PROGS)
+.PHONY: test
+
+check-local: test
+
--- a/tests/test-variables.c Sun Nov 15 00:24:16 2009 -0600
+++ b/tests/test-variables.c Sun Nov 15 00:25:30 2009 -0600
@@ -2,111 +2,8 @@
# include <config.h>
#endif /* HAVE_CONFIG_H */
-#include <check.h>
-
#include <gplate/gplate.h>
-#include "test.h"
-
-/******************************************************************************
- * Simple Variables
- *****************************************************************************/
-static void
-test_variable(GPlateVariable *var, const gchar *name, const gchar *value) {
- const gchar *n = NULL;
- const gchar *v = NULL;
-
- fail_unless(GPLATE_IS_VARIABLE(var), "'%p' is not a GPlateVariable.", var);
-
- n = gplate_variable_get_name(var);
- test_string(n, name);
-
- v = gplate_variable_get_value(var);
- test_string(v, value);
-}
-
-START_TEST(test_variable_string_empty_name)
- GPlateVariable *var = gplate_variable_new_from_string("", "baz");
-
- test_variable(var, "", "baz");
-END_TEST
-
-START_TEST(test_variable_float_negative)
- GPlateVariable *var = gplate_variable_new_from_float("f1", -3.14f);
-
- test_variable(var, "f1", "-3.140000");
-END_TEST
-
-START_TEST(test_variable_float_positive)
- GPlateVariable *var = gplate_variable_new_from_float("f2", 3.14f);
-
- test_variable(var, "f2", "3.140000");
-END_TEST
-
-START_TEST(test_variable_float_negative_whole)
- GPlateVariable *var = gplate_variable_new_from_float("f3", -1234.0f);
-
- test_variable(var, "f3", "-1234.000000");
-END_TEST
-
-START_TEST(test_variable_float_positive_whole)
- GPlateVariable *var = gplate_variable_new_from_float("f4", 1234.0f);
-
- test_variable(var, "f4", "1234.000000");
-END_TEST
-
-START_TEST(test_variable_double_negative)
- GPlateVariable *var = gplate_variable_new_from_double("d1", -3.14);
-
- test_variable(var, "d1", "-3.14");
-END_TEST
-
-START_TEST(test_variable_double_positive)
- GPlateVariable *var = gplate_variable_new_from_double("d2", 3.14);
-
- test_variable(var, "d2", "3.14");
-END_TEST
-
-START_TEST(test_variable_double_negative_whole)
- GPlateVariable *var = gplate_variable_new_from_double("d3", -1234.0);
-
- test_variable(var, "d3", "-1234");
-END_TEST
-
-START_TEST(test_variable_double_positive_whole)
- GPlateVariable *var = gplate_variable_new_from_double("d4", 1234.0);
-
- test_variable(var, "d4", "1234");
-END_TEST
-
-/******************************************************************************
- * API
- *****************************************************************************/
-Suite *
-variable_suite(void) {
- Suite *s = suite_create("Variable Suite");
- TCase *tc = NULL;
-
- tc = tcase_create("Simple Variables");
- tcase_add_test(tc, test_variable_string_empty_name);
- tcase_add_test(tc, test_variable_string);
- tcase_add_test(tc, test_variable_boolean_true);
- tcase_add_test(tc, test_variable_boolean_false);
- tcase_add_test(tc, test_variable_int_negative);
- tcase_add_test(tc, test_variable_int_positive);
- tcase_add_test(tc, test_variable_float_negative);
- tcase_add_test(tc, test_variable_float_positive);
- tcase_add_test(tc, test_variable_float_negative_whole);
- tcase_add_test(tc, test_variable_float_positive_whole);
- tcase_add_test(tc, test_variable_double_negative);
- tcase_add_test(tc, test_variable_double_positive);
- tcase_add_test(tc, test_variable_double_negative_whole);
- tcase_add_test(tc, test_variable_double_positive_whole);
- suite_add_tcase(s, tc);
-
- return s;
-}
-
/******************************************************************************
* Fixtures
*****************************************************************************/
@@ -168,6 +65,8 @@
*****************************************************************************/
gint
main(gint argc, gchar **argv) {
+ g_type_init();
+
g_test_init(&argc, &argv, NULL);
/* string tests */