aboutsummaryrefslogtreecommitdiff
path: root/internal/locale/plural_test.go
blob: 2bbf9d50558da905c94c7aa0115e8ab4f13326b6 (plain) (blame)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

package locale // import "miniflux.app/v2/internal/locale"

import "testing"

func TestPluralRules(t *testing.T) {
	scenarios := map[string]map[int]int{
		"default": {
			1: 0,
			2: 1,
			5: 1,
		},
		"ar_AR": {
			0:   0,
			1:   1,
			2:   2,
			5:   3,
			11:  4,
			200: 5,
		},
		"cs_CZ": {
			1: 0,
			2: 1,
			5: 2,
		},
		"fr_FR": {
			1: 0,
			2: 1,
			5: 1,
		},
		"id_ID": {
			1: 0,
			5: 0,
		},
		"ja_JP": {
			1: 0,
			2: 0,
			5: 0,
		},
		"pl_PL": {
			1: 0,
			2: 1,
			5: 2,
		},
		"pt_BR": {
			1: 0,
			2: 1,
			5: 1,
		},
		"ru_RU": {
			1: 0,
			2: 1,
			5: 2,
		},
		"sr_RS": {
			1: 0,
			2: 1,
			5: 2,
		},
		"tr_TR": {
			1: 0,
			2: 1,
			5: 1,
		},
		"uk_UA": {
			1: 0,
			2: 1,
			5: 2,
		},
		"zh_CN": {
			1: 0,
			5: 0,
		},
		"zh_TW": {
			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)
			}
		}
	}
}