feat: add GetOrSet

This commit is contained in:
dudaodong committed 2024-06-24 17:28:51 +08:00
1 parent aeef0418a4
commit a220220f09
5 files changed
+122

No files matched your search

+16
View File
@@ -691,3 +691,19 @@ func TestToSortedSlicesWithComparator(t *testing.T) {
})
}
}
func TestGetOrSet(t *testing.T) {
t.Parallel()
assert := internal.NewAssert(t, "TestGetOrSet")
m := map[int]string{
1: "a",
}
result1 := GetOrSet(m, 1, "1")
result2 := GetOrSet(m, 2, "b")
assert.Equal("a", result1)
assert.Equal("b", result2)
}