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

Function TestFindStringPrefixCandidateFallbacks

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

Source from the content-addressed store, hash-verified

350}
351
352func TestFindStringPrefixCandidateFallbacks(t *testing.T) {
353 re := &Regexp{
354 stringPrefixFilter: func(input string, startAt int) (candidateByteIndex int, ok bool) {
355 return 1, true
356 },
357 }
358
359 candidateByteIndex, ok := re.findStringPrefixCandidate("éabc", 0)
360 if !ok {
361 t.Fatal("expected fallback candidate")
362 }
363 if got, want := candidateByteIndex, 0; got != want {
364 t.Fatalf("candidateByteIndex = %d, want %d", got, want)
365 }
366
367 re.stringPrefixFilter = func(input string, startAt int) (candidateByteIndex int, ok bool) {
368 return startAt - 1, true
369 }
370 candidateByteIndex, ok = re.findStringPrefixCandidate("abc", 1)
371 if !ok {
372 t.Fatal("expected fallback candidate")
373 }
374 if got, want := candidateByteIndex, 1; got != want {
375 t.Fatalf("candidateByteIndex = %d, want %d", got, want)
376 }
377}
378
379func TestFindStringPrefixCandidateDisabledForRightToLeft(t *testing.T) {
380 re := &Regexp{

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected