diff options
Diffstat (limited to 'internal/cond/compile_test.go')
| -rw-r--r-- | internal/cond/compile_test.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/internal/cond/compile_test.go b/internal/cond/compile_test.go index 2a07ad6..8432365 100644 --- a/internal/cond/compile_test.go +++ b/internal/cond/compile_test.go @@ -165,3 +165,24 @@ func TestGroupsMatchSpec(t *testing.T) { } } } + +// TestCompileCollectsKeywords: every content keyword is recorded as +// compared, normalised under the compile options, and its key names those +// options. +func TestCompileCollectsKeywords(t *testing.T) { + opt := Options{IgnoreCase: true, Fold: true} + c, errs := Compile("d.conf", nodes(t, `(or (content "Spółka" "x") (not (content "NIP")))`), opt) + if len(errs) > 0 { + t.Fatal(errs) + } + want := []Keyword{{Opt: opt, Norm: "spolka"}, {Opt: opt, Norm: "x"}, {Opt: opt, Norm: "nip"}} + if !reflect.DeepEqual(c.Keywords, want) { + t.Errorf("Keywords = %+v, want %+v", c.Keywords, want) + } + if got := want[0].Key(); got != "if:spolka" { + t.Errorf("Key = %q", got) + } + if got := KeywordKey(Options{}, "NIP"); got != "sn:NIP" { + t.Errorf("strict, unfolded key = %q", got) + } +} |
