2023-06-19 23:42:47 +02:00
|
|
|
// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
2018-09-23 00:04:55 +02:00
|
|
|
|
2023-08-11 04:46:45 +02:00
|
|
|
package locale // import "miniflux.app/v2/internal/locale"
|
2018-09-23 00:04:55 +02:00
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
|
|
|
func TestPluralRules(t *testing.T) {
|
|
|
|
scenarios := map[string]map[int]int{
|
2021-02-17 07:58:44 +01:00
|
|
|
"default": {
|
2018-09-23 00:04:55 +02:00
|
|
|
1: 0,
|
|
|
|
2: 1,
|
|
|
|
5: 1,
|
|
|
|
},
|
2021-02-17 07:58:44 +01:00
|
|
|
"ar_AR": {
|
2018-09-23 00:04:55 +02:00
|
|
|
0: 0,
|
|
|
|
1: 1,
|
|
|
|
2: 2,
|
|
|
|
5: 3,
|
|
|
|
11: 4,
|
|
|
|
200: 5,
|
|
|
|
},
|
2021-02-17 07:58:44 +01:00
|
|
|
"cs_CZ": {
|
2018-09-23 00:04:55 +02:00
|
|
|
1: 0,
|
|
|
|
2: 1,
|
|
|
|
5: 2,
|
|
|
|
},
|
2024-03-01 05:20:29 +01:00
|
|
|
"fr_FR": {
|
|
|
|
1: 0,
|
|
|
|
2: 1,
|
|
|
|
5: 1,
|
|
|
|
},
|
|
|
|
"id_ID": {
|
|
|
|
1: 0,
|
|
|
|
5: 0,
|
|
|
|
},
|
|
|
|
"ja_JP": {
|
|
|
|
1: 0,
|
|
|
|
2: 0,
|
|
|
|
5: 0,
|
|
|
|
},
|
2021-02-17 07:58:44 +01:00
|
|
|
"pl_PL": {
|
2018-09-23 00:04:55 +02:00
|
|
|
1: 0,
|
|
|
|
2: 1,
|
|
|
|
5: 2,
|
|
|
|
},
|
2021-02-17 07:58:44 +01:00
|
|
|
"pt_BR": {
|
2018-09-23 00:04:55 +02:00
|
|
|
1: 0,
|
|
|
|
2: 1,
|
|
|
|
5: 1,
|
|
|
|
},
|
2021-02-17 07:58:44 +01:00
|
|
|
"ru_RU": {
|
2018-09-23 00:04:55 +02:00
|
|
|
1: 0,
|
|
|
|
2: 1,
|
|
|
|
5: 2,
|
|
|
|
},
|
2021-02-17 07:58:44 +01:00
|
|
|
"sr_RS": {
|
2018-09-23 00:04:55 +02:00
|
|
|
1: 0,
|
|
|
|
2: 1,
|
|
|
|
5: 2,
|
|
|
|
},
|
2024-03-01 05:20:29 +01:00
|
|
|
"tr_TR": {
|
|
|
|
1: 0,
|
|
|
|
2: 1,
|
|
|
|
5: 1,
|
|
|
|
},
|
|
|
|
"uk_UA": {
|
|
|
|
1: 0,
|
|
|
|
2: 1,
|
|
|
|
5: 2,
|
|
|
|
},
|
2021-02-17 07:58:44 +01:00
|
|
|
"zh_CN": {
|
2018-09-23 00:04:55 +02:00
|
|
|
1: 0,
|
|
|
|
5: 0,
|
|
|
|
},
|
2024-03-01 05:20:29 +01:00
|
|
|
"zh_TW": {
|
|
|
|
1: 0,
|
|
|
|
5: 0,
|
|
|
|
},
|
2018-09-23 00:04:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|