1
1
import org .junit .jupiter .api .BeforeEach ;
2
2
import org .junit .jupiter .api .Disabled ;
3
+ import org .junit .jupiter .api .DisplayName ;
3
4
import org .junit .jupiter .api .Test ;
4
5
5
6
import static org .assertj .core .api .Assertions .assertThat ;
@@ -13,132 +14,154 @@ public void setUp() {
13
14
}
14
15
15
16
@ Test
17
+ @ DisplayName ("single digit strings can not be valid" )
16
18
public void testSingleDigitStringInvalid () {
17
19
assertThat (luhnValidator .isValid ("1" )).isFalse ();
18
20
}
19
21
20
22
@ Disabled ("Remove to run test" )
21
23
@ Test
24
+ @ DisplayName ("a single zero is invalid" )
22
25
public void testSingleZeroIsInvalid () {
23
26
assertThat (luhnValidator .isValid ("0" )).isFalse ();
24
27
}
25
28
26
29
@ Disabled ("Remove to run test" )
27
30
@ Test
31
+ @ DisplayName ("a simple valid SIN that remains valid if reversed" )
28
32
public void testSimpleValidSINReversedRemainsValid () {
29
33
assertThat (luhnValidator .isValid ("059" )).isTrue ();
30
34
}
31
35
32
36
@ Disabled ("Remove to run test" )
33
37
@ Test
38
+ @ DisplayName ("a simple valid SIN that becomes invalid if reversed" )
34
39
public void testSimpleValidSINReversedBecomesInvalid () {
35
40
assertThat (luhnValidator .isValid ("59" )).isTrue ();
36
41
}
37
42
38
43
@ Disabled ("Remove to run test" )
39
44
@ Test
45
+ @ DisplayName ("a valid Canadian SIN" )
40
46
public void testValidCanadianSINValid () {
41
47
assertThat (luhnValidator .isValid ("055 444 285" )).isTrue ();
42
48
}
43
49
44
50
@ Disabled ("Remove to run test" )
45
51
@ Test
52
+ @ DisplayName ("invalid Canadian SIN" )
46
53
public void testInvalidCanadianSINInvalid () {
47
54
assertThat (luhnValidator .isValid ("055 444 286" )).isFalse ();
48
55
}
49
56
50
57
@ Disabled ("Remove to run test" )
51
58
@ Test
59
+ @ DisplayName ("invalid credit card" )
52
60
public void testInvalidCreditCardInvalid () {
53
61
assertThat (luhnValidator .isValid ("8273 1232 7352 0569" )).isFalse ();
54
62
}
55
63
56
64
@ Disabled ("Remove to run test" )
57
65
@ Test
66
+ @ DisplayName ("invalid long number with an even remainder" )
58
67
public void testInvalidLongNumberWithAnEvenRemainder () {
59
68
assertThat (luhnValidator .isValid ("1 2345 6789 1234 5678 9012" )).isFalse ();
60
69
}
61
70
62
71
@ Disabled ("Remove to run test" )
63
72
@ Test
73
+ @ DisplayName ("invalid long number with a remainder divisible by 5" )
64
74
public void testInvalidLongNumberWithARemainderDivisibleBy5 () {
65
75
assertThat (luhnValidator .isValid ("1 2345 6789 1234 5678 9013" )).isFalse ();
66
76
}
67
77
68
78
@ Disabled ("Remove to run test" )
69
79
@ Test
80
+ @ DisplayName ("valid number with an even number of digits" )
70
81
public void testValidNumberWithAnEvenNumberOfDigits () {
71
82
assertThat (luhnValidator .isValid ("095 245 88" )).isTrue ();
72
83
}
73
84
74
85
@ Disabled ("Remove to run test" )
75
86
@ Test
87
+ @ DisplayName ("valid number with an odd number of spaces" )
76
88
public void testValidNumberWithAnOddNumberOfSpaces () {
77
89
assertThat (luhnValidator .isValid ("234 567 891 234" )).isTrue ();
78
90
}
79
91
80
92
@ Disabled ("Remove to run test" )
81
93
@ Test
94
+ @ DisplayName ("valid strings with a non-digit added at the end become invalid" )
82
95
public void testValidStringsWithANonDigitAtEndInvalid () {
83
96
assertThat (luhnValidator .isValid ("059a" )).isFalse ();
84
97
}
85
98
86
99
@ Disabled ("Remove to run test" )
87
100
@ Test
101
+ @ DisplayName ("valid strings with punctuation included become invalid" )
88
102
public void testStringContainingPunctuationInvalid () {
89
103
assertThat (luhnValidator .isValid ("055-444-285" )).isFalse ();
90
104
}
91
105
92
106
@ Disabled ("Remove to run test" )
93
107
@ Test
108
+ @ DisplayName ("valid strings with symbols included become invalid" )
94
109
public void testStringContainingSymbolsInvalid () {
95
110
assertThat (luhnValidator .isValid ("055# 444$ 285" )).isFalse ();
96
111
}
97
112
98
113
@ Disabled ("Remove to run test" )
99
114
@ Test
115
+ @ DisplayName ("single zero with space is invalid" )
100
116
public void testSingleSpaceWithZeroInvalid () {
101
117
assertThat (luhnValidator .isValid (" 0" )).isFalse ();
102
118
}
103
119
104
120
@ Disabled ("Remove to run test" )
105
121
@ Test
122
+ @ DisplayName ("more than a single zero is valid" )
106
123
public void testMoreThanSingleZeroValid () {
107
124
assertThat (luhnValidator .isValid ("0000 0" )).isTrue ();
108
125
}
109
126
110
127
@ Disabled ("Remove to run test" )
111
128
@ Test
129
+ @ DisplayName ("input digit 9 is correctly converted to output digit 9" )
112
130
public void testDigitNineConvertedToOutputNine () {
113
131
assertThat (luhnValidator .isValid ("091" )).isTrue ();
114
132
}
115
133
116
134
@ Disabled ("Remove to run test" )
117
135
@ Test
136
+ @ DisplayName ("very long input is valid" )
118
137
public void testVeryLongInputIsValid () {
119
138
assertThat (luhnValidator .isValid ("9999999999 9999999999 9999999999 9999999999" )).isTrue ();
120
139
}
121
140
122
141
@ Disabled ("Remove to run test" )
123
142
@ Test
143
+ @ DisplayName ("valid luhn with an odd number of digits and non zero first digit" )
124
144
public void testValidLuhnWithOddNumberOfDigitsAndNonZeroFirstDigit () {
125
145
assertThat (luhnValidator .isValid ("109" )).isTrue ();
126
146
}
127
147
128
148
@ Disabled ("Remove to run test" )
129
149
@ Test
150
+ @ DisplayName ("using ascii value for non-doubled non-digit isn't allowed" )
130
151
public void testUsingASCIIValueForNonDoubledNonDigitNotAllowed () {
131
152
assertThat (luhnValidator .isValid ("055b 444 285" )).isFalse ();
132
153
}
133
154
134
155
@ Disabled ("Remove to run test" )
135
156
@ Test
157
+ @ DisplayName ("using ascii value for doubled non-digit isn't allowed" )
136
158
public void testUsingASCIIValueForDoubledNonDigitNotAllowed () {
137
159
assertThat (luhnValidator .isValid (":9" )).isFalse ();
138
160
}
139
161
140
162
@ Disabled ("Remove to run test" )
141
163
@ Test
164
+ @ DisplayName ("non-numeric, non-space char in the middle with a sum that's divisible by 10 isn't allowed" )
142
165
public void testNonNumericNonSpaceCharInMiddleWithSumDivisibleBy10IsNotAllowed () {
143
166
assertThat (luhnValidator .isValid ("59%59" )).isFalse ();
144
167
}
@@ -150,7 +173,8 @@ public void testNonNumericNonSpaceCharInMiddleWithSumDivisibleBy10IsNotAllowed()
150
173
*/
151
174
@ Disabled ("Remove to run test" )
152
175
@ Test
153
- public void testStringContainingSymbolsInvalidJavaTrackSpecific () {
176
+ @ DisplayName ("string containing symbols is invalid (Java track specific)" )
177
+ public void testStringContainingSymbolsIsInvalidJavaTrackSpecific () {
154
178
assertThat (luhnValidator .isValid ("85&" )).isFalse ();
155
179
}
156
180
}
0 commit comments