Password rules: lengths and combinations
beginner Equivalence partitioning Challenge 2 of 10
A sign-up form validates passwords before sending them to the server. The checker receives the password’s length and two flags that were computed from it.
Write tests that would catch a mistake in any implementation of the rule. They are run against the correct implementation, and then against seven buggy copies.
Requirements
- The length must be between 8 and 64 characters inclusive.
- The password must contain at least one digit.
- The password must contain at least one uppercase letter.
- The result is
validonly when all three conditions hold, otherwiseinvalid.
Expected output
Tests that match the specification and expose all 7 planted bugs.
Function under test
isValidPassword(length, hasDigit, hasUpper) → result
lengtha number (characters)hasDigittrue or falsehasUppertrue or false (has an uppercase letter)
How your tests are checked
- ○Every expected value agrees with the specification
- ○Your tests expose all 7 planted bugs
The correct implementation is the oracle. A bug counts as caught when one of your valid tests gives a different result on the buggy copy than on the correct code.
| # | lengthnumbercharacters | hasDigitboolean | hasUpperbooleanhas an uppercase letter | expected result | Remove |
|---|---|---|---|---|---|
| 1 |
Ctrl/⌘ + Enter to check tests · your tests are saved in this browser
Results
Check your tests to see which planted bugs they catch.