File: formula_test.go

package info (click to toggle)
golang-github-chai2010-gettext-go 1.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 3,304 kB
  • sloc: makefile: 29
file content (50 lines) | stat: -rw-r--r-- 848 bytes parent folder | download | duplicates (2)
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
// Copyright 2013 ChaiShushan <chaishushan{AT}gmail.com>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package plural

import (
	"testing"
)

func TestFormula(t *testing.T) {
	for i, v := range testData {
		if out := Formula(v.lang)(v.in); out != v.out {
			t.Fatalf("%d/%s: expect = %d, got = %d", i, v.lang, v.out, out)
		}
	}
}

var testData = []struct {
	lang string
	in   int
	out  int
}{
	{"#@", 0, 0},
	{"#@", 1, 0},
	{"#@", 10, 0},
	{"#@", -1, 0},

	{"zh", 0, 0},
	{"zh", 1, 0},
	{"zh", 10, 0},
	{"zh", -1, 0},

	{"zh_CN", 0, 0},
	{"zh_CN", 1, 0},
	{"zh_CN", 10, 0},
	{"zh_CN", -1, 0},

	{"en", 0, 0},
	{"en", 1, 0},
	{"en", 2, 1},
	{"en", 10, 1},
	{"en", -1, 0},

	{"en_US", 0, 0},
	{"en_US", 1, 0},
	{"en_US", 2, 1},
	{"en_US", 10, 1},
	{"en_US", -1, 0},
}