-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
62 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package locales | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
func TestLocales(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
header string | ||
locale map[string]string | ||
}{ | ||
{ | ||
name: "Test empty 'Accept-Language' request header which defaults to English language", | ||
header: "", | ||
locale: locale_en, | ||
}, | ||
{ | ||
name: "Test 'Accept-Language' request header which favours English language", | ||
header: "fr-CH, fr;q=0.9, en;q=0.8, de;q=0.7, *;q=0.5", | ||
locale: locale_en, | ||
}, | ||
{ | ||
name: "Test 'Accept-Language' request header which favours Japan language", | ||
header: "ja;q=0.8, en;q=0.7", | ||
locale: locale_ja, | ||
}, | ||
{ | ||
name: "Test 'Accept-Language' request header which favours Korean language", | ||
header: "ja;q=0.8, ko;q=0.9", | ||
locale: locale_ko, | ||
}, | ||
{ | ||
name: "Test 'Accept-Language' request header which favours Chinese language", | ||
header: "en;q=0.3, zh;q=0.7", | ||
locale: locale_zh, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if !reflect.DeepEqual(GetLocale(tt.header), tt.locale) { | ||
t.Error(tt.name) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters