Skip to content

Commit

Permalink
Merge pull request #169 from andygrunwald/set-unit-tests
Browse files Browse the repository at this point in the history
Set: Add unit test for New with entries
  • Loading branch information
tylertreat-wf authored May 3, 2017
2 parents 1546d99 + a56193b commit 01ff43b
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions set/dict_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,22 @@ func TestExists(t *testing.T) {
}
}

func TestExists_WithNewItems(t *testing.T) {
set := New(`test`, `test1`)

if !set.Exists(`test`) {
t.Errorf(`Correct existence not determined`)
}

if !set.Exists(`test1`) {
t.Errorf(`Correct existence not determined`)
}

if set.Exists(`test2`) {
t.Errorf(`Correct nonexistence not determined.`)
}
}

func TestLen(t *testing.T) {
set := New()
set.Add(`test`)
Expand All @@ -102,6 +118,19 @@ func TestFlattenCaches(t *testing.T) {
}
}

func TestFlattenCaches_CacheReturn(t *testing.T) {
set := New()
item := `test`
set.Add(item)

flatten1 := set.Flatten()
flatten2 := set.Flatten()

if !reflect.DeepEqual(flatten1, flatten2) {
t.Errorf(`Flatten cache is not the same as original result. Got %+v, expected %+v`, flatten2, flatten1)
}
}

func TestAddClearsCache(t *testing.T) {
set := New()
item := `test`
Expand Down

0 comments on commit 01ff43b

Please sign in to comment.