// SPDX-License-Identifier: GPL-3.0-or-later package norm import "testing" // FuzzTextIdempotent: normalising text twice changes nothing more than // normalising it once, under every case and fold setting, and so for names. // Keywords are normalised at load and text at match time by the same // functions; a second pass that still changed something would mean the two // could disagree about what one normalised string is. func FuzzTextIdempotent(f *testing.F) { for _, s := range []string{"Spółka Z O.O.", "ẞ straße", "a\u0301", " tabs\tand\nlines ", "\xff", "İstanbul", "Dž", "Æsir Œuvre"} { f.Add(s) } f.Fuzz(func(t *testing.T, s string) { for _, opt := range [][2]bool{{false, false}, {true, false}, {false, true}, {true, true}} { once := Text(s, opt[0], opt[1]) if twice := Text(once, opt[0], opt[1]); twice != once { t.Fatalf("Text(%q, %v, %v) = %q, again %q", s, opt[0], opt[1], once, twice) } } for _, fold := range []bool{false, true} { once := Name(s, fold) if twice := Name(once, fold); twice != once { t.Fatalf("Name(%q, %v) = %q, again %q", s, fold, once, twice) } } }) }