diff tests.c @ 666:e1d27caf0dbd

More work on regex stuff.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 27 Jan 2020 12:43:39 +0200
parents c5aa9ada1051
children 48e8820bc625
line wrap: on
line diff
--- a/tests.c	Mon Jan 27 07:51:07 2020 +0200
+++ b/tests.c	Mon Jan 27 12:43:39 2020 +0200
@@ -603,7 +603,7 @@
     th_regex_t *expr = NULL;
     int res;
 
-    printf("========================================\n");
+    printf("\n========================================\n\n");
     printf("Compiling pattern \"%s\"\n", pattern);
     if ((res = th_regex_compile(&expr, pattern)) != THERR_OK)
     {
@@ -620,7 +620,7 @@
         th_regex_match_t *matches = NULL;
         size_t nmatches;
 
-        printf("----------------------------------------\n");
+        printf("\n----------------------------------------\n");
         if ((res = th_regex_match(expr, def->str,
             &nmatches, &matches, -1, def->flags)) != THERR_OK)
         {
@@ -645,7 +645,7 @@
 
 void test_regex_list2(const test_regex_def2 *list)
 {
-    printf("========================================\n");
+    printf("\n========================================\n\n");
 
     for (const test_regex_def2 *def = list; def->str != NULL; def++)
     {
@@ -959,21 +959,23 @@
             const char *str = "z*k+abba fabboa? [a-zA-Z_-] \\{\\} k{4} ([0-9]+ yay){1,2} foo(bar|zoo)?";
             th_regex_t *expr = NULL;
             int res = th_regex_compile(&expr, str);
+
             printf("REGEX: \"%s\"\n", str);
+
             if (res == THERR_OK)
                 th_regex_dump(&testio, 1, expr);
             else
                 printf("ERROR: %s\n", th_error_str(res));
+
             th_regex_free(expr);
         }
 
-#if 0
         {
             static const test_regex_def1 tlist[] =
             {
-                { "abcfoabccg"                   , 1, 0 },
-                { "abcbcfoabccg"                 , 1, 0 },
-                { "abcbcfoabccgabcbcfoabccg"     , 2, 0 },
+                { "abcfoabcccg"                  , 1, 0 },
+                { "abcbcfoabcccg"                , 1, 0 },
+                { "abcbcfoabccg abcbcfoabccccg"  , 2, 0 },
                 { "ffdsafS abcbcfoabccg zasdf"   , 1, 0 },
                 { NULL                           , 0, 0 }
             };
@@ -986,7 +988,7 @@
             {
                 { "abcfoabccg"                   , 1, 0 },
                 { "abcbcfoabccg"                 , 1, 0 },
-                { "abcbcfoabccgabcbcfoabccg"     , 2, 0 },
+                { "abcbcfoabccgabcbcfoabccg"     , 1, 0 },
                 { "ffdsafS abcbcfoabccg zasdf"   , 0, 0 },
                 { NULL                           , 0, 0 }
             };
@@ -1006,7 +1008,6 @@
 
             test_regex_list1(tlist, "g$");
         }
-#endif
 
         {
             static const test_regex_def1 tlist[] =
@@ -1019,7 +1020,7 @@
             };
 
             test_regex_list1(tlist, "zoo.*?bar");
-//            test_regex_list(tlist, "zoo.*?bar");
+            test_regex_list1(tlist, "zoo.*bar");
         }
     }
 #endif