-
Notifications
You must be signed in to change notification settings - Fork 3
/
xandor_test.go
38 lines (36 loc) · 1.03 KB
/
xandor_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
package orwell
import (
"testing"
)
func TestApplyXAndOr(t *testing.T) {
t.Run("And not nil, ors not nil, value not nil", func(t *testing.T) {
r := &xAndOr{and: "not nil", ors: []interface{}{1, 2}, msg: "test"}
if err := r.Apply("test"); err != nil {
t.Error("Expected valid")
}
})
t.Run("And not nil, ors not nil, value nil", func(t *testing.T) {
r := &xAndOr{and: "not nil", ors: []interface{}{1, 2}, msg: "test"}
if err := r.Apply(nil); err != nil {
t.Error("Expected valid")
}
})
t.Run("And not nil, ors nil, value not nil", func(t *testing.T) {
r := &xAndOr{and: "not nil", msg: "test"}
if err := r.Apply("test"); err != nil {
t.Error("Expected valid")
}
})
t.Run("And nil, ors nil, value nil", func(t *testing.T) {
r := &xAndOr{msg: "test"}
if err := r.Apply("test"); err != nil {
t.Error("Expected valid")
}
})
t.Run("And not nil, ors nil, value nil", func(t *testing.T) {
r := &xAndOr{and: "not nil", msg: "test"}
if err := r.Apply(nil); err == nil {
t.Error("Expected error")
}
})
}