diff options
Diffstat (limited to 'internal/cond/compile_test.go')
| -rw-r--r-- | internal/cond/compile_test.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/internal/cond/compile_test.go b/internal/cond/compile_test.go index e68a4d8..2a07ad6 100644 --- a/internal/cond/compile_test.go +++ b/internal/cond/compile_test.go @@ -124,6 +124,23 @@ func TestEmptyChildrenGuard(t *testing.T) { } } +// TestNameGroups: B1b - NameGroups() reports the capture-group count of +// every name test reachable without crossing a not, and skips one reachable +// only under a not (B1): here the outer (name ...) has two groups and the +// (not (name ...)) one has one, but the result must carry only the outer's +// count. +func TestNameGroups(t *testing.T) { + c, errs := Compile("d.conf", nodes(t, `(and (name "inv-(\d+)-(\d+)") (not (name "draft-(\d+)")))`), Options{}) + if len(errs) > 0 { + t.Fatal(errs) + } + got := c.NameGroups() + want := []int{2} + if !reflect.DeepEqual(got, want) { + t.Errorf("NameGroups() = %v, want %v", got, want) + } +} + func TestGroupsMatchSpec(t *testing.T) { want := map[string]string{ "image": "jpg jpeg png gif webp bmp tif tiff heic heif avif svg ico raw cr2 nef arw dng", |
