Skip to content

Commit b114586

Browse files
committed
test: improve testing coverage for prompt package
- Add a new test file for the `prompt` package - Implement a test for the `GetLanguage` function Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
1 parent fcc9ca4 commit b114586

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

prompt/language_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package prompt
2+
3+
import "testing"
4+
5+
func TestGetLanguage(t *testing.T) {
6+
testCases := []struct {
7+
langCode string
8+
expected string
9+
}{
10+
{"en", DefaultLanguage},
11+
{"zh-tw", "Traditional Chinese"},
12+
{"zh-cn", "Simplified Chinese"},
13+
{"ja", "Japanese"},
14+
{"fr", DefaultLanguage},
15+
}
16+
17+
for _, tc := range testCases {
18+
result := GetLanguage(tc.langCode)
19+
if result != tc.expected {
20+
t.Errorf("GetLanguage(%q) = %q, expected %q", tc.langCode, result, tc.expected)
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)