Study guide: Validate and Test Reusable Rules
Test inclusive thresholds, validate inputs and count results from a reusable rule.
Ideas to explain in your own words
- Choose test cases below, at, and above a rule’s threshold.
- Reject values outside a stated whole-number input contract.
- Pass a threshold into a function without changing its comparison.
- Filter invalid inputs before counting those that meet a threshold.
Watch your reasoning
- Exactly 10 satisfies “at least 10,” so the expected message is Goal reached. The incorrect rule “more than 10” would exclude 10, which is why this boundary test matters.
- 30 is a whole number at the included upper end of the range and is at least 10. It is valid and gets Goal reached.
- The inputs satisfy the stated contract and 7 ≥ 7 is true. The function returns reached; it does not add the parameters.
- 10 and 30 are accepted and at least 10. 40 is rejected and 5 is below the goal, so the count is 2.
A worked review example
Test an Algorithm at Its Boundary: Input 9 gives Keep going. Input 10 gives Goal reached because equality satisfies “at least.” Input 11 also gives Goal reached. Check an Input Before Using It: Rows: −1 → invalid; 0 → Keep going; 9 → Keep going; 10 → Goal reached; 30 → Goal reached; 31 → invalid; 2.5 → invalid. Both ends of the allowed range are included. Reuse a Rule with a Parameter: status(8, 6) evaluates 8 ≥ 6 and returns reached. status(8, 10) evaluates 8 ≥ 10 and returns continue. status(6, 6) returns reached because equality is included. Count Accepted Results: 9 is valid but below goal; 10 qualifies; 31 is invalid; 12 qualifies; −1 is invalid; 0 is below goal. Running counts: 0, 1, 1, 2, 2, 2. Final reached_count = 2.
Make a practice plan
- Try the supplied lesson problems without looking at the answers.
- Compare your method with the worked examples and explain any correction.
- Use the new review cases, then complete the transfer task on paper or in your own document.