(t *testing.T)
| 17 | } |
| 18 | |
| 19 | func TestRegisterEngine_CacheHit(t *testing.T) { |
| 20 | didFindFirst := false |
| 21 | didExecute := false |
| 22 | engine := emptyEngine{ |
| 23 | findFirstChar: func(r *Runner) bool { |
| 24 | didFindFirst = true |
| 25 | return true |
| 26 | }, |
| 27 | execute: func(r *Runner) error { |
| 28 | didExecute = true |
| 29 | return nil |
| 30 | }, |
| 31 | } |
| 32 | RegisterEngine("This is a regexp", RuntimeEngineData{ |
| 33 | CapSize: 1, |
| 34 | FindFirstChar: engine.FindFirstChar, |
| 35 | Execute: engine.Execute, |
| 36 | }, RE2) |
| 37 | |
| 38 | re := MustCompile("This is a regexp", RE2) |
| 39 | val, err := re.MatchString("This is a regexp") |
| 40 | |
| 41 | if !didFindFirst { |
| 42 | t.Fatal("Expected find first char to be called, but it wasn't") |
| 43 | } |
| 44 | if !didExecute { |
| 45 | t.Fatal("Expected execute to be called, but it wasn't") |
| 46 | } |
| 47 | if err != nil { |
| 48 | t.Fatal("Unexpected error", err) |
| 49 | } |
| 50 | if val { |
| 51 | t.Fatal("Expected no match") |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | func TestRegisterEngine_QuickExecute(t *testing.T) { |
| 56 | const pattern = "quick-execute" |
nothing calls this directly
no test coverage detected