static_test.go 648 B

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright 2020 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package conf
  5. import (
  6. "testing"
  7. "github.com/stretchr/testify/assert"
  8. )
  9. func Test_i18n_DateLang(t *testing.T) {
  10. c := &i18nConf{
  11. dateLangs: map[string]string{
  12. "en-US": "en",
  13. "zh-CN": "zh",
  14. },
  15. }
  16. tests := []struct {
  17. lang string
  18. want string
  19. }{
  20. {lang: "en-US", want: "en"},
  21. {lang: "zh-CN", want: "zh"},
  22. {lang: "jp-JP", want: "en"},
  23. }
  24. for _, test := range tests {
  25. t.Run("", func(t *testing.T) {
  26. assert.Equal(t, test.want, c.DateLang(test.lang))
  27. })
  28. }
  29. }