11import org .junit .jupiter .api .BeforeEach ;
22import org .junit .jupiter .api .Disabled ;
3+ import org .junit .jupiter .api .DisplayName ;
34import org .junit .jupiter .api .Test ;
45
56import static org .assertj .core .api .Assertions .assertThat ;
@@ -13,132 +14,154 @@ public void setUp() {
1314 }
1415
1516 @ Test
17+ @ DisplayName ("single digit strings can not be valid" )
1618 public void testSingleDigitStringInvalid () {
1719 assertThat (luhnValidator .isValid ("1" )).isFalse ();
1820 }
1921
2022 @ Disabled ("Remove to run test" )
2123 @ Test
24+ @ DisplayName ("a single zero is invalid" )
2225 public void testSingleZeroIsInvalid () {
2326 assertThat (luhnValidator .isValid ("0" )).isFalse ();
2427 }
2528
2629 @ Disabled ("Remove to run test" )
2730 @ Test
31+ @ DisplayName ("a simple valid SIN that remains valid if reversed" )
2832 public void testSimpleValidSINReversedRemainsValid () {
2933 assertThat (luhnValidator .isValid ("059" )).isTrue ();
3034 }
3135
3236 @ Disabled ("Remove to run test" )
3337 @ Test
38+ @ DisplayName ("a simple valid SIN that becomes invalid if reversed" )
3439 public void testSimpleValidSINReversedBecomesInvalid () {
3540 assertThat (luhnValidator .isValid ("59" )).isTrue ();
3641 }
3742
3843 @ Disabled ("Remove to run test" )
3944 @ Test
45+ @ DisplayName ("a valid Canadian SIN" )
4046 public void testValidCanadianSINValid () {
4147 assertThat (luhnValidator .isValid ("055 444 285" )).isTrue ();
4248 }
4349
4450 @ Disabled ("Remove to run test" )
4551 @ Test
52+ @ DisplayName ("invalid Canadian SIN" )
4653 public void testInvalidCanadianSINInvalid () {
4754 assertThat (luhnValidator .isValid ("055 444 286" )).isFalse ();
4855 }
4956
5057 @ Disabled ("Remove to run test" )
5158 @ Test
59+ @ DisplayName ("invalid credit card" )
5260 public void testInvalidCreditCardInvalid () {
5361 assertThat (luhnValidator .isValid ("8273 1232 7352 0569" )).isFalse ();
5462 }
5563
5664 @ Disabled ("Remove to run test" )
5765 @ Test
66+ @ DisplayName ("invalid long number with an even remainder" )
5867 public void testInvalidLongNumberWithAnEvenRemainder () {
5968 assertThat (luhnValidator .isValid ("1 2345 6789 1234 5678 9012" )).isFalse ();
6069 }
6170
6271 @ Disabled ("Remove to run test" )
6372 @ Test
73+ @ DisplayName ("invalid long number with a remainder divisible by 5" )
6474 public void testInvalidLongNumberWithARemainderDivisibleBy5 () {
6575 assertThat (luhnValidator .isValid ("1 2345 6789 1234 5678 9013" )).isFalse ();
6676 }
6777
6878 @ Disabled ("Remove to run test" )
6979 @ Test
80+ @ DisplayName ("valid number with an even number of digits" )
7081 public void testValidNumberWithAnEvenNumberOfDigits () {
7182 assertThat (luhnValidator .isValid ("095 245 88" )).isTrue ();
7283 }
7384
7485 @ Disabled ("Remove to run test" )
7586 @ Test
87+ @ DisplayName ("valid number with an odd number of spaces" )
7688 public void testValidNumberWithAnOddNumberOfSpaces () {
7789 assertThat (luhnValidator .isValid ("234 567 891 234" )).isTrue ();
7890 }
7991
8092 @ Disabled ("Remove to run test" )
8193 @ Test
94+ @ DisplayName ("valid strings with a non-digit added at the end become invalid" )
8295 public void testValidStringsWithANonDigitAtEndInvalid () {
8396 assertThat (luhnValidator .isValid ("059a" )).isFalse ();
8497 }
8598
8699 @ Disabled ("Remove to run test" )
87100 @ Test
101+ @ DisplayName ("valid strings with punctuation included become invalid" )
88102 public void testStringContainingPunctuationInvalid () {
89103 assertThat (luhnValidator .isValid ("055-444-285" )).isFalse ();
90104 }
91105
92106 @ Disabled ("Remove to run test" )
93107 @ Test
108+ @ DisplayName ("valid strings with symbols included become invalid" )
94109 public void testStringContainingSymbolsInvalid () {
95110 assertThat (luhnValidator .isValid ("055# 444$ 285" )).isFalse ();
96111 }
97112
98113 @ Disabled ("Remove to run test" )
99114 @ Test
115+ @ DisplayName ("single zero with space is invalid" )
100116 public void testSingleSpaceWithZeroInvalid () {
101117 assertThat (luhnValidator .isValid (" 0" )).isFalse ();
102118 }
103119
104120 @ Disabled ("Remove to run test" )
105121 @ Test
122+ @ DisplayName ("more than a single zero is valid" )
106123 public void testMoreThanSingleZeroValid () {
107124 assertThat (luhnValidator .isValid ("0000 0" )).isTrue ();
108125 }
109126
110127 @ Disabled ("Remove to run test" )
111128 @ Test
129+ @ DisplayName ("input digit 9 is correctly converted to output digit 9" )
112130 public void testDigitNineConvertedToOutputNine () {
113131 assertThat (luhnValidator .isValid ("091" )).isTrue ();
114132 }
115133
116134 @ Disabled ("Remove to run test" )
117135 @ Test
136+ @ DisplayName ("very long input is valid" )
118137 public void testVeryLongInputIsValid () {
119138 assertThat (luhnValidator .isValid ("9999999999 9999999999 9999999999 9999999999" )).isTrue ();
120139 }
121140
122141 @ Disabled ("Remove to run test" )
123142 @ Test
143+ @ DisplayName ("valid luhn with an odd number of digits and non zero first digit" )
124144 public void testValidLuhnWithOddNumberOfDigitsAndNonZeroFirstDigit () {
125145 assertThat (luhnValidator .isValid ("109" )).isTrue ();
126146 }
127147
128148 @ Disabled ("Remove to run test" )
129149 @ Test
150+ @ DisplayName ("using ascii value for non-doubled non-digit isn't allowed" )
130151 public void testUsingASCIIValueForNonDoubledNonDigitNotAllowed () {
131152 assertThat (luhnValidator .isValid ("055b 444 285" )).isFalse ();
132153 }
133154
134155 @ Disabled ("Remove to run test" )
135156 @ Test
157+ @ DisplayName ("using ascii value for doubled non-digit isn't allowed" )
136158 public void testUsingASCIIValueForDoubledNonDigitNotAllowed () {
137159 assertThat (luhnValidator .isValid (":9" )).isFalse ();
138160 }
139161
140162 @ Disabled ("Remove to run test" )
141163 @ Test
164+ @ DisplayName ("non-numeric, non-space char in the middle with a sum that's divisible by 10 isn't allowed" )
142165 public void testNonNumericNonSpaceCharInMiddleWithSumDivisibleBy10IsNotAllowed () {
143166 assertThat (luhnValidator .isValid ("59%59" )).isFalse ();
144167 }
@@ -150,7 +173,8 @@ public void testNonNumericNonSpaceCharInMiddleWithSumDivisibleBy10IsNotAllowed()
150173 */
151174 @ Disabled ("Remove to run test" )
152175 @ Test
153- public void testStringContainingSymbolsInvalidJavaTrackSpecific () {
176+ @ DisplayName ("string containing symbols is invalid (Java track specific)" )
177+ public void testStringContainingSymbolsIsInvalidJavaTrackSpecific () {
154178 assertThat (luhnValidator .isValid ("85&" )).isFalse ();
155179 }
156180}
0 commit comments