File tree Expand file tree Collapse file tree 2 files changed +54
-1
lines changed Expand file tree Collapse file tree 2 files changed +54
-1
lines changed Original file line number Diff line number Diff line change @@ -208,7 +208,7 @@ func TestGetOrSet(t *testing.T) {
208
208
}
209
209
}
210
210
211
- func TestIterator (t * testing.T ) {
211
+ func TestForEach (t * testing.T ) {
212
212
m := New [int , * Animal ]()
213
213
214
214
m .ForEach (func (i int , a * Animal ) bool {
Original file line number Diff line number Diff line change
1
+ //go:build go1.23
2
+ // +build go1.23
3
+
4
+ package haxmap
5
+
6
+ import (
7
+ "testing"
8
+ )
9
+
10
+ func TestIterators (t * testing.T ) {
11
+ type Value = struct {
12
+ key int
13
+ }
14
+
15
+ m := New [int , * Value ]()
16
+
17
+ itemCount := 16
18
+ for i := itemCount ; i > 0 ; i -- {
19
+ m .Set (i , & Value {i })
20
+ }
21
+
22
+ t .Run ("iterator" , func (t * testing.T ) {
23
+ counter := 0
24
+ for k , v := range m .Iterator () {
25
+ if v == nil {
26
+ t .Error ("Expecting an object." )
27
+ } else if k != v .key {
28
+ t .Error ("Incorrect key/value pairs" )
29
+ }
30
+
31
+ counter ++
32
+ }
33
+
34
+ if counter != itemCount {
35
+ t .Error ("Iterated item count did not match." )
36
+ }
37
+ })
38
+
39
+ t .Run ("keys" , func (t * testing.T ) {
40
+ counter := 0
41
+ for k := range m .Keys () {
42
+ _ , ok := m .Get (k )
43
+ if ! ok {
44
+ t .Error ("The key is not is the map" )
45
+ }
46
+ counter ++
47
+ }
48
+
49
+ if counter != itemCount {
50
+ t .Error ("Iterated item count did not match." )
51
+ }
52
+ })
53
+ }
You can’t perform that action at this time.
0 commit comments