Exercise 3: An Off-by-One Bug the Original Suite Misses — Possible Solution ==================================================================== THE BUG ------------------------------ def calculate_shipping_offbyone_bug(weight, zone, express): ... if weight >= 50: base *= 0.9 # BUG: >= instead of > RESULTS AGAINST THE ORIGINAL 6 CHARACTERIZATION TESTS ------------------------------ (10, 'A', False): expected 5.0, got 5.0: PASS (10, 'B', False): expected 6.0, got 6.0: PASS (10, 'C', True): expected 17.5, got 17.5: PASS (-5, 'A', False): expected 0.0, got 0.0: PASS (10, 'Z', False): expected 10.0, got 10.0: PASS (60, 'A', False): expected 27.0, got 27.0: PASS Any of the 6 original tests caught the bug: False RESULT AGAINST EXERCISE 2'S OWN BOUNDARY TEST ------------------------------ weight=50: buggy version gives 22.5, characterization expected 25.0 Exercise 2's own test result against this bug: CAUGHT THE BUG WHY NONE OF THE ORIGINAL 6 CATCH IT ------------------------------ None of the original 6 inputs uses weight=50 exactly - the only test anywhere near the threshold is weight=60, which satisfies BOTH "weight > 50" and "weight >= 50" identically, so changing the operator produces no observable difference for that specific input. The bug is real and would affect any weight=50 order in production, but it's invisible to a test suite that never happens to probe that exact value. WHY THIS WORKS AS AN ANSWER ------------------------------ This is the chapter's own central caution made concrete: a characterization test suite is only as good as the inputs it was built from. A suite that passes completely can still miss a real regression, if the regression happens to only manifest on an input nobody thought to characterize. This is exactly why Exercise 2's own boundary-value test - discovered by deliberately probing the edge of a conditional, not by chance - matters: boundary values are disproportionately likely to expose exactly this class of bug, which is why deliberately testing them (rather than only "typical" values) is a core characterization testing skill, not an optional extra.