Repository navigation
Expand file tree
/
Copy pathvoices_test.go
More file actions
85 lines (78 loc) · 1.9 KB
/
Copy pathvoices_test.go
File metadata and controls
85 lines (78 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<
8000
div data-line-number="41" class="react-line-number react-code-text" style="padding-right:16px">4142
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package cmd
import (
"testing"
"github.com/neosapience/cast/internal/client"
)
var testVoices = []client.Voice{
{
VoiceID: "v1",
VoiceName: "건석",
Models: []client.VoiceModel{
{Version: "ssfm-v21", Emotions: []string{"normal", "happy"}},
},
},
{
VoiceID: "v2",
VoiceName: "Alice",
Models: []client.VoiceModel{
{Version: "ssfm-v30", Emotions: []string{"normal", "sad"}},
},
},
{
VoiceID: "v3",
VoiceName: "건우",
Models: []client.VoiceModel{
{Version: "ssfm-v30", Emotions: []string{"angry"}},
},
},
}
func TestFilterVoicesByName(t *testing.T) {
cases := []struct {
name string
filter string
want []string
}{
{"exact match", "건석", []string{"v1"}},
{"partial match", "건", []string{"v1", "v3"}},
{"case insensitive", "alice", []string{"v2"}},
{"no match", "없음", []string{}},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
got := filterVoicesByName(append([]client.Voice{}, testVoices...), tc.filter)
if len(got) != len(tc.want) {
t.Fatalf("got %d voices, want %d", len(got), len(tc.want))
}
for i, v := range got {
if v.VoiceID != tc.want[i] {
t.Errorf("got[%d] = %q, want %q", i, v.VoiceID, tc.want[i])
}
}
})
}
}
func TestFilterVoicesByEmotion(t *testing.T) {
cases := []struct {
name string
emotion string
want []string
}{
{"happy", "happy", []string{"v1"}},
{"normal", "normal", []string{"v1", "v2"}},
{"angry", "angry", []string{"v3"}},
{"no match", "whisper", []string{}},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
got := filterVoicesByEmotion(append([]client.Voice{}, testVoices...), tc.emotion)
if len(got) != len(tc.want) {
t.Fatalf("got %d voices, want %d", len(got), len(tc.want))
}
for i, v := range got {
if v.VoiceID != tc.want[i] {
t.Errorf("got[%d] = %q, want %q", i, v.VoiceID, tc.want[i])
}
}
})
}
}