-
Notifications
You must be signed in to change notification settings - Fork 7
/
bool_test.go
105 lines (89 loc) · 2.88 KB
/
bool_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 pack_test
import (
"reflect"
"github.com/renproject/pack"
"github.com/renproject/pack/packutil"
"github.com/renproject/surge/surgeutil"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Bool", func() {
numTrials := 10
Context("when fuzzing", func() {
It("should not panic", func() {
for trial := 0; trial < numTrials; trial++ {
Expect(func() { surgeutil.Fuzz(reflect.TypeOf(pack.Bool(false))) }).ToNot(Panic())
Expect(func() { packutil.JSONFuzz(reflect.TypeOf(pack.Bool(false))) }).ToNot(Panic())
}
})
})
Context("when marshaling and then unmarshaling", func() {
It("should return itself", func() {
for trial := 0; trial < numTrials; trial++ {
Expect(surgeutil.MarshalUnmarshalCheck(reflect.TypeOf(pack.Bool(false)))).To(Succeed())
Expect(packutil.JSONMarshalUnmarshalCheck(reflect.TypeOf(pack.Bool(false)))).To(Succeed())
}
})
})
Context("when marshaling", func() {
Context("when the buffer is too small", func() {
It("should return itself", func() {
for trial := 0; trial < numTrials; trial++ {
Expect(surgeutil.MarshalBufTooSmall(reflect.TypeOf(pack.Bool(false)))).To(Succeed())
}
})
})
Context("when the remaining memory quota is too small", func() {
It("should return itself", func() {
for trial := 0; trial < numTrials; trial++ {
Expect(surgeutil.MarshalRemTooSmall(reflect.TypeOf(pack.Bool(false)))).To(Succeed())
}
})
})
})
Context("when unmarshaling", func() {
Context("when the buffer is too small", func() {
It("should return itself", func() {
for trial := 0; trial < numTrials; trial++ {
Expect(surgeutil.UnmarshalBufTooSmall(reflect.TypeOf(pack.Bool(false)))).To(Succeed())
}
})
})
Context("when the remaining memory quota is too small", func() {
It("should return itself", func() {
for trial := 0; trial < numTrials; trial++ {
Expect(surgeutil.UnmarshalRemTooSmall(reflect.TypeOf(pack.Bool(false)))).To(Succeed())
}
})
})
})
Context("when comparing", func() {
Context("when the booleans are equal", func() {
It("should return true", func() {
Expect(pack.NewBool(true).Equal(pack.NewBool(true))).To(BeTrue())
})
})
Context("when the booleans are not equal", func() {
It("should return false", func() {
Expect(pack.NewBool(true).Equal(pack.NewBool(false))).To(BeFalse())
})
})
})
Context("when stringifying", func() {
Context("when the boolean is true", func() {
It("should return \"true\"", func() {
Expect(pack.NewBool(true).String()).To(Equal("true"))
})
})
Context("when the boolean is false", func() {
It("should return \"false\"", func() {
Expect(pack.NewBool(false).String()).To(Equal("false"))
})
})
})
Context("when getting type information", func() {
It("should return the bool type", func() {
Expect(pack.NewBool(false).Type().Kind()).To(Equal(pack.KindBool))
})
})
})