(t *testing.T)
| 197 | } |
| 198 | |
| 199 | func TestRegisterEngine_CacheHitMaintainCaptureOrder(t *testing.T) { |
| 200 | didFindFirst := false |
| 201 | didExecute := false |
| 202 | engine := emptyEngine{ |
| 203 | findFirstChar: func(r *Runner) bool { |
| 204 | didFindFirst = true |
| 205 | return true |
| 206 | }, |
| 207 | execute: func(r *Runner) error { |
| 208 | didExecute = true |
| 209 | return nil |
| 210 | }, |
| 211 | } |
| 212 | RegisterEngine("(?<first>This) (is)", RuntimeEngineData{ |
| 213 | CapSize: 3, |
| 214 | FindFirstChar: engine.FindFirstChar, |
| 215 | Execute: engine.Execute, |
| 216 | }, OptionMaintainCaptureOrder()) |
| 217 | |
| 218 | re := MustCompile("(?<first>This) (is)", OptionMaintainCaptureOrder()) |
| 219 | val, err := re.MatchString("This is") |
| 220 | |
| 221 | if !didFindFirst { |
| 222 | t.Fatal("Expected find first char to be called, but it wasn't") |
| 223 | } |
| 224 | if !didExecute { |
| 225 | t.Fatal("Expected execute to be called, but it wasn't") |
| 226 | } |
| 227 | if err != nil { |
| 228 | t.Fatal("Unexpected error", err) |
| 229 | } |
| 230 | if val { |
| 231 | t.Fatal("Expected no match") |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | func TestStringPrefixFilterSkipsDecodeOnMiss(t *testing.T) { |
| 236 | const pattern = `string-prefix-filter-miss-only` |
nothing calls this directly
no test coverage detected