-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtriples_test.go
65 lines (63 loc) · 1.88 KB
/
triples_test.go
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
package rusnum
import (
"math"
"reflect"
"testing"
)
func Test_triplesInWords(t *testing.T) {
type args struct {
n int64
withZeros bool
gender GrammaticalGender
}
tests := []struct {
name string
args args
want []string
}{
{name: "01",
args: args{n: 0, withZeros: false},
want: []string{"ноль"},
},
{name: "02",
args: args{n: 0, withZeros: true},
want: []string{"ноль"},
},
{name: "1n",
args: args{n: 1, gender: Neuter},
want: []string{"одно"},
},
{name: "2f",
args: args{n: 2, gender: Feminine},
want: []string{"две"},
},
{name: "21m",
args: args{n: 21, gender: Masculine},
want: []string{"двадцать один"},
},
{name: "1000001",
args: args{n: 1000001, withZeros: false, gender: Masculine},
want: []string{"один", "", "один миллион"},
},
{name: "1000001z",
args: args{n: 1000001, withZeros: true, gender: Masculine},
want: []string{"один", "ноль тысяч", "один миллион"},
},
{name: "1001001",
args: args{n: 1001001, gender: Neuter},
want: []string{"одно", "одна тысяча", "один миллион"},
},
{name: "MaxInt64",
args: args{n: math.MaxInt64, gender: Feminine},
want: []string{"восемьсот семь", "семьсот семьдесят пять тысяч", "восемьсот пятьдесят четыре миллиона",
"тридцать шесть миллиардов", "триста семьдесят два триллиона", "двести двадцать три квадриллиона", "девять квинтиллионов"},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := triplesInWords(tt.args.n, tt.args.withZeros, tt.args.gender); !reflect.DeepEqual(got, tt.want) {
t.Errorf("triplesInWords() = %v, want %v", got, tt.want)
}
})
}
}