package nmap_test import ( "git.noahlan.cn/noahlan/ntool/nmap" "git.noahlan.cn/noahlan/ntool/ntest/assert" "testing" ) func TestHasKey(t *testing.T) { var mp any = map[string]string{"key0": "val0"} assert.True(t, nmap.HasKey(mp, "key0")) assert.False(t, nmap.HasKey(mp, "not-exist")) assert.False(t, nmap.HasKey("abc", "not-exist")) } func TestHasAllKeys(t *testing.T) { var mp any = map[string]string{"key0": "val0", "key1": "def"} ok, noKey := nmap.HasAllKeys(mp, "key0") assert.True(t, ok) assert.Nil(t, noKey) ok, noKey = nmap.HasAllKeys(mp, "key0", "key1") assert.True(t, ok) assert.Nil(t, noKey) ok, noKey = nmap.HasAllKeys(mp, "key0", "not-exist") assert.False(t, ok) assert.Eq(t, "not-exist", noKey) ok, _ = nmap.HasAllKeys(mp, "invalid-map", "not-exist") assert.False(t, ok) }