tests: Add a test of running 'ls --version' and matching the output.
[miniexpect.git] / tests.h
diff --git a/tests.h b/tests.h
index e258782..e9b19f3 100644 (file)
--- a/tests.h
+++ b/tests.h
@@ -39,4 +39,20 @@ test_diagnose (int status)
     fprintf (stderr, "stopped by signal %d", WSTOPSIG (status));
 }
 
+static pcre *
+test_compile_re (const char *rex)
+{
+  const char *errptr;
+  int erroffset;
+  pcre *ret;
+
+  ret = pcre_compile (rex, 0, &errptr, &erroffset, NULL);
+  if (ret == NULL) {
+    fprintf (stderr, "error: failed to compile regular expression '%s': %s at offset %d\n",
+             rex, errptr, erroffset);
+    exit (EXIT_FAILURE);
+  }
+  return ret;
+}
+
 #endif /* TESTS_H_ */