zoukankan      html  css  js  c++  java
  • 实验三 白盒测试

    1.

    package wjz;

     

    import java.util.*;

    public class test {

    /**

    *

    * @param args

    */

    public static void main(String[] args){

    test x = new test();

    x.view();

    }

     

    public void view(){

    Scanner in = new Scanner(System.in);

    int number1 = 1;

    int number2 = 1;

     

    System.out.print("请输入第一个数:");

    number1 = in.nextInt();

    System.out.print("请输入第二个数:");

    number2 = in.nextInt();               //输出最大公约数

    System.out.println(number1+"和"+number2+"的最大公约数为:"+das(number1,number2));

    }

     

     

    public static int das(int number1,int number2){

     

    int a= 3;

    int i=1;

    for(a=3;a<=number1 && a<=number2;a++ ){

    if(number1%a==0&&number2%a==0){

        i=a;

    break;

    }

    }

    return a;

    }

    2.语句覆盖

    路径:aef  aeg  abc

    测试用例:x=5,y=0

                    x=4,y=0

              x=2,y=2

    分支覆盖

    路径:aeg  aef  abd

    测试用例:x=1,y=2

              x=1,y=1

                    x=4,y=0

              x=5,y=0

    package wjz;

     

    import java.util.*;

     

    public class whitebox {

    void view(int x, int y){

    if(x < 4 || y > 0){

    if(y > 1){

    y = y + 1;

    }

    }else{

    if(x >= 5){

    x = x - y;

    System.out.println("输出结果:x=" + x);

    }

    else{

    x = x + y;

    }

    }

     

    System.out.println("输出结果:y=" + y);

     

     

    }

    public static void main(String[] args) {

    // TODO Auto-generated method stub

    Scanner x = new Scanner(System.in);

    System.out.println("请输入x的 值:");

    int num1= x.nextInt();

    System.out.println("请输入y的 值:");

    int num2 = x.nextInt();

    whitebox p = new whitebox();

    p.view(num1, num2);

    }

     

    }

     

  • 相关阅读:
    父亲对子女的话
    开通博客
    在linux下安装MySQLdb及基本操作
    java 词汇表速查手册
    java数据源的几种配置
    DBCP的参数配置
    Linux crontab定时执行任务
    很好看的Button CSS.
    C# 创建活动目录.txt
    解密存储过程
  • 原文地址:https://www.cnblogs.com/Ssatan/p/5393780.html
Copyright © 2011-2022 走看看