-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathevaluator_test.go
74 lines (65 loc) · 1.78 KB
/
evaluator_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
73
74
package statsig
import "testing"
func TestStringComparsigon(t *testing.T) {
eq := func(s1, s2 string) bool { return s1 == s2 }
if !compareStrings("a", "a", true, eq) {
t.Error("Expected string equality check to pass")
}
if !compareStrings("a", "A", true, eq) {
t.Error("Expected case-insensitive string equality check to pass")
}
if !compareStrings(true, "true", true, eq) {
t.Error("Expected boolean to string equality check to pass")
}
var numInt int = 1
if !compareStrings(numInt, "1", true, eq) {
t.Error("Expected integer to string equality check to pass")
}
type StringDefinition string
const (
A1 StringDefinition = "a"
)
if !compareStrings(A1, "a", true, eq) {
t.Error("Expected string custom definition equality check to pass")
}
type StringAlias = string
const (
A2 StringAlias = "a"
)
if !compareStrings(A2, "a", true, eq) {
t.Error("Expected string alias equality check to pass")
}
}
func TestNumericComparsigon(t *testing.T) {
eq := func(x, y float64) bool { return x == y }
var numInt int = 1
if !compareNumbers(numInt, 1, eq) {
t.Error("Expected int equality check to pass")
}
var numUInt uint = 1
if !compareNumbers(numUInt, 1, eq) {
t.Error("Expected uint equality check to pass")
}
var numFloat32 float32 = 1
if !compareNumbers(numFloat32, 1, eq) {
t.Error("Expected float32 equality check to pass")
}
var numFloat64 float64 = 1
if !compareNumbers(numFloat64, 1, eq) {
t.Error("Expected float64 equality check to pass")
}
type IntDefinition int
const (
Int1 IntDefinition = 1
)
if !compareNumbers(Int1, 1, eq) {
t.Error("Expected int custom definition equality check to pass")
}
type IntAlias = int
const (
Int2 IntAlias = 1
)
if !compareNumbers(Int2, 1, eq) {
t.Error("Expected int alias equality check to pass")
}
}