Browse Source

Add unit test for parser

Andrew Young 8 years ago
parent
commit
af31542404
3 changed files with 42 additions and 0 deletions
  1. 8 0
      tests/Makefile.am
  2. 0 0
      tests/README
  3. 34 0
      tests/check_parser.c

+ 8 - 0
tests/Makefile.am

@@ -0,0 +1,8 @@
+## Process this file with automake to produce Makefile.in
+TESTS = check_parser
+check_PROGRAMS = check_parser
+
+## Check Parser
+check_parser_SOURCES = check_parser.c
+check_parser_CFLAGS = @CHECK_CFLAGS@
+check_parser_LDADD = @CHECK_LIBS@

+ 0 - 0
tests/README


+ 34 - 0
tests/check_parser.c

@@ -0,0 +1,34 @@
+#include <stdlib.h>
+#include <check.h>
+
+START_TEST (parser_check)
+{
+  fail_if (1 > 2);
+}
+END_TEST
+
+Suite *
+parser_suite (void)
+{
+  Suite *s = suite_create ("Parsing");
+  /* Core test case */
+  TCase *tc_core = tcase_create ("Core");
+  tcase_add_test (tc_core, parser_check);
+  suite_add_tcase (s, tc_core);
+  return s;
+}
+
+int
+main (void)
+{
+  int number_failed;
+  Suite *s = parser_suite ();
+  SRunner *sr = srunner_create (s);
+  srunner_run_all (sr, CK_NORMAL);
+  number_failed = srunner_ntests_failed (sr);
+  srunner_free (sr);
+
+  return (number_failed == 0) 
+    ? EXIT_SUCCESS 
+    : EXIT_FAILURE;
+}