Skip to content

Commit

Permalink
test: add test for dict's Iter method.
Browse files Browse the repository at this point in the history
Signed-off-by: ghosind <ghosind@gmail.com>
  • Loading branch information
ghosind committed Oct 13, 2024
1 parent 183d67c commit 890d1f5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
19 changes: 19 additions & 0 deletions dict/dict_go123_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//go:build go1.23

package dict

import (
"github.com/ghosind/collection"
"github.com/ghosind/go-assert"
)

func testDictIter(a *assert.Assertion, m collection.Dict[int, int], data []int) {
n := 0

for k, v := range m.Iter() {
n++
a.EqualNow(v, data[k])
}

a.EqualNow(n, m.Size())
}
12 changes: 12 additions & 0 deletions dict/dict_pre_go123_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//go:build !go1.23

package dict

import (
"github.com/ghosind/collection"
"github.com/ghosind/go-assert"
)

func testDictIter(a *assert.Assertion, m collection.Dict[int, int], data []int) {
// Do nothing
}
2 changes: 2 additions & 0 deletions dict/dict_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ func testDict(a *assert.Assertion, m collection.Dict[int, int]) {

testDictForEach(a, m, data)

testDictIter(a, m, data)

testDictKeys(a, m)

testDictValues(a, m)
Expand Down

0 comments on commit 890d1f5

Please sign in to comment.