softwareTesting_work2_question1
- input类
package com.Phantom; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry; public class inputs {
public int times;
public int getTimes() {
return times;
}
public void setTimes(int times) {
this.times = times;
}
public inputs(int times, String words) {
super();
this.times = times;
this.words = words;
} public String words;
Map<String, Integer>map=new HashMap<String, Integer>();
List<Entry<String, Integer>>list=new ArrayList<Map.Entry<String,Integer>>();
// public String getWords() {
// return words;
// }
public void setWords(String words) {
this.words = words;
} public Map<String, Integer> getMap() {
return map;
}
// public void setMap(Map<String, Integer> map) {
// this.map = map;
// }
// public List<Entry<String, Integer>> getList() {
// return list;
// }
// public void setList(List<Entry<String, Integer>> list) {
// this.list = list;
// } public inputs() {
} } - operation类
package com.Phantom; import java.util.Collections;
import java.util.Comparator;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.Set; public class operation {
inputs i=new inputs();
public String in(int times,String input){
Scanner in=new Scanner(System.in);
String words=in.nextLine(); i.setWords(words);
String[] items = words.split(" "); for(String s:items){
if (i.map.containsKey(s)) {
i.map.put(s, i.map.get(s)+1);
}
else{
i.map.put(s, 1);
}
} for(Entry<String, Integer>entry:i.map.entrySet()){
i.list.add(entry);
} System.out.println("单词"+"\t"+"出现频率");
for (Entry<String, Integer> obj : i.list) {
i.times=obj.getValue();
System.out.println(obj.getKey() + "\t" + i.times);
}
//测试
// System.out.println(i.map);
// System.out.println(i.map.values());
// i.map.put("aaa", 3);
// Set<Entry<String, Integer>>e=i.map.entrySet();
// System.out.println(i.map);
// System.out.println(i.map.get("aaa"));
// System.out.println(i.map.values().size());
// System.out.println(i.map.toString());
return words;
} //测试
// public static void main(String[] args) {
// // TODO Auto-generated method stub
// System.out.println("请输入内容:");
// inputs i=new inputs(0, null);
// operation o=new operation();
// o.in(0, null);
// }
} //测试用main函数
// public static void main(String[] args) {
// // TODO Auto-generated method stub
// System.out.println("请输入内容:");
// inputs i=new inputs(0, null);
// operation o=new operation();
// o.in(0, null);
// }
}- testing类
package com.Phantom; import static org.junit.Assert.*;
import junit.framework.TestCase; import org.junit.Before;
import org.junit.Test; public class testingOperation extends TestCase{
private operation o1;
inputs i1=new inputs(0, null);
@Before
public void setUp() throws Exception {
super.setUp();
o1=new operation();
} public void testOperation() {
i1.setWords("aaa aaa aaa");
i1.setTimes(3);
i1.map.put("aaa", 3);
assertTrue(o1.in(i1.getTimes(), i1.map.toString())==i1.map.get("aaa")+"aaa aaa aaa");} @Override
protected void tearDown() throws Exception {
// TODO Auto-generated method stub
super.tearDown();
System.out.println("getMap"+i1.getMap());
} }
junit

覆盖率

softwareTesting_work2_question1的更多相关文章
随机推荐
- SharePoint Foundation 2013 安装出错
前段时间装foundation 13的时候遇到这个问题.怀疑是Office的问题.然后找了一些资料,问题得到了解决 解决方案: 运行 regedit,删除注册表下的office的LicenseType ...
- mybatis高级(2)_数据库中的列和实体类不匹配时的两种解决方法_模糊查询_智能标签
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "- ...
- Windows Store App JavaScript 开发:WinJS库控件
在介绍了如何使用标准的HTML控件以及WinJS库中提供的新控件之后,下面来着重介绍WinJS库中几种常用的控件. (1)ListView控件 在开发Windows应用商店应用时可以使用ListVie ...
- nmon--非常棒的LINUX/AIX性能计数器监测和分析工具
转自51Testinghttp://bbs.51testing.com/viewthread.php?tid=116526 经常看到很多人讨论说loadrunner对linux/aix的性能监测太少, ...
- 【思路】-jscode
jscode //1.0 思路 //VH.PutSet(TagFields.PageName, PageName.Index); ...
- 使用 AngularJS 和 Electron 构建桌面应用
GitHub 的 Electron 框架(以前叫做 Atom Shell)允许你使用 HTML, CSS 和 JavaScript 编写跨平台的桌面应用.它是io.js 运行时的衍生,专注于桌面应用而 ...
- cacti监控juniper路由器
之前也没有写过博客,但是最近一直在做监控.从网上查找很多资料都还是感觉差一点.所以自己添加一份我在cacti监控路由器的步骤. 环境,ubuntu14.04,apt-get install cacti ...
- RP4412开发板在Android系统编译生成ramdisk-uboot.img
荣品RP4412开发板在android系统编译的时候,怎么生成ramdisk-uboot.img生成流程分析: mkimage -A arm -O linux -T ramdisk -C none - ...
- 【图像处理】【SEED-VPM】1.注意点
1. 新装系统要启动NFX 每次虚拟机复位要执行以下命令 /usr/sbin/exportfs -av /sbin/service nfs restart —————————————————————— ...
- algorithm -- 基本介绍
为学习算法和使用.实践 GIT & GitHub ,而写此系列. 我使用的编译器是 visual studio community 2015 低版本的VS打不开GitHub中的解决方案,拷贝代 ...