aboutsummaryrefslogtreecommitdiff
path: root/internal/cond/compile_test.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-09-14 15:16:55 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-09-14 15:16:55 +0200
commit0b5d0eb92c5be2f0ddb2fa73990f31e5654e57fe (patch)
tree358e331945b8206ed4a72703e3aedfe8ea7cdcdb /internal/cond/compile_test.go
parent1d3f2d1e4c59867024470d3444e12698b7ebb22e (diff)
downloadkrino-0b5d0eb92c5be2f0ddb2fa73990f31e5654e57fe.tar.gz
krino-0b5d0eb92c5be2f0ddb2fa73990f31e5654e57fe.zip
krino: 0.0.5 — keyword cache, t and d in reviewv0.0.5
Diffstat (limited to 'internal/cond/compile_test.go')
-rw-r--r--internal/cond/compile_test.go21
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)
+ }
+}