forked from Antipitch/orwell
-
Notifications
You must be signed in to change notification settings - Fork 1
/
max_test.go
41 lines (39 loc) · 841 Bytes
/
max_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
package orwell
import (
"testing"
)
func TestApplyMax(t *testing.T) {
r := &max{max: 10, msg: "test"}
t.Run("Nil value", func(t *testing.T) {
if err := r.Apply(nil); err != nil {
t.Error("Expected valid")
}
})
t.Run("Valid int", func(t *testing.T) {
if err := r.Apply(9); err != nil {
t.Error("Expected valid")
}
})
t.Run("Valid int equal", func(t *testing.T) {
if err := r.Apply(10); err != nil {
t.Error("Expected valid")
}
})
t.Run("Invalid int", func(t *testing.T) {
if err := r.Apply(11); err == nil {
t.Error("Expected error")
}
})
t.Run("Valid Pointer", func(t *testing.T) {
i := 9
if err := r.Apply(&i); err != nil {
t.Error("Expected valid")
}
})
t.Run("Invalid Pointer", func(t *testing.T) {
i := 11
if err := r.Apply(&i); err == nil {
t.Error("Expected error")
}
})
}