diff --git a/regex/re_test.go b/regex/re_test.go index 1ce9136..8d24304 100644 --- a/regex/re_test.go +++ b/regex/re_test.go @@ -105,6 +105,9 @@ var reTests = []struct { {"(a|b){3,4}", nil, "ababaa", []Group{{0, 4}}}, {"(bc){5,}", nil, "bcbcbcbcbcbcbcbc", []Group{{0, 16}}}, {`\d{3,4}`, nil, "1209", []Group{{0, 4}}}, + {`\d{3,4}`, nil, "120", []Group{{0, 3}}}, + {`\d{3,4}`, nil, "12709", []Group{{0, 4}}}, + {`\d{3,4}`, nil, "12", []Group{}}, {`\d{3,4}`, nil, "109", []Group{{0, 3}}}, {`\d{3,4}`, nil, "5", []Group{}}, {`\d{3,4}`, nil, "123135", []Group{{0, 4}}}, @@ -671,6 +674,17 @@ var groupTests = []struct { {`^([ab]*)(?)`, nil, `391`, []Match{[]Group{{0, 3}, {0, 3}}}}, + + // // Tests from https://wiki.haskell.org/Regex_Posix + // {`(()|.)(b)`, nil, `ab`, []Match{[]Group{{0, 2}, {0, 1}, {-1, -1}, {1, 2}}}}, + // {`(()|[ab])(b)`, nil, `ab`, []Match{[]Group{{0, 2}, {0, 1}, {-1, -1}, {1, 2}}}}, + // {`(()|[ab])+b`, nil, `aaab`, []Match{[]Group{{0, 4}, {2, 3}, {-1, -1}}}}, + // {`([ab]|())+b`, nil, `aaab`, []Match{[]Group{{0, 4}, {2, 3}, {-1, -1}}}}, + // // Bug - this should give {0,6},{3,6},{-1,-1} but it gives {0,6},{3,6},{3,3} + // // {`yyyyyy`, nil, `(yyy|(x?)){2,4}`, []Match{[]Group{{0, 6}, {3, 6}, {-1, -1}}, []Group{{6, 6}, {6, 6}, {6, 6}}}}, + // {`(a|ab|c|bcd)*(d*)`, nil, `ababcd`, []Match{[]Group{{0, 6}, {3, 6}, {6, 6}}, []Group{{6, 6}, {6, 6}, {6, 6}}}}, + // // Bug - this should give {0,3},{0,3},{0,0},{0,3},{3,3} but it gives {0,3},{0,2},{0,1},{1,2},{2,3} + // // {`((a*)(b|abc))(c*)`, nil, `abc`, []Match{[]Group{{0, 3}, {0, 3}, {0, 0}, {0, 3}, {3, 3}}}}, } func TestFind(t *testing.T) {