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