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

    (1)实现的代码如下:

    package cn.gmh.mju;

     

    import java.util.Scanner;

     

    public class test2 {

     

       /**

        * @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();

          test2.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.gmh.mju;

     

    import static org.junit.Assert.*;

     

    import org.junit.Before;

    import org.junit.Test;

     

    public class test2Test {

     

       @Before

    public void setUp() throws Exception {

       }

     

       @Test

          public void test() throws Exception {

             String str="how are you";

             test2.test(str);

             }

       }

     结果如下:

  • 相关阅读:
    imac 截图

    [Python] 安装及环境配置
    冒泡算法
    [转载]分页+双向排序(jquery + ashx)
    【转载】jQuery最佳实践
    【转载】星级评分jQuery插件
    ie浏览器模式判断语句
    jQuery面向对象定制业务框架开发
    【转载】jQuery设计思想
  • 原文地址:https://www.cnblogs.com/guomeihong/p/5325505.html
Copyright © 2011-2022 走看看