(t *testing.T)
| 257 | } |
| 258 | |
| 259 | func TestRegisterEngine_CacheHitMaintainCaptureOrder(t *testing.T) { |
| 260 | didFindFirst := false |
| 261 | didExecute := false |
| 262 | engine := emptyEngine{ |
| 263 | findFirstChar: func(r *Runner) bool { |
| 264 | didFindFirst = true |
| 265 | return true |
| 266 | }, |
| 267 | execute: func(r *Runner) error { |
| 268 | didExecute = true |
| 269 | return nil |
| 270 | }, |
| 271 | } |
| 272 | RegisterEngine("(?<first>This) (is)", RuntimeEngineData{ |
| 273 | CapSize: 3, |
| 274 | FindFirstChar: engine.FindFirstChar, |
| 275 | Execute: engine.Execute, |
| 276 | }, OptionMaintainCaptureOrder()) |
| 277 | |
| 278 | re := MustCompile("(?<first>This) (is)", OptionMaintainCaptureOrder()) |
| 279 | val, err := re.MatchString("This is") |
| 280 | |
| 281 | if !didFindFirst { |
| 282 | t.Fatal("Expected find first char to be called, but it wasn't") |
| 283 | } |
| 284 | if !didExecute { |
| 285 | t.Fatal("Expected execute to be called, but it wasn't") |
| 286 | } |
| 287 | if err != nil { |
| 288 | t.Fatal("Unexpected error", err) |
| 289 | } |
| 290 | if val { |
| 291 | t.Fatal("Expected no match") |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | func TestStringPrefixFilterSkipsDecodeOnMiss(t *testing.T) { |
| 296 | const pattern = `string-prefix-filter-miss-only` |
nothing calls this directly
no test coverage detected