mirror of
https://github.com/wneessen/apg-go.git
synced 2024-12-23 03:30:39 +01:00
Add pronunciation tests in spelling_test.go
Added "TestPronounce" function in spelling_test.go file to ensure pronunciation mechanism works as expected. The function tests various cases including no syllables, single syllable, multiple syllables, and non-Koremutake syllables.
This commit is contained in:
parent
fefb2557fc
commit
4b0437d3b1
1 changed files with 49 additions and 0 deletions
|
@ -110,3 +110,52 @@ func TestSpell(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestPronounce(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
syllables []string
|
||||
want string
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "Pronounce_NoSyllables",
|
||||
syllables: []string{},
|
||||
want: "",
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "Pronounce_SingleSyllable",
|
||||
syllables: []string{"me"},
|
||||
want: "me",
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "Pronounce_MultipleSyllables",
|
||||
syllables: []string{"mu", "sa"},
|
||||
want: "mu-sa",
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "Pronounce_NonKoremutakeSyllable",
|
||||
syllables: []string{"ä"},
|
||||
wantErr: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
config := NewConfig()
|
||||
g := New(config)
|
||||
g.syllables = tt.syllables
|
||||
got, err := g.Pronounce()
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("Generator.Pronounce() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
}
|
||||
if got != tt.want {
|
||||
t.Errorf("Generator.Pronounce() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue