-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfloat64_test.go
52 lines (49 loc) · 1.2 KB
/
float64_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
package nill
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestFloat64(t *testing.T) {
t.Run("add", func(t *testing.T) {
value := NewFloat64(1.5)
value.Add(1)
assert.Equal(t, Float64{Valid: true, V: 2.5}, value)
})
t.Run("sub", func(t *testing.T) {
value := NewFloat64(1.5)
value.Sub(1)
assert.Equal(t, Float64{Valid: true, V: 0.5}, value)
})
t.Run("mul", func(t *testing.T) {
value := NewFloat64(1.5)
value.Mul(5)
assert.Equal(t, Float64{Valid: true, V: 7.5}, value)
})
t.Run("div", func(t *testing.T) {
value := NewFloat64(1.5)
value.Div(5)
assert.Equal(t, Float64{Valid: true, V: 0.3}, value)
})
t.Run("inc", func(t *testing.T) {
value := NewFloat64(1.5)
value.Inc()
assert.Equal(t, Float64{Valid: true, V: 2.5}, value)
})
t.Run("dec", func(t *testing.T) {
value := NewFloat64(1.5)
value.Dec()
assert.Equal(t, Float64{Valid: true, V: 0.5}, value)
})
t.Run("zero", func(t *testing.T) {
value := NewFloat64(0)
assert.True(t, value.Zero())
})
t.Run("positive", func(t *testing.T) {
value := NewFloat32(1)
assert.True(t, value.Positive())
})
t.Run("negative", func(t *testing.T) {
value := NewFloat64(-1)
assert.True(t, value.Negative())
})
}