feat: add ForEach func

This commit is contained in:
dudaodong committed 2022-03-30 19:41:55 +08:00
1 parent 1a436aeb41
commit 3ad142d5d7
2 files changed
+26

No files matched your search

+19
View File
@@ -62,3 +62,22 @@ func TestMerge(t *testing.T) {
assert.Equal(expected, acturl)
}
func TestForEach(t *testing.T) {
assert := internal.NewAssert(t, "TestForEach")
m := map[string]int{
"a": 1,
"b": 2,
"c": 3,
"d": 4,
}
var sum int
ForEach(m, func(_ string, value int) {
sum += value
})
assert.Equal(10, sum)
}