1
0
mirror of https://github.com/charlienet/go-mixed.git synced 2025-07-18 00:22:41 +08:00
This commit is contained in:
2022-05-12 11:32:03 +08:00
parent 7930a64e59
commit 08309e4a49
7 changed files with 85 additions and 37 deletions

25
maps/hash_map_test.go Normal file
View File

@ -0,0 +1,25 @@
package maps
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestForEach(t *testing.T) {
m := map[string]any{"b": "b", "a": "a", "d": "d", "c": "c"}
var hashMap = NewHashMap(map[string]any{"b": "b", "a": "a", "d": "d", "c": "c"})
assert.True(t, hashMap.Exist("a"))
assert.Equal(t, len(m), hashMap.Count())
hashMap.ForEach(func(s string, a any) {
if _, ok := m[s]; !ok {
t.Fatal("值不存在")
}
})
for k := range m {
assert.True(t, hashMap.Exist(k))
}
}