forked from Antipitch/orwell
-
Notifications
You must be signed in to change notification settings - Fork 1
/
xor_test.go
33 lines (30 loc) · 816 Bytes
/
xor_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
package orwell
import (
"testing"
)
func TestApplyXOr(t *testing.T) {
t.Run("Ors not nil, value not nil", func(t *testing.T) {
r := &xOr{ors: []interface{}{1, 2}, msg: "test"}
if err := r.Apply("test"); err != nil {
t.Error("Expected valid")
}
})
t.Run("All ors empty, value not nil", func(t *testing.T) {
r := &xOr{ors: []interface{}{"", 0, nil}, msg: "test"}
if err := r.Apply("test"); err != nil {
t.Error("Expected error")
}
})
t.Run("Ors not nil, value nil", func(t *testing.T) {
r := &xOr{ors: []interface{}{"", 2}, msg: "test"}
if err := r.Apply(nil); err != nil {
t.Error("Expected valid")
}
})
t.Run("Ors empty, value nil", func(t *testing.T) {
r := &xOr{ors: []interface{}{}, msg: "test"}
if err := r.Apply(""); err == nil {
t.Error("Expected error")
}
})
}