-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptional_isnothing_int_test.go
91 lines (79 loc) · 1.38 KB
/
optional_isnothing_int_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
package opt_test
import (
"testing"
"github.com/reiver/go-opt"
)
func TestOptional_IsNothing_int(t *testing.T) {
tests := []struct{
Optional opt.Optional[int]
Expected bool
}{
{
Optional: opt.Nothing[int](),
Expected: true,
},
{
Optional: opt.Something(-255),
Expected: false,
},
{
Optional: opt.Something(-5),
Expected: false,
},
{
Optional: opt.Something(-4),
Expected: false,
},
{
Optional: opt.Something(-3),
Expected: false,
},
{
Optional: opt.Something(-2),
Expected: false,
},
{
Optional: opt.Something(-1),
Expected: false,
},
{
Optional: opt.Something(0),
Expected: false,
},
{
Optional: opt.Something(1),
Expected: false,
},
{
Optional: opt.Something(2),
Expected: false,
},
{
Optional: opt.Something(3),
Expected: false,
},
{
Optional: opt.Something(4),
Expected: false,
},
{
Optional: opt.Something(5),
Expected: false,
},
{
Optional: opt.Something(255),
Expected: false,
},
}
for testNumber, test := range tests {
actual := test.Optional.IsNothing()
expected := test.Expected
if expected != actual {
t.Errorf("For test #%d, the actual value of is-nothing it not what was expected.", testNumber)
t.Logf("EXPECTED: %t", expected)
t.Logf("ACTUAL: %t", actual)
t.Logf("OPTIONAL: %#v", test.Optional)
continue
}
}
}