forked from gkmngrgn/dosh-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil_test.go
39 lines (35 loc) · 973 Bytes
/
util_test.go
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
package dosh
import "testing"
var (
languageCodes = []struct {
value, want string
}{
{"en_US.UTF-8", "en"},
{"de_DE.UTF-8", "en"}, // fallback language, we don't support de for now.
{"tr_TR.UTF-8", "tr"},
{"", "en"},
}
helpTextLines = []struct {
value, want string
}{
{"command 1", "command 1 "},
{"bla-bla-bla-bla-bla", "bla-bla-bla-bla-bla "},
{"foo", "foo "},
{"what if I write a too long command?", "what if I write a too long command?"},
}
)
func TestGetLanguage(t *testing.T) {
for _, lang := range languageCodes {
if langCode := GetLanguage(lang.value); langCode != lang.want {
t.Fatalf("Actual: %s, Expected: %s", langCode, lang.want)
}
}
t.Log(len(languageCodes), "test cases")
}
func TestPadLength(t *testing.T) {
for _, text := range helpTextLines {
if alignedText := LeftPad(text.value, 20); alignedText != text.want {
t.Fatalf("Actual: %s, Expected: %s", alignedText, text.want)
}
}
}