-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathordered_test.go
72 lines (67 loc) · 1.45 KB
/
ordered_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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package vaddie
import (
"testing"
"time"
)
var orderedIntTests = []TestCase[int]{
{
Name: "eq",
ValidValues: []int{15},
InvalidValues: []int{13},
Validation: OrderedEq(15),
},
{
Name: "gt",
ValidValues: []int{16, 17},
InvalidValues: []int{13, 8},
Validation: OrderedGt(15),
},
{
Name: "gte",
ValidValues: []int{15, 18},
InvalidValues: []int{12, 6},
Validation: OrderedGte(15),
},
{
Name: "lt",
ValidValues: []int{14, 8},
InvalidValues: []int{15, 20},
Validation: OrderedLt(15),
},
{
Name: "lte",
ValidValues: []int{15, 3},
InvalidValues: []int{27, 50},
Validation: OrderedLte(15),
},
}
func Test_Ordered(t *testing.T) {
for _, tc := range orderedIntTests {
tc.Run(t)
}
}
var durationTests = []TestCase[time.Duration]{
{
Name: "equals",
ValidValues: []time.Duration{5 * time.Second},
InvalidValues: []time.Duration{10 * time.Second},
Validation: OrderedEq(5 * time.Second),
},
{
Name: "lte",
ValidValues: []time.Duration{10 * time.Second},
InvalidValues: []time.Duration{30 * time.Second},
Validation: OrderedLte(15 * time.Second),
},
{
Name: "gte",
ValidValues: []time.Duration{30 * time.Second},
InvalidValues: []time.Duration{10 * time.Second},
Validation: OrderedGte(15 * time.Second),
},
}
func Test_Duration(t *testing.T) {
for _, tc := range durationTests {
tc.Run(t)
}
}