Practice question · Sort into groups
A function is meant to accept a whole number of items. Sort each test input by its kind.
Groups: Typical case · Edge case · Invalid case
- The text "hello" where a number is expected
- The number 0
- An empty list
- The number 7
Hints
- Typical inputs are ordinary; edge cases sit at the boundaries; invalid inputs should be rejected.
- Zero, an empty list, and the largest allowed value are all boundaries where bugs hide.
Show the answer
Typical case: The number 7
Edge case: The number 0, An empty list
Invalid case: The text "hello" where a number is expected
Why
Ordinary values like 7 and 12 are typical; zero, an empty list and the maximum are edges where bugs love to hide; non-numeric text is invalid and should be handled gracefully. Testing only typical cases is exactly the false confidence the lesson warns against.
Practise Testing Small Programs
The app has 5 more questions on this lesson, and keeps your place in the course. Computer Science I is free to start.
More questions on Testing Small Programs
- A program that passes one hundred typical-case tests is guaranteed to have no bugs.
- Order the steps of writing and running one test case.
- A test suite that passes on typical inputs can miss bugs that a handful of edge cases would catch…
- A test asserts that a function returns something, and passes even when the function returns the wrong answer.…
- A function takes a list of numbers. Select every input that is an edge case worth testing.