diff options
author | Frédéric Guillot <fred@miniflux.net> | 2018-09-22 15:04:55 -0700 |
---|---|---|
committer | Frédéric Guillot <fred@miniflux.net> | 2018-09-22 15:04:55 -0700 |
commit | b1e8f534eff7569dc2e8dab4dee851d1b709f71b (patch) | |
tree | ec9d5cbebc78704727c9ce959f442b3df5cc7d76 /locale/plural_test.go | |
parent | aae9b4eb835c72c0b7ecd8fa6565eacce3963d00 (diff) |
Simplify locale package usage (refactoring)
Diffstat (limited to 'locale/plural_test.go')
-rw-r--r-- | locale/plural_test.go | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/locale/plural_test.go b/locale/plural_test.go new file mode 100644 index 0000000..e7694bd --- /dev/null +++ b/locale/plural_test.go @@ -0,0 +1,63 @@ +// Copyright 2018 Frédéric Guillot. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +package locale // import "miniflux.app/locale" + +import "testing" + +func TestPluralRules(t *testing.T) { + scenarios := map[string]map[int]int{ + "default": map[int]int{ + 1: 0, + 2: 1, + 5: 1, + }, + "ar_AR": map[int]int{ + 0: 0, + 1: 1, + 2: 2, + 5: 3, + 11: 4, + 200: 5, + }, + "cs_CZ": map[int]int{ + 1: 0, + 2: 1, + 5: 2, + }, + "pl_PL": map[int]int{ + 1: 0, + 2: 1, + 5: 2, + }, + "pt_BR": map[int]int{ + 1: 0, + 2: 1, + 5: 1, + }, + "ru_RU": map[int]int{ + 1: 0, + 2: 1, + 5: 2, + }, + "sr_RS": map[int]int{ + 1: 0, + 2: 1, + 5: 2, + }, + "zh_CN": map[int]int{ + 1: 0, + 5: 0, + }, + } + + for rule, values := range scenarios { + for input, expected := range values { + result := pluralForms[rule](input) + if result != expected { + t.Errorf(`Unexpected result for %q rule, got %d instead of %d for %d as input`, rule, result, expected, input) + } + } + } +} |