maputil: IsDisjoint (#43)

Verifies map a and map b have no keys in common.

if it returns true then the maps are disjoint otherwise a join in some form available
This commit is contained in:
donutloop authored and GitHub committed 2022-07-20 17:26:54 +08:00
1 parent ecf325a06c
commit 336e454ce7
4 files changed
+83

No files matched your search

+22
View File
@@ -148,3 +148,25 @@ func TestMinus(t *testing.T) {
assert.Equal(map[string]int{"c": 3}, Minus(m1, m2))
}
func TestIsDisjoint(t *testing.T) {
assert := internal.NewAssert(t, "TestMinus")
m1 := map[string]int{
"a": 1,
"b": 2,
"c": 3,
}
m2 := map[string]int{
"d": 22,
}
assert.Equal(true, IsDisjoint(m1, m2))
m3 := map[string]int{
"a": 22,
}
assert.Equal(false, IsDisjoint(m1, m3))
}