diff options
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) + } +} |
