mirror of
https://github.com/charlienet/go-mixed.git
synced 2025-07-18 00:22:41 +08:00
fix err
This commit is contained in:
25
maps/hash_map_test.go
Normal file
25
maps/hash_map_test.go
Normal 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))
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user