diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-14 23:34:51 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-14 23:34:51 +0200 |
| commit | 3990586a85e91923c0a3ae1a1f0f61420db555ac (patch) | |
| tree | 041692e7961cb66333b2c7b47d32a25487c6522d /internal/cond/eval_test.go | |
| parent | 01b0cfe2055e23cf03870d9a9f60648037b4005e (diff) | |
| download | krino-3990586a85e91923c0a3ae1a1f0f61420db555ac.tar.gz krino-3990586a85e91923c0a3ae1a1f0f61420db555ac.zip | |
captures keep the name's diacritics
Diffstat (limited to 'internal/cond/eval_test.go')
| -rw-r--r-- | internal/cond/eval_test.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/internal/cond/eval_test.go b/internal/cond/eval_test.go index 88612ac..2e8bcfd 100644 --- a/internal/cond/eval_test.go +++ b/internal/cond/eval_test.go @@ -240,3 +240,20 @@ func TestEvalReportsUnreadableContent(t *testing.T) { t.Errorf("not reached: Match %v Unreadable %v; want true, false", r.Match, r.Unreadable) } } + +// TestCapturesKeepDiacritics: a name test matches the folded name, but its +// captures are the original name's characters, so {1} keeps "Łódź". +func TestCapturesKeepDiacritics(t *testing.T) { + f := &fake{name: "Łódź-Faktura.pdf"} + r := eval(t, `(name "^(.+)-faktura")`, Options{IgnoreCase: true, Fold: true}, f) + if !r.Match { + t.Fatal("no match") + } + if want := []string{"Łódź-Faktura", "Łódź"}; !reflect.DeepEqual(r.Captures, want) { + t.Errorf("captures = %q, want %q", r.Captures, want) + } + r = eval(t, `(name "^(lodz)?(x)?-")`, Options{IgnoreCase: true, Fold: true}, f) + if want := []string{"Łódź-", "Łódź", ""}; !reflect.DeepEqual(r.Captures, want) { + t.Errorf("captures with a group that did not take part = %q, want %q", r.Captures, want) + } +} |
