TEST CASES
|
STEPS
|
LOCATIONS
|
EXPECTED OUTPUT
|
ACTUAL OUTPUT
|
1
|
1
|
-
|
Error Msg: Invalid input (# steps must > 1),
Prompt user
|
Enter locations: prompt
|
2
|
s
|
-
|
Error Message: Invalid input (not an integer)
Prompt user
|
Please re-enter a valid input
|
3
|
-1
|
-
|
Error Message: Invalid Input (must be positive)
Prompt user
|
Enter locations:
prompt
|
4
|
3
|
5, 10
|
Prompt user
|
Prompt User
|
5
|
5
|
2, 3, 6, 4, 10
|
Error Message: Invalid Input (must be greater than previous), Prompt User
|
6
(Wrong Output)
|
6
|
5
|
-1, 2, 4, 6, 10
|
Error Message: Invalid Input (must be positive), Prompt User
|
4
(Wrong Output)
|
7
|
5
|
2, 5, 8, l, 12
|
Error Message: Invalid input (not an integer)
Prompt user
|
Please re-enter a valid input
|
8
|
5
|
2, 3, 6, 4, e
|
Error Message: Invalid input (not an integer)
Error Message: Invalid Input (must be greater than previous)
Prompt User
|
Please re-enter valid input
|
9
|
5
|
-2, 4, 6, 5, 10
|
Error Message: Invalid Input (must be positive)
Error Message: Invalid Input (must be greater than previous)
Prompt User
|
6
(Wrong Output)
|
10
|
5
|
-10, 3, 5, 6
|
Error Message: Invalid Input (must be positive)
Prompt User
|
Prompt User
|
11
|
5
|
2, 4, 5, 3
|
Error Message: Invalid Input (must be greater than previous)
Prompt User
|
Prompt User
|
12
|
5
|
2, 4, 5, e
|
Error Message: Invalid Input (must be greater than previous), Error Message: (must be an integer)
Prompt User
|
Prompt user
|
13
|
5
|
-10, 2, 4, 3
|
Error Message: Invalid Input (must be positive)
Prompt User
|
Prompt User
|
14
|
5
|
2, 4, 6, 8, 12
|
Print Valid Output
|
4
|
1. Steps is not greater than 1
As per the condition s must be greater than 1, the program's output/action is not reflective of the expected output in that it continues to ask for the locations even though the input for steps is not greater than one. Logically, for there to be a "difference" there must be two or more locations. However this program does not seem to factor that in.
Here the input for steps is not an integer and therefore should not be accepted. As expected, the program rejects the letter 's' and asks the user for a valid input. It passes this test.
As a sub-section of that test, if a negative number is entered however the program accepts it and proceeds to ask for the locations. This is clearly a fault as it should only accept integers greater than 1 for the variable steps. Furthermore, logically, there is no such thing as a negative one step. When continued, if the user does enter a valid integer, the program simply prints "The largest difference is 0" which does not mean anything. It fails in this sense.
3. The number of locations entered is not the same as the value of steps
The program does as expected and waits for the user to input more locations until the number of locations entered is the same as the value of the steps. It does this in both entering the values one by one (each value entered after a carriage return) as well as in one line. It passes this test.
4. A location entered is less than a previous one
Here the program accepts all of the locations entered, even though the fourth location (4) is less than the previous one (6). This does not make sense logically as a subsequent step cannot be lower/closer to the ground than the previous one in a conventional ladder (wherein subsequent steps are higher than the last/previous). In turn, the program outputs the wrong answer (6 from 10 - 4), wherein it should have warned the user to re-enter that value or organise the values in such a way that they are in order.
5. A location entered is negative
Again the program simply accepts a negative number even though it does not make sense in the context. The distance of a location from the ground up cannot be measured in a negative sense. Therefore the program should warn the user of this fact and ask them to re-enter the value. Here it provides the wrong answer once more (4).
6. A location entered is not a whole, positive numerical number.
The locations entered in this example are 2, 5, 8, 'l' (the letter l). When each value is entered using a carriage return, the program catches the error as an 'l' is not a numerical number and asks the user for a valid input, reflecting the expected action in this case.
The same happens when the locations are entered in one line. The first value entered replaces the 'l' and the user has to input the remaining values again as well. However, even with the hindrance of inputting the value again, it does return the right answer.
7. A location entered is less than a previous one and it is not a whole, positive numerical number.
There are two rules not being fulfilled in this case. The fourth location (4) is less than the previous one (6) and an 'e' is entered as the last value. The program catches the error of the latter and asks the user to re-enter a valid input but does not do anything about the first problem. This poses as a problem as it will try to calculate the largest difference given the these values once the user inputs a replacement for the 'e'. This is clearly a fault.
8. A location entered is less than a previous one and a location is negative
Again, two rules are being violated in this case as the first location is a negative and should not be accepted and the fourth location (5) is not greater than the previous one (6) and should also not be accepted. The program does not catch either of these faults and proceeds to calculate the wrong largest difference between the values entered, leading to the wrong output of 6 (from 4 -- 2).
9. A location entered is negative and the number of locations entered does not equal the value of steps.
The program accepts the first value entered (-10) which it should not have (for reasons stated previously). However it waits for the user to keep entering values for locations until it reaches the number of steps. The only error here is that it accepts a negative value when it should not
10. A location entered is less than a previous one and there are not enough locations entered
The fourth location entered is 3 which is less than the previous (5). For reasons stated above, the program should not accept this as a valid input and should ask the user for a value greater than the previous. Clearly, this is a fault in the system. However, it does still keep prompting the user for more values until the number of locations filled equal the steps.
11. The number of locations entered is not enough, a location entered is less than a previous one and a location entered is not a whole numerical number.
Again, the program does not catch that a location entered is less than the previous one (i.e. the third input 3 is less than 4) and allows for that to be valid inputs. However it does catch that a letter 'e' is entered and asks the user to re-enter a valid input for that location. It also waits for the user to input 5 steps.
12. The number of locations entered is not enough, a location entered is less than a previous one and a location entered is a negative number.
In this case the program still accepts the negative number, which would lead to a wrong output in the end if the user manages to enter enough valid values. Here the program is still waiting for enough values to be entered until the number of locations equal the steps. As well as that, the fourth location (3) is less than the previous one (4), which the program does not warn against/catch, and will lead to the wrong output.
13. The steps entered is greater than 1 and is a whole, positive numerical number and if the locations entered equal the value of steps and each subsequent location entered is greater than the last and they are all whole, positive numerical numbers.
In this case, the user enters all of the inputs perfectly that is each subsequent number is greater than the one previous, they are all whole positive numbers and the user entered enough to reach the required number of steps. It produces the correct output.
CONCLUSION:
Through these tests, the program in question only managed to pass 3/13 tests (2, 3, 13). It shows that there are many faults within the code as it does not cater for many cases of invalid inputs such as:
- negative numbers
- where a location entered is less than the previous
- a combination of the two above.
As well as that, when the program does encounter an error it does not specify what a valid input is. Even if it catches certain faults such as when an input is a string or a character, it overlooks the other ones even if it happens in the same sequence. This could be solved by continually rejecting negative inputs and continually compare if the current input is greater than the previous one, before performing calculations on the set of data.



