标签:
第二题
实现代码如下:
package com.liu.ST2;
import java.util.Scanner;
public class Question2 {
public static void reverse(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("请输入英文:");
String str = input.nextLine();
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, ‘ ‘);
System.out.println("颠倒顺序后的结果为:" + result.toString());
}
}
Junit测试代码如下:
package com.liu.ST2;
import static org.junit.Assert.*;
import org.junit.Test;
public class Question2Test {
@Test
public void test() {
Question2 q2 = new Question2();
q2.reverse(null);;
}
}
Junit测试及ElcEmma覆盖率如下:
因第二次只测试第二题,并没有测试第一题,所以第一题的覆盖率为0%.
标签:
原文地址:http://www.cnblogs.com/lmxiyt/p/5324321.html