-
Notifications
You must be signed in to change notification settings - Fork 0
/
misc_test.go
105 lines (93 loc) · 2.11 KB
/
misc_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
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
package stackage
import (
"testing"
)
var strInSliceMap map[int]map[int][]bool = map[int]map[int][]bool{
// case match
0: {
0: {true, true, true, true, true},
1: {true, true, true, true, true},
},
// case fold
1: {
0: {true, true, true, true, true},
1: {true, true, true, true, true},
},
}
func TestStrInSlice(t *testing.T) {
for idx, fn := range []func(string, []string) bool{
strInSlice,
strInSliceFold,
} {
for i, values := range [][]string{
{`cAndidate1`, `blarGetty`, `CANndidate7`, `squatcobbler`, `<censored>`},
{`Ó-aîï4Åø´øH«w%);<wï`, `piles`, `4378295fmitty`, string(rune(0)), `broccolI`},
} {
for j, val := range values {
result_expected := strInSliceMap[idx][i][j]
// warp the candidate value such that
// it no longer matches the slice from
// whence it originates. j² is used as
// its quicker and less stupid than
// adding a rand generator.
if isPowerOfTwo(j) {
var R []rune = []rune(val)
for g, h := 0, len(R)-1; g < h; g, h = g+1, h-1 {
R[g], R[h] = R[h], R[g]
}
val = string(R)
result_expected = !result_expected // invert
}
result_received := fn(val, values)
if result_expected != result_received {
t.Errorf("%s[%d->%d] failed; []byte(%v) in %v: %t (wanted %t)",
t.Name(), i, j, []byte(val), values, result_received, result_expected)
return
}
}
}
}
}
func TestDeref(t *testing.T) {
c := Cond(`this`, Eq, `that`)
ptr := &c
if T, V := derefPtr(ptr); V.IsZero() || T.Kind() == 0x0 {
t.Errorf("%s failed; pointer deref unsuccessful", t.Name())
return
}
}
func TestMiscCodecov(t *testing.T) {
for idx, val := range []any{
uint(1),
int(1),
uint8(1),
int8(1),
uint16(1),
int16(1),
uint32(1),
int32(1),
uint64(1),
int64(1),
} {
if idx%2 == 0 {
_ = uintStringer(val)
} else {
_ = intStringer(val)
}
}
for _, val := range []any{
complex64(1),
complex128(1),
} {
_ = complexStringer(val)
}
var ls logSystem
_ = ls.positive(1)
ls = logSystem{
log: cLogDefault,
}
_ = ls.positive(1)
logDiscard(nil)
logDiscard(sLogDefault)
_ = timestamp()
}