diff --git a/re_test.go b/re_test.go index f60d778..bfcf160 100644 --- a/re_test.go +++ b/re_test.go @@ -21,9 +21,9 @@ var reTests = []struct { {"ab*", "abb", []matchIndex{{0, 3}}}, {"a*b", "aaab", []matchIndex{{0, 4}}}, {"a*b", "qwqw", []matchIndex{}}, - {"(abc)*", "abcabcabc", []matchIndex{{0, 9}}}, - {"((abc)|(def))*", "abcdef", []matchIndex{{0, 6}}}, - {"(abc)*|(def)*", "abcdef", []matchIndex{{0, 3}, {3, 3}, {3, 6}, {6, 6}}}, + {"(abc)*", "abcabcabc", []matchIndex{{0, 9}, {9, 9}}}, + {"((abc)|(def))*", "abcdef", []matchIndex{{0, 6}, {6, 6}}}, + {"(abc)*|(def)*", "abcdef", []matchIndex{{0, 3}, {3, 6}, {6, 6}}}, {"b*a*a", "bba", []matchIndex{{0, 3}}}, {"(ab)+", "abcabddd", []matchIndex{{0, 2}, {3, 5}}}, {"a(b(c|d)*)*", "abccbd", []matchIndex{{0, 6}}}, @@ -38,8 +38,8 @@ var reTests = []struct { {"a?b", "ab", []matchIndex{{0, 2}}}, {"a?", "", []matchIndex{{0, 0}}}, {"a?b?c", "a", []matchIndex{}}, - {"a?b?c?", "ab", []matchIndex{{0, 2}}}, - {"a?b?c?", "ac", []matchIndex{{0, 2}}}, + {"a?b?c?", "ab", []matchIndex{{0, 2}, {2, 2}}}, + {"a?b?c?", "ac", []matchIndex{{0, 2}, {2, 2}}}, {"a?b?c", "abc", []matchIndex{{0, 3}}}, {"a?b?c", "acb", []matchIndex{{0, 2}}}, @@ -49,7 +49,7 @@ var reTests = []struct { {"g[ab]c", "gbc", []matchIndex{{0, 3}}}, {"g[ab]c", "gc", []matchIndex{}}, {"g[ab]c", "gfc", []matchIndex{}}, - {"[ab]*", "aabbbabaababab", []matchIndex{{0, 14}}}, + {"[ab]*", "aabbbabaababab", []matchIndex{{0, 14}, {14, 14}}}, {"[ab]+", "aabbbablaababab", []matchIndex{{0, 7}, {8, 15}}}, {"[Ff]r[Uu]it", "fruit", []matchIndex{{0, 5}}}, {"[Ff]r[Uu]it", "FrUit", []matchIndex{{0, 5}}}, @@ -78,6 +78,15 @@ var reTests = []struct { {"[^0-9]+", "a1b2c3dd", []matchIndex{{0, 1}, {2, 3}, {4, 5}, {6, 8}}}, {"[^abc]+", "ababababbababaccacacacaca", []matchIndex{}}, {`\([^)]+\)`, "Not (paranthesized), (so) is (this) not", []matchIndex{{4, 19}, {21, 25}, {29, 35}}}, + + {"^ab", "ab bab", []matchIndex{{0, 2}}}, + {"^aaaa^", "aaaaaaaa", []matchIndex{}}, + {"^([bB][Gg])", "bG", []matchIndex{{0, 2}}}, + {"b$", "ba", []matchIndex{}}, + {"(boy|girl)$", "girlf", []matchIndex{}}, + {`\bint\b`, "print int integer", []matchIndex{{6, 9}}}, + {`int(\b|a)`, "inta", []matchIndex{{0, 4}}}, + {`\b\d+\b`, "511 a3 43", []matchIndex{{0, 3}, {7, 9}}}, } func TestFindAllMatches(t *testing.T) {