-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvalue_checker.go
121 lines (95 loc) · 2.17 KB
/
value_checker.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package hpcmodel
import (
"strings"
"time"
)
type StringValueChecker interface {
CheckValue(s string) bool
}
type StringEqualValueChecker struct {
ExpectedValue string
}
func (c *StringEqualValueChecker) CheckValue(s string) bool {
return s == c.ExpectedValue
}
type StringInValueChecker struct {
ExpectedValues []string
}
func (c *StringInValueChecker) CheckValue(s string) bool {
for _, v := range c.ExpectedValues {
if s == v {
return true
}
}
return false
}
type StringContainChecker struct {
ExpectedValue string
}
func (c *StringContainChecker) CheckValue(s string) bool {
return strings.Contains(s, c.ExpectedValue)
}
type NumberValueChecker interface {
CheckValue(s float64) bool
}
type NumberEqualValueChecker struct {
ExpectedValue float64
}
func (c *NumberEqualValueChecker) CheckValue(s float64) bool {
return s == c.ExpectedValue
}
type NumberGreaterValueChecker struct {
ExpectedValue float64
}
func (c *NumberGreaterValueChecker) CheckValue(s float64) bool {
return s > c.ExpectedValue
}
type NumberLessValueChecker struct {
ExpectedValue float64
}
func (c *NumberLessValueChecker) CheckValue(s float64) bool {
return s < c.ExpectedValue
}
type NumberInValueChecker struct {
ExpectedValues []float64
}
func (c *NumberInValueChecker) CheckValue(s float64) bool {
for _, v := range c.ExpectedValues {
if s == v {
return true
}
}
return false
}
type DateTimeValueChecker interface {
CheckValue(t time.Time) bool
}
type DateTimeEqualValueChecker struct {
ExpectedValue time.Time
}
func (c *DateTimeEqualValueChecker) CheckValue(t time.Time) bool {
return t.Equal(c.ExpectedValue)
}
type DateTimeAfterValueChecker struct {
ExpectedValue time.Time
}
func (c *DateTimeAfterValueChecker) CheckValue(t time.Time) bool {
return t.After(c.ExpectedValue)
}
type DateTimeBeforeValueChecker struct {
ExpectedValue time.Time
}
func (c *DateTimeBeforeValueChecker) CheckValue(t time.Time) bool {
return t.Before(c.ExpectedValue)
}
type DateTimeInValueChecker struct {
ExpectedValues []time.Time
}
func (c *DateTimeInValueChecker) CheckValue(t time.Time) bool {
for _, v := range c.ExpectedValues {
if t.Equal(v) {
return true
}
}
return false
}