51Testing软件测试论坛
标题:
白盒测试--求教各位高手
[打印本页]
作者:
player
时间:
2014-4-21 15:24
标题:
白盒测试--求教各位高手
大家好,有没有哪位高手能帮助我回答一下下面的问题:谢谢
四、 单元测试(需源码)
有一个diff函数,2个参数,1,2都是map类型,以map1为标准,取map2和map1中key对应的value相等时对应的value的集合。函数如下:
public Map<String, String> diffMap(Map<String, String> map1,Map<String, Object> map2) {
Map<String, String> result = new HashMap<String, String>();
if (map1 == null || map1.size() == 0 || map2 == null) {
return result;
}
for (Entry<String, String> entry : map1.entrySet()) {
String key = entry.getKey();
String value1 = entry.getValue();
if (StringUtils.isEmpty(value1)) {
continue;
}
Object value2 = map2.get(key);
if (value2 == null ) {
continue;
}
if (value2 instanceof String) {
if (value1.equals(value2)) {
result.put(key, value1);
}
} else if (value2 instanceof String[]) {
// 拆分value2再与value1进行对比,符合要求的加入result
} else {
continue;
}
}
return result;
}
请完成:
测试点
测试代码
作者:
player
时间:
2014-4-22 11:09
大家帮帮忙啊。
作者:
player
时间:
2014-4-22 11:13
大家多多指点呀,如果没有代码的话,给个思路或者方法也行,谢谢大家
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/)
Powered by Discuz! X3.2