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的更多相关文章
随机推荐
- 解决Gradle生成Eclipse支持后,发布到Tomcat丢失依赖jar包的问题
最近一个项目中,使用号称下一代构建工具的Gradle构建项目. 使用中发现一个问题,Gradle从中央库下载的jar文件在系统的其它目录,使用gradle eclipse添加Eclipse支持时,ja ...
- Process Explorer使用图文教程
这是一款由Sysinternals开发的Windows系统和应用程序监视工具,目前Sysinternals已经被微软收购,此款不仅结合了文件监视和注册表监视两个工具的功能,还增加了多项重要的增强功能, ...
- jquery 中 $.map 的使用方法
$.map(data,function(item,index){return XXX}) 遍历data数组中的每个元素,并按照return中的计算方式 形成一个新的元素,放入返回的数组中 ,,], f ...
- PHP发送电子邮件
1.导入文件,如本案例把Stmp.class.php放到Common\Common目录下,代码很多,直接复制就行! <?php namespace Common\Common; class Sm ...
- [原创]WPF资源Binding自定义集合类。
简单介绍一下Wpf资源字典: 每个WPF界面元素都有一个名为Resource的属性,这个属性继承至FrameworkElement类,其类型为ResourceDictionary.ResourceDi ...
- Microsoft.Office.Interop.Excel操作Excel文件时出现的问题及解决方案
问题描述: Microsoft.Office.Interop.Excel.Worksheet 打不开文件 Microsoft Office Excel 不能访问文件"a.xls". ...
- iOS 开发之控件快速学习(一)
最近一个朋友想转iOS所以我开始写一些初级iOS学习博客!也希望第一些初学的朋友有所帮助,!好吧进入今天的正题,我们今天主要完成如下界面的显示! 好的一起打开Xcode一下几步我截图说明:
- XML 详解
import urllib import requests from xml.etree import ElementTree as ET root = ET.XML(open('D:\E\seman ...
- jstl_fmt
<fmt:formatDate value="${isoDate}" type="both"/>2004-5-31 23:59:59<fmt: ...
- Codeforces Round #380 (Div. 1, Rated, Based on Technocup 2017 - Elimination Round 2)
http://codeforces.com/contest/737 A: 题目大意: 有n辆车,每辆车有一个价钱ci和油箱容量vi.在x轴上,起点为0,终点为s,中途有k个加油站,坐标分别是pi,到每 ...