Tier 2 · Write the test first
Test clamp before you trust it
Write the test first
Write asserts that prove clamp works, then check them.
The function should
clamp(x, lo, hi) returns x, but never below lo and never above hi.
Write assert lines that must be true for a correct function. Good tests also catch a wrong one.
Loading...
