zoukankan      html  css  js  c++  java
  • 2016 Tianjin University Software Testing (homework2)

    Question one:Identify the fault.
    the answer:
    the first function :The for-loop misses the 0 index,so that should be -- for(int i=x.length-1;i>=0;i--)
    the second function: The for-loop is from beginning to the end ,but we want to find the last 0. So that should be -- for(int i=x.length-1;i>=0;i--)

    Question two:If possible, identify a test case that does not execute the fault. (Reachability)
    The answer:
    the first function:x==null will throw a NullPointerException and it doesn't enter the for-loop test ,so there is no fault to execute. Just like this: Input: x=null;y=0 Expected:NullPointerException The real output: NullPointerException
    the second function:there is not such a case.

    Question three:If possible, identify a test case that executes the fault, but does not result in an error state.
    The answer:
    the first function: the y doesn't appear in the first position,there is no error. Just like this: Input: x=[0,2,0];y= 2; Expected:1 The real output: 1
    the second function: if the for-loop just executes once, that should be ok. Because the first become the last. Just like this: Input: x=[0] Expected:1 The real output: 1

    Question four:If possible identify a test case that results in an error, but not a failure.
    The answer:
    the first function: the y doesn't appear in the x array. Just like this: Input: x=[0,2,0];y= 3; Expected:-1 The real output: -1
    the second function: if the for-loop just executes more than once and the 0 appears only once, that should be ok. Just like this: Input: x=[1,0,2] Expected:1 The real output: 1

  • 相关阅读:
    MySQL导出数据库、数据库表结构、存储过程及函数
    个人支付接口
    C# WPF,XAML 跨平台应用框架
    uniapp 第三方组件库
    C语言图形界面库
    微信小程序 获取cookie 以及设置 cookie
    stm32资源网
    找最长连续重复字母子串
    asp .net web api Swagger简单实用
    跨域问题
  • 原文地址:https://www.cnblogs.com/ida-xj/p/5264811.html
Copyright © 2011-2022 走看看