From 0b5d0eb92c5be2f0ddb2fa73990f31e5654e57fe Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Mon, 14 Sep 2026 15:16:55 +0200 Subject: krino: 0.0.5 — keyword cache, t and d in review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/cond/compile_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'internal/cond/compile_test.go') 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) + } +} -- cgit v1.3