summaryrefslogtreecommitdiffstats
path: root/vendor/golang.org/x/text/feature/plural/plural_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/golang.org/x/text/feature/plural/plural_test.go')
-rw-r--r--vendor/golang.org/x/text/feature/plural/plural_test.go17
1 files changed, 15 insertions, 2 deletions
diff --git a/vendor/golang.org/x/text/feature/plural/plural_test.go b/vendor/golang.org/x/text/feature/plural/plural_test.go
index e5524c59a..b3cf4c449 100644
--- a/vendor/golang.org/x/text/feature/plural/plural_test.go
+++ b/vendor/golang.org/x/text/feature/plural/plural_test.go
@@ -28,6 +28,8 @@ func TestGetIntApprox(t *testing.T) {
{"123", 0, 2, 2, 12},
{"123", 3, 4, 2, 0},
{"12345", 3, 4, 2, 4},
+ {"40", 0, 1, 2, 4},
+ {"1", 0, 7, 2, big},
{"123", 0, 5, 2, big},
{"123", 0, 5, 3, big},
@@ -114,7 +116,7 @@ func testPlurals(t *testing.T, p *Rules, testCases []pluralTest) {
for i := range digits {
digits[i] -= '0'
}
- if f := p.MatchDigits(tag, digits, 0, 0); f != Form(tc.form) {
+ if f := p.MatchDigits(tag, digits, len(digits), 0); f != Form(tc.form) {
t.Errorf("MatchDigits: got %v; want %v", f, Form(tc.form))
}
})
@@ -139,14 +141,25 @@ func testPlurals(t *testing.T, p *Rules, testCases []pluralTest) {
num := fmt.Sprintf("%[1]d.%0[3]*[2]d", n/m, n%m, scale)
name := fmt.Sprintf("%s:dec(%s)", loc, num)
t.Run(name, func(t *testing.T) {
+ ff := n % m
+ tt := ff
+ w := scale
+ for tt > 0 && tt%10 == 0 {
+ w--
+ tt /= 10
+ }
+ if f := p.MatchPlural(tag, n/m, scale, w, ff, tt); f != Form(tc.form) {
+ t.Errorf("MatchPlural: got %v; want %v", f, Form(tc.form))
+ }
if f := p.matchComponents(tag, n/m, n%m, scale); f != Form(tc.form) {
t.Errorf("matchComponents: got %v; want %v", f, Form(tc.form))
}
+ exp := strings.IndexByte(num, '.')
digits := []byte(strings.Replace(num, ".", "", 1))
for i := range digits {
digits[i] -= '0'
}
- if f := p.MatchDigits(tag, digits, -scale, scale); f != Form(tc.form) {
+ if f := p.MatchDigits(tag, digits, exp, scale); f != Form(tc.form) {
t.Errorf("MatchDigits: got %v; want %v", f, Form(tc.form))
}
})