-
Notifications
You must be signed in to change notification settings - Fork 3
/
in_test.go
39 lines (35 loc) · 835 Bytes
/
in_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
package orwell
import (
"testing"
)
func TestApplyInWithIntegers(t *testing.T) {
r := in{args: []interface{}{1, 2, 3}, 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(2); err != nil {
t.Error("Expected valid")
}
})
t.Run("Invalid int", func(t *testing.T) {
if err := r.Apply(4); err == nil {
t.Error("Expected error")
}
})
}
func TestApplyInWithStrings(t *testing.T) {
r := in{args: []interface{}{"1", "2", "3"}, msg: "test"}
t.Run("Valid string", func(t *testing.T) {
if err := r.Apply("2"); err != nil {
t.Error("Expected valid")
}
})
t.Run("Invalid string", func(t *testing.T) {
if err := r.Apply("4"); err == nil {
t.Error("Expected error")
}
})
}