iso639/iso_639_test.go

48 lines
848 B
Go
Raw Permalink Normal View History

2023-10-01 08:51:38 +02:00
package iso639
import "testing"
func TestGetAllKeysOfMap(t *testing.T) {
got := getAllKeysOfMap(
map[string]string{
"This": "is",
"just": "a",
"little": "test",
"for": "you",
},
)
want := []string{
"This",
"for",
"just",
"little",
}
for i := 0; i <= 3; i++ {
if got[i] != want[i] {
t.Errorf("got %q, wanted %q", got[i], want[i])
}
}
}
func TestGetLanguageNameForISO639Code(t *testing.T) {
data := map[string]string{
"nl": "Dutch", // ISO 639-1
"nld": "Dutch", // ISO 639-2/B
"dut": "Dutch", // ISO 639-2/T
"NL": "",
"NLD": "",
"DUT": "",
"gfedgjhgrh": "",
"GIJGKDJ": "",
}
for code, name := range data {
result, _ := GetLanguageNameForISO639Code(code)
if result != name {
t.Errorf("got %q, wanted %q", result, name)
}
}
}