package ttsnorm import ( "strings" "testing" ) func TestDictionaryLoads(t *testing.T) { // An empty map is the failure mode, and it is silent at runtime by design. if len(pronounce) == 0 { t.Fatal("pronunciation dictionary is empty — it failed to load or failed its version check") } } func TestPronounceRewritesAKnownService(t *testing.T) { got := Pronounce("netdata говорит что диск заполнен") if strings.Contains(got, "netdata") { t.Fatalf("got %q, want the latin name spelled in Cyrillic", got) } } func TestPronounceIsCaseInsensitive(t *testing.T) { for _, in := range []string{"Netdata", "NETDATA", "netdata"} { if got := Pronounce(in); got != pronounce["netdata"] { t.Errorf("Pronounce(%q) = %q, want %q", in, got, pronounce["netdata"]) } } } func TestPronounceLeavesUnknownWordsAlone(t *testing.T) { // A miss must be the old behaviour, never a guess. const in = "zzqx упал" if got := Pronounce(in); got != in { t.Fatalf("Pronounce(%q) = %q, want it untouched", in, got) } } func TestPronounceDoesNotTouchRussian(t *testing.T) { const in = "напомню завтра в 19:00" if got := Pronounce(in); got != in { t.Fatalf("Pronounce(%q) = %q, want Cyrillic untouched", in, got) } } func TestPronounceMatchesWholeWordsOnly(t *testing.T) { // "nexuses" is not "nexus", and half-rewriting a word is worse than not // rewriting it. if got := Pronounce("nexuses"); got != "nexuses" { t.Fatalf("Pronounce(\"nexuses\") = %q, want it untouched", got) } } func TestSpeakableAppliesTheDictionary(t *testing.T) { got := Speakable("homesrv: 10.07.2026") if strings.Contains(got, "homesrv") { t.Fatalf("Speakable did not apply the dictionary: %q", got) } if !strings.Contains(got, "июля") { t.Fatalf("Speakable stopped rewriting dates: %q", got) } }