(t *testing.T)
| 125 | } |
| 126 | |
| 127 | func TestRegexStaticErrors(t *testing.T) { |
| 128 | tests := []struct { |
| 129 | expr string |
| 130 | err string |
| 131 | }{ |
| 132 | { |
| 133 | expr: "regex.replace('abc', '^', 1)", |
| 134 | err: "found no matching overload for 'regex.replace' applied to '(string, string, int)'", |
| 135 | }, |
| 136 | { |
| 137 | expr: "regex.replace('abc', '^', '1','')", |
| 138 | err: "found no matching overload for 'regex.replace' applied to '(string, string, string, string)'", |
| 139 | }, |
| 140 | { |
| 141 | expr: "regex.extract('foo bar', 1)", |
| 142 | err: "found no matching overload for 'regex.extract' applied to '(string, int)'", |
| 143 | }, |
| 144 | { |
| 145 | expr: "regex.extract('foo bar', 1, 'bar')", |
| 146 | err: "found no matching overload for 'regex.extract' applied to '(string, int, string)'", |
| 147 | }, |
| 148 | { |
| 149 | expr: "regex.extractAll()", |
| 150 | err: "found no matching overload for 'regex.extractAll' applied to '()'", |
| 151 | }, |
| 152 | { |
| 153 | expr: "regex.replace('banana', 'a', 'x', 18446744073709551615)", |
| 154 | err: `ERROR: <input>:1:35: invalid int literal`, |
| 155 | }, |
| 156 | } |
| 157 | env := testRegexEnv(t) |
| 158 | for i, tst := range tests { |
| 159 | tr := tst |
| 160 | t.Run(fmt.Sprintf("%d", i), func(t *testing.T) { |
| 161 | _, iss := env.Compile(tr.expr) |
| 162 | if iss.Err() == nil || !strings.Contains(iss.Err().Error(), tr.err) { |
| 163 | t.Errorf("env.Compile(%q) got error %v, wanted %v", tr.expr, iss.Err(), tr.err) |
| 164 | } |
| 165 | }) |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | func TestRegexRuntimeErrors(t *testing.T) { |
| 170 | tests := []struct { |
nothing calls this directly
no test coverage detected