Skip to content

Commit 01ff43b

Browse files
Merge pull request #169 from andygrunwald/set-unit-tests
Set: Add unit test for New with entries
2 parents 1546d99 + a56193b commit 01ff43b

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

set/dict_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,22 @@ func TestExists(t *testing.T) {
7676
}
7777
}
7878

79+
func TestExists_WithNewItems(t *testing.T) {
80+
set := New(`test`, `test1`)
81+
82+
if !set.Exists(`test`) {
83+
t.Errorf(`Correct existence not determined`)
84+
}
85+
86+
if !set.Exists(`test1`) {
87+
t.Errorf(`Correct existence not determined`)
88+
}
89+
90+
if set.Exists(`test2`) {
91+
t.Errorf(`Correct nonexistence not determined.`)
92+
}
93+
}
94+
7995
func TestLen(t *testing.T) {
8096
set := New()
8197
set.Add(`test`)
@@ -102,6 +118,19 @@ func TestFlattenCaches(t *testing.T) {
102118
}
103119
}
104120

121+
func TestFlattenCaches_CacheReturn(t *testing.T) {
122+
set := New()
123+
item := `test`
124+
set.Add(item)
125+
126+
flatten1 := set.Flatten()
127+
flatten2 := set.Flatten()
128+
129+
if !reflect.DeepEqual(flatten1, flatten2) {
130+
t.Errorf(`Flatten cache is not the same as original result. Got %+v, expected %+v`, flatten2, flatten1)
131+
}
132+
}
133+
105134
func TestAddClearsCache(t *testing.T) {
106135
set := New()
107136
item := `test`

0 commit comments

Comments
 (0)