Practice Testing in CS Thinking
Use these practice problems to test your method after reviewing the concept explanation and worked examples.
Quick Recap
Systematically running a program with known inputs to verify that its outputs are correct.
Try to break it before users do. Test normal cases, edge cases, and error cases.
Example 1
easyA function isEven(n) should return TRUE if n is even and FALSE otherwise. Suggest three test cases, including a normal, boundary, and erroneous value.
Example 2
mediumA program grades students: 90-100 = A, 80-89 = B, 70-79 = C, 60-69 = D, below 60 = F. Design a complete set of test data including boundary values.
Example 3
mediumA password validation function requires: at least 8 characters, at least one uppercase letter, and at least one digit. Design test cases that check each requirement independently.
Example 4
hardExplain the difference between white-box and black-box testing. Which approach would you use to test a sorting function, and why?