diff options
author | Christopher Speller <crspeller@gmail.com> | 2017-09-29 12:46:30 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-29 12:46:30 -0700 |
commit | b84736e9b6401df0c6eeab9950bef09458a6aefd (patch) | |
tree | d9175208de3236db75a33879750a57b3000ba096 /vendor/golang.org/x/text/feature/plural/plural_test.go | |
parent | 8b9dbb86133ff0fd6002a391268383d1593918ca (diff) | |
download | chat-b84736e9b6401df0c6eeab9950bef09458a6aefd.tar.gz chat-b84736e9b6401df0c6eeab9950bef09458a6aefd.tar.bz2 chat-b84736e9b6401df0c6eeab9950bef09458a6aefd.zip |
Updating server dependancies. (#7538)
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.go | 17 |
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)) } }) |