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的更多相关文章
随机推荐
- 生产排产表DL-ZPPR002
*&---------------------------------------------------------------------* *& Report ZPPR002 * ...
- Scala学习(一)
最近在学习Scala,总结了一下比较基础的知识. 一.Scala简介 1.Scalable Language,是一门多范式的编程语言,是一种纯面向对象的语言,每个值都是对象. 2.特点:①Scalab ...
- SQL Server中Text和varchar(max)数据类型区别
SQL Server中Text和varchar(max)数据类型区别 以前只知道text和image是可能被SQL Server淘汰的数据类型,但具体原因不太清楚,今天读书的时候发现了text与v ...
- winform webbrowser flash显示
string flashSrc = "e:\\t.swf"; StringBuilder sb = new StringBuilder(); sb.Append("< ...
- running programmer——spring-01(初谈spring)
今天主要是通过一个简单的登录程序学习一些spring做基础的配置和功能. I.spring的核心配置applicationContext.xml 关于bean的配置官方给出的最基础的配置文件如下: & ...
- python网络编程【二】(使用UDP)
UDP通信几乎不使用文件对象,因为他们往往不能为数据如何发送和接受提供足够的控制.下面是一个基本的UPD客户端: #!/usr/bin/env python import socket,sys hos ...
- map 取值
1>可以取出Map中所有的键所在的Set集合:再通过Set的迭代器获取到每一个键,之后再用get();方法获得对应的值. public static void main(String[] arg ...
- OC基础--结构体 枚举做类成员属性
结构体 枚举作类的成员属性: 定义一个学生类 性别 -- 枚举 生日 入学日期 毕业日期 -- 结构体 代码示例: 声明文件 Student.h: #import <Foundation ...
- OpenLDAP安装
参考: http://54im.com/openldap/centos-6-yum-install-openldap-phpldapadmin-tls-%E5%8F%8C%E4%B8%BB%E9%85 ...
- 在iis7上如何配置来看到asp报错
今天网站改版时碰到一个问题,客户要求老网站的地图等功能要保持,但是老网站是用asp开发的.我们可以直接利用老的数据库以及老的代码,但是部署到新的服务器上一直报错. 刚开始是404,后来是500...今 ...