MCPcopy Create free account
hub / github.com/dlclark/regexp2 / TestFindStringPrefixCandidateFallbacks

Function TestFindStringPrefixCandidateFallbacks

stringprefixfilter_test.go:293–318  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

291}
292
293func TestFindStringPrefixCandidateFallbacks(t *testing.T) {
294 re := &Regexp{
295 stringPrefixFilter: func(input string, startAt int) (candidateByteIndex int, ok bool) {
296 return 1, true
297 },
298 }
299
300 candidateByteIndex, ok := re.findStringPrefixCandidate("éabc", 0)
301 if !ok {
302 t.Fatal("expected fallback candidate")
303 }
304 if got, want := candidateByteIndex, 0; got != want {
305 t.Fatalf("candidateByteIndex = %d, want %d", got, want)
306 }
307
308 re.stringPrefixFilter = func(input string, startAt int) (candidateByteIndex int, ok bool) {
309 return startAt - 1, true
310 }
311 candidateByteIndex, ok = re.findStringPrefixCandidate("abc", 1)
312 if !ok {
313 t.Fatal("expected fallback candidate")
314 }
315 if got, want := candidateByteIndex, 1; got != want {
316 t.Fatalf("candidateByteIndex = %d, want %d", got, want)
317 }
318}
319
320func TestFindStringPrefixCandidateDisabledForRightToLeft(t *testing.T) {
321 re := &Regexp{

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected