← IGCSE Computer Science Paper 2

Suggesting test data for length, presence and format checks

Test data for a check includes values that pass and fail it: for an 8-character minimum, 8 characters is accepted, 7 is rejected, and an empty string fails a presence check.

Understanding Suggesting test data for length, presence and format checks in IGCSE Computer Science Paper 2

What it does: Seven characters is one less than the minimum of 8, so it is the test value that fails the length check and the expected outcome is rejected. AB123 matches the pattern so it passes, while 1234A has the wrong pattern so it fails. Good test data shows both outcomes. A presence check only makes sure something has been entered. An empty string fails it. One letter passes it. An empty string has 0 characters. It is not present and it is shorter than 8, so both checks reject it.

Common mistakes: The minimum is 8 characters, so a password of exactly 8 must be accepted. > 8 would reject it. The condition should be >= 8. 'abcdefg' has only 7 characters. It is the test value one character too short, so the comment should say (7 chars).

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 71–82) and word search (Modules 71–92).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
A password must have at least 8 characters. What is the expected outcome for the test value Football (8 characters)?
Rejected, because it is exactly 8 charactersAccepted, because 8 characters meets the minimum
Matches
Length check (minimum 8): test data "abcd1234" accepted and "abcd12345" rejected
↓
The rejected value is 9 characters, which is longer than the minimum, so it would actually pass. The failing value should be one character too short, such as "abcd123" with 7 characters.
Applying
Meanings
Term
LENGTH(Password) >= 8
Meaning
Test data for a check includes values that pass and fail it: for an 8-character minimum, 8 characters is accepted, 7 is rejected, and an empty string fails a presence check.
Practice
// Test data for the Password checks
Testing
Gaps
IF LENGTH(Password) >= THEN
Check Answer
Spots
1IF LENGTH(Password) >= 8 THEN
2IF LENGTH(Password) > 8 THEN

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Octopus' badge — Multi-Tasker, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. A password must have at least 8 characters. What is the expected outcome for the test value Football (8 characters)?
A. Rejected, because it is exactly 8 characters
B. Accepted, because 8 characters meets the minimum ✓
Football has 8 characters. The rule is at least 8, so 8 passes the length check.
2. Which value is good test data for a password that is one character too short for the 8-character minimum?
A. Penguin (7 characters) ✓
B. Penguins (8 characters)
Penguin has 7 characters, so a length check should reject it. Penguins has 8 and would pass.
3. Which value should a presence check on a username reject?
A. An empty string ✓
B. A single letter such as a
A presence check only makes sure something has been entered. An empty string fails it. One letter passes it.
4. Which test data best checks the edge of an 8-character minimum length check?
A. Only a password with 30 characters
B. A password with 8 characters and one with 7 characters ✓
Test data should include values that pass and values that fail. 8 is accepted and 7 is rejected, so you test either side of the limit.
5. A format check requires a student ID of two letters then three digits, like AB123. Which value should be rejected?
A. 12ABC, because the pattern is wrong ✓
B. QR482, because it has too many letters
QR482 matches the pattern of two letters then three digits, so it is accepted. 12ABC has the digits and letters the wrong way round, so the format check rejects it.

Match the Pairs

LENGTH(Password) >= 8 → A length check for a minimum of 8 characters. Test data: "abcd1234" (8 characters) is accepted and "abcd123" (7 characters) is rejected.
Password <> "" → A presence check. Test data: an empty string "" is rejected, and any entry such as "abcd1234" is accepted.
Test data for a length check of 8 characters minimum should include a value that is one character too short, which must be rejected. → Test value "abcd123" -> LENGTH(Password) = 7 -> Rejected
Test data for a format check should include a value with the wrong pattern, such as a code with letters where digits are needed, which must be rejected. → Format: 2 letters then 3 digits -> "AB123" accepted, "1234A" rejected
Length check (minimum 8): test data "abcd1234" accepted and "abcd12345" rejected → The rejected value is 9 characters, which is longer than the minimum, so it would actually pass. The failing value should be one character too short, such as "abcd123" with 7 characters.
Presence check test data: "" accepted, "abcd1234" rejected → The outcomes are the wrong way round. The empty string should be rejected because nothing was entered, and "abcd1234" should be accepted because data is present.

Key Term

LENGTH(Password) >= 8
Test data for a check includes values that pass and fail it: for an 8-character minimum, 8 characters is accepted, 7 is rejected, and an empty string fails a presence check.

Fill in the Blanks

1. IF LENGTH(Password) >= 8 THEN OUTPUT "Accepted" ENDIF
Hint: Type the minimum number of characters; a test value with exactly this length is accepted.
2. IF LENGTH(Password) < 8 THEN OUTPUT "Too short" ENDIF
Hint: Type the relational operator that rejects a 7-character password.
3. IF LENGTH(Password) = 0 THEN OUTPUT "Please enter a password" ENDIF
Hint: Type the length of an empty string, the test value a presence check should reject.
4. Password ← "abcdefg" Valid ← LENGTH(Password) >= 8 // Expected result: FALSE
Hint: Type the BOOLEAN value the length check gives for this 7-character test value.
5. IF SUBSTRING(Code, 1, 2) = "AB" THEN OUTPUT "Format OK" ENDIF
Hint: Type the start position, so the format check starts at the first character.

Spot the Error

Question 1
A IF LENGTH(Password) >= 8 THEN
B IF LENGTH(Password) > 8 THEN
C ENDIF
Line B — The minimum is 8 characters, so a password of exactly 8 must be accepted. > 8 would reject it. The condition should be >= 8.
Question 2
A // Minimum length is 8
B // Test: 'abcdefgh' (8 chars)
C // Expected: accepted
D // Test: 'abcdefg' (8 chars)
E // Expected: rejected
Line D — 'abcdefg' has only 7 characters. It is the test value one character too short, so the comment should say (7 chars).
Question 3
A IF Password <> "" THEN
B OUTPUT "Enter a password"
C ENDIF
Line A — A presence check fails when nothing was entered, so the test must be for the empty string. It should be Password = "", not <>.
Question 4
A Password ← ""
B IF LENGTH(Password) = 0 THEN
C OUTPUT "Accepted"
D ENDIF
Line C — An empty string has length 0 and fails the presence check, so the expected outcome is Rejected, not Accepted.
Question 5
A // Format: 2 letters 3 digits
B ValidCode ← "A1B23"
C InvalidCode ← "1234A"
D // Expect: accepted, rejected
Line B — The valid test value must match the format of 2 letters then 3 digits. "A1B23" has the wrong pattern. It should be "AB123".

Student with a class code? Join your class →