-
Notifications
You must be signed in to change notification settings - Fork 1
/
int32_test.go
98 lines (95 loc) · 2.32 KB
/
int32_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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package nill
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestInt32(t *testing.T) {
t.Run("add", func(t *testing.T) {
value := NewInt32(1)
value.Add(1)
assert.Equal(t, Int32{Valid: true, V: 2}, value)
})
t.Run("sub", func(t *testing.T) {
value := NewInt32(1)
value.Sub(1)
assert.Equal(t, Int32{Valid: true, V: 0}, value)
})
t.Run("mul", func(t *testing.T) {
value := NewInt32(3)
value.Mul(5)
assert.Equal(t, Int32{Valid: true, V: 15}, value)
})
t.Run("div", func(t *testing.T) {
value := NewInt32(10)
value.Div(5)
assert.Equal(t, Int32{Valid: true, V: 2}, value)
})
t.Run("mod", func(t *testing.T) {
value := NewInt32(1)
value.Mod(5)
assert.Equal(t, Int32{Valid: true, V: 1}, value)
})
t.Run("inc", func(t *testing.T) {
value := NewInt32(1)
value.Inc()
assert.Equal(t, Int32{Valid: true, V: 2}, value)
})
t.Run("dec", func(t *testing.T) {
value := NewInt32(1)
value.Dec()
assert.Equal(t, Int32{Valid: true, V: 0}, value)
})
t.Run("zero", func(t *testing.T) {
value := NewInt32(0)
assert.True(t, value.Zero())
})
t.Run("positive", func(t *testing.T) {
value := NewInt32(1)
assert.True(t, value.Positive())
})
t.Run("negative", func(t *testing.T) {
value := NewInt32(-1)
assert.True(t, value.Negative())
})
t.Run("event", func(t *testing.T) {
value := NewInt32(10)
value.Even()
assert.True(t, value.Even())
})
t.Run("odd", func(t *testing.T) {
value := NewInt32(11)
assert.True(t, value.Odd())
})
t.Run("greater than", func(t *testing.T) {
value := NewInt32(11)
assert.True(t, value.GreaterThan(10))
})
t.Run("greater than equal", func(t *testing.T) {
value := NewInt32(10)
assert.True(t, value.LessThanOrEqual(10))
})
t.Run("less than", func(t *testing.T) {
value := NewInt32(10)
assert.True(t, value.LessThan(11))
})
t.Run("less than equal", func(t *testing.T) {
value := NewInt32(10)
assert.True(t, value.LessThanOrEqual(10))
})
t.Run("equal", func(t *testing.T) {
value := NewInt32(10)
assert.True(t, value.Equal(10))
})
t.Run("not equal", func(t *testing.T) {
value := NewInt32(10)
assert.True(t, value.NotEqual(11))
})
t.Run("divisible by", func(t *testing.T) {
value := NewInt32(10)
assert.True(t, value.DivisibleBy(5))
})
t.Run("prime", func(t *testing.T) {
value := NewInt32(19)
assert.True(t, value.Prime())
})
}