-
Notifications
You must be signed in to change notification settings - Fork 3
/
length_test.go
51 lines (41 loc) · 1.04 KB
/
length_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
package tests_test
import (
"testing"
tests "github.com/fino-digital/json-rule-engine"
)
func TestLengthTestWrongExpectedValue(t *testing.T) {
_, err := tests.NewStartsWithTest(123)
if err == nil {
t.Error("test should have only accepted strings as input")
}
}
func TestLengthTestWrongType(t *testing.T) {
test, err := tests.NewStartsWithTest("test")
if err != nil {
t.Error("failed to create test", err)
}
err = test.Run(123)
if err == nil {
t.Error("should have failed when number was passed as input")
}
}
func TestLengthTestWrongInput(t *testing.T) {
test, err := tests.NewStartsWithTest("test")
if err != nil {
t.Error("failed to create test", err)
}
err = test.Run("pew")
if err == nil {
t.Error("should have failed when non matching input was passed")
}
}
func TestLengthTestCorrectInput(t *testing.T) {
test, err := tests.NewStartsWithTest("test")
if err != nil {
t.Error("failed to create test", err)
}
err = test.Run("test2")
if err != nil {
t.Error("test should not have failed when given correct input")
}
}