test: slre: add more test cases
authorRasmus Villemoes <ravi@prevas.dk>
Tue, 13 May 2025 08:40:27 +0000 (10:40 +0200)
committerTom Rini <trini@konsulko.com>
Thu, 29 May 2025 14:25:18 +0000 (08:25 -0600)
Add some tests for the "drop wrong anchored optimization". Without
the previous commit, the first, fifth and seventh of these would fail,
i.e. those:

{ "xby", "^a|b", 1},
{ "", "x*$", 1},
{ "yy", "x*$", 1},

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Rasmus Villemoes <ravi@prevas.dk>
test/lib/slre.c

index 51a50b2..b76d334 100644 (file)
@@ -15,6 +15,14 @@ static const struct re_test re_test[] = {
        { "x23", "^\\d+$", 0},
        { "banana", "^([bn]a)*$", 1},
        { "panama", "^([bn]a)*$", 0},
+       { "xby", "^a|b", 1},
+       { "xby", "b|^a", 1},
+       { "xby", "b|c$", 1},
+       { "xby", "c$|b", 1},
+       { "", "x*$", 1},
+       { "", "^x*$", 1},
+       { "yy", "x*$", 1},
+       { "yy", "^x*$", 0},
        {}
 };