-
Notifications
You must be signed in to change notification settings - Fork 0
/
set_test.go
70 lines (55 loc) · 1.25 KB
/
set_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
package adt_test
import (
"adt"
. "github.com/onsi/gomega"
. "github.com/onsi/ginkgo"
)
var s *adt.Set
var _ = Describe("Set", func() {
BeforeEach(func() {
s = adt.NewSet()
})
Describe("Emptiness", func() {
Context("When the set does not contain items", func() {
It("Should be empty", func() {
Expect(s.IsEmpty()).To(BeTrue())
})
})
Context("When the set contains items", func() {
It("Should not be empty", func() {
s.Add("red")
Expect(s.IsEmpty()).To(BeFalse())
})
})
})
Describe("Size", func() {
Context("As items are added", func() {
It("Should return an increasing size", func() {
By("Empty set size being 0", func() {
Expect(s.Size()).To(BeZero())
})
By("Adding a first item", func() {
s.Add("red")
Expect(s.Size()).To(Equal(1))
})
By("Adding a second item", func() {
s.Add("blue")
Expect(s.Size()).To(Equal(2))
})
})
})
})
Describe("Contains", func() {
Context("When red has not been added", func() {
It("Should not contain red", func() {
Expect(s.Contains("red")).To(BeFalse())
})
})
Context("When red has been adding", func() {
It("Should contain red", func() {
s.Add("red")
Expect(s.Contains("red")).To(BeTrue())
})
})
})
})