zoukankan      html  css  js  c++  java
  • 软件测试第二次作业2

    (1)  把一个英语句子中的单词次序颠倒后输出。例如输入“how are you”,输出“you are how”;

    package cn.han.mju;

    import java.util.Scanner;

    public class test {

    /**
    * @param args
    */
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    Scanner input = new Scanner(System.in);

    System.out.print("请输入要测试的字符串:");
    String str = input.nextLine();
    test.test(str);
    }
    public static void test(String str){

    String[] strArr = str.split("\s+|[,]");

    StringBuffer result = new StringBuffer();

    for(int i = strArr.length -1;i >=0; i--){

    result.append(strArr[i] + " ");


    }

    result.setCharAt(str.length()-0, (char) 0);

    System.out.println("颠倒顺序后的字符串:: "+result.toString());

    }

     

    (2) 编写单元测试进行测试;

    代码:      

    package cn.hanzy.mju; 

    import static org.junit.Assert.*;

    import org.junit.Before;

    import org.junit.Test;

    public class testTest {

        @Before

        public void setUp() throws Exception {

        }

        @Test

        public void test() throws Exception {

            String str="how are you";

            Action action =new Action();

            action.findWord(str);;

            }

        }

    (3)用ElcEmma查看代码覆盖率,要求覆盖率达到100%。

  • 相关阅读:
    最短路径BellmanFord , Dijsktra
    minhash
    eclipse 中使用tomcat
    http 服务
    MongoDB小记
    java post 请求
    hadoop拾遗(五)---- mapreduce 输出到多个文件 / 文件夹
    weka数据挖掘拾遗(二)---- 特征选择(IG、chi-square)
    weka数据挖掘拾遗(一)---- 生成Arff格式文件
    基于SimHash的微博去重
  • 原文地址:https://www.cnblogs.com/hzzyii/p/5326852.html
Copyright © 2011-2022 走看看