• softwareTesting_work2_question1


    1. 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() {
          }
          
      
      }
    2. 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("单词"+"	"+"出现频率");
              for (Entry<String, Integer> obj : i.list) {
                  i.times=obj.getValue();
                  System.out.println(obj.getKey() + "	" + 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);
      //    }
      }
    3. //测试用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);
      // }
      }

    4. 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

    覆盖率

  • 相关阅读:
    unity opaque sort
    Vulkan --vulkan in powervr
    转载:C#中的Invoke理解一
    C#:实现快捷键自定义设置(转)
    C#中Thread.sleep() 【转载】
    winform窗体最大化、最小化、还原
    深入C#判断操作系统类型的总结详解(转载)
    2016年7月25日----总结(键盘点击事件、判断系统版本)
    正则表达式理解
    C# PInvoke(DllImport使用) 进阶教程(一)转
  • 原文地址:https://www.cnblogs.com/Phantom-void/p/5322951.html
Copyright © 2020-2023  润新知