Commits

Matt Bone  committed df25c80

println thing converted to tests

  • Participants
  • Parent commits f640e0b

Comments (0)

Files changed (2)

File regex/regex_driver.c

 #include "regex.h"
 
 int main(void) {
-  printf("%d\n", match("fuck", "fuck"));
-  printf("%d\n", match("fu.k", "fuck"));
-  printf("%d\n", match("fu.k", "fukk"));
-  printf("%d\n", match("^fu.k$", "fukk"));
-  printf("%d\n", match("^fu.k$", "fucka"));
-  printf("%d\n", match("^fu.k", "fucka"));
-
   printf("Hello, World.\n");
   return 1;
 }

File regex/regex_test.c

-#include<stdio.h>
-#include<glib.h>
+#include <stdio.h>
+#include <glib.h>
+#include "regex.h"
 
-void test_simple() {
-    g_assert_cmpint(1, ==, 1);
+/**
+ * TODO create two testing macros:
+ *   - is_match
+ *   - is_not_match
+ * 
+ * To make this shinier.
+ */
+
+void test_straight_match() {
+  g_assert(match("fuck", "fuck"));
 }
 
+
+void test_dot_match() {
+  g_assert(match("fu.k", "fuck"));
+  g_assert(match("fu.k", "fukk"));
+}
+
+
+void test_end_of_line() {
+  g_assert(match("^fu.k$", "fukk"));
+  g_assert(!match("^fu.k$", "fucka"));
+}
+
+
+void test_start_of_line() {
+  g_assert(match("^fu.k", "fucka"));
+}
+
+
 int main(int argc, char *argv[]) {
   g_test_init(&argc, &argv, NULL);
 
-  g_test_add_func("/simple/Let's see if this works", test_simple);
+  g_test_add_func("/regex/straight_match", test_straight_match);
+  g_test_add_func("/regex/dot_match", test_dot_match);
+  g_test_add_func("/regex/end_of_line", test_end_of_line);
+  g_test_add_func("/regex/start_of_line", test_start_of_line);
 
   return g_test_run();
 }