首页 > 代码库 > Homework 2

Homework 2

  • No.1

  1. Fault:
    for (int i=x.length-1; i > 0; i--)
    should be
    for (int i=x.length-1; i >= 0; i--)
  2. Test: x = NULL; y=1
    Expected: NullPointerException
    Actual: NullPointerException
  3. Test: x=[1, 2, 3]; y=3
    Expected is 2;
    Actual is 2;
  4. Test: x=[1, 2, 3]; y=4
    Expected is -1;
    Actual is -1;

 

  • No.2

  1. Fault
    for (int i = 0; i < x.length; i++)
    should be
    for (int i = x.length-1; i>=0; i--)
  2. Test: x=[ ];
    Expected: NullPointerException
    Actual: NullPointerException
  3. Test: x=[0];
    Expected is 0;
    Actual is 0;
  4. Test: x=[1, 2, 3];
    Expected is -1;
    Actual is -1;

Homework 2