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

Function TestStringLiteralAfterLoopFilter

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

Source from the content-addressed store, hash-verified

178}
179
180func TestStringLiteralAfterLoopFilter(t *testing.T) {
181 filter := stringLiteralAfterLoopFilter(&syntax.LiteralAfterLoop{
182 Char: '@',
183 LoopNode: &syntax.RegexNode{
184 Set: syntax.DigitClass(),
185 },
186 }, 4)
187 if filter == nil {
188 t.Fatal("expected filter")
189 }
190
191 candidateByteIndex, ok := filter("xx123@", 0)
192 if !ok {
193 t.Fatal("expected candidate")
194 }
195 if got, want := candidateByteIndex, 0; got != want {
196 t.Fatalf("candidateByteIndex = %d, want %d", got, want)
197 }
198
199 if _, ok := filter("xx123", 0); ok {
200 t.Fatal("unexpected candidate for missing literal")
201 }
202}
203
204func TestNewStringPrefixFilterFixedDistanceChar(t *testing.T) {
205 filter := newStringPrefixFilter(&syntax.Code{

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected