- fixed TestDictKeysMan bug

- order api added.
This commit is contained in:
gazebo
2018-06-06 11:37:25 +08:00
parent a27ae4d732
commit 8c412fc2f0
3 changed files with 50 additions and 9 deletions

View File

@@ -15,16 +15,22 @@ func (t TT) foo() {
}
func TestDictKeysMan(t *testing.T) {
testData := map[string]string{"k1": "v1", "k2": "v2"}
testData := map[string]interface{}{"k1": "v1", "k2": "v2"}
result1 := DictKeysMan(testData, []string{"k1"}, nil).(map[string]interface{})
if _, ok := result1["k1"]; ok {
t.Error("Params keysToRemove can not remove key!")
}
if _, ok := result1["k2"]; !ok {
if k2Value, ok := result1["k2"]; !ok {
t.Error("Params keysToRemove removed wrong key!")
} else {
k2ValueStr, _ := k2Value.(string)
if k2ValueStr != "v2" {
t.Logf("k2Value:%s", k2ValueStr)
t.Error("wrong data when removeKeys")
}
}
result2 := DictKeysMan([]interface{}{testData}, nil, []string{"k1"}).([]interface{})
result2 := DictKeysMan([]interface{}{testData, map[string]string{"k1": "v11", "k2": "v22"}}, nil, []string{"k1"}).([]interface{})
result20 := result2[0].(map[string]interface{})
if _, ok := result20["k1"]; !ok {
t.Error("Params keysToKeep can not keep key!")