Question Constellation Sign up for free

AQA · GCSE · Computer Science · Higher

Boundary testing integer validation

Q03.2 2 marks
Figure 3
5int userNumber = Convert.ToInt32(Console.ReadLine());
6while (userNumber < 1 || userNumber > 100)
7{
8 Console.WriteLine("Invalid number");
9 userNumber = Convert.ToInt32(Console.ReadLine());
10}
11Console.WriteLine("Valid number entered");
Table 1
Test numberTest typeTest dataExpected result
[object Object][object Object][object Object][object Object]
[object Object][object Object][object Object][object Object]
[object Object][object Object][object Object][object Object]

Complete the test plan in Table 1 to test the validation of userNumber in the program in Figure 3.

Practice unavailable

This question can be viewed, but its original response format is not available for practice yet.

Write your answer first. You can study the marking guidance whenever you need it.

Study the marking See what earns credit and compare it with a full-mark answer.

Marking points

  1. 1 Completes the erroneous expected result and supplies valid normal data.
  2. 2 Supplies one accepted boundary datum with its matching expected result; cross-paired values are not accepted.

Full-mark answer

Test 1 expected result: Invalid number. Test 2 boundary example: test data 0 with expected result Invalid number. Test 3 normal test data: 50.

Why this answer loses marks

I chose a boundary value but paired it with the result from the wrong side of the valid range.

A boundary test only works when the datum and its expected valid or invalid outcome agree.