|
@@ -14,55 +14,55 @@ public class LuhnValidatorTest {
|
14
|
14
|
}
|
15
|
15
|
|
16
|
16
|
@Test
|
17
|
|
- public void testThatSingleDigitStringIsNotValid() {
|
|
17
|
+ public void testSingleDigitStringInvalid() {
|
18
|
18
|
assertFalse(luhnValidator.isValid("1"));
|
19
|
19
|
}
|
20
|
20
|
|
21
|
21
|
@Ignore("Remove to run test")
|
22
|
22
|
@Test
|
23
|
|
- public void testThatTheStringConsistingOfASingleZeroIsInvalid() {
|
|
23
|
+ public void testSingleZeroIsInvalid() {
|
24
|
24
|
assertFalse(luhnValidator.isValid("0"));
|
25
|
25
|
}
|
26
|
26
|
|
27
|
27
|
@Ignore("Remove to run test")
|
28
|
28
|
@Test
|
29
|
|
- public void testThatASimpleValidNumberIsIdentifiedAsValid() {
|
30
|
|
- assertTrue(luhnValidator.isValid(" 5 9 "));
|
|
29
|
+ public void testSimpleValidSINReversedRemainsValid() {
|
|
30
|
+ assertTrue(luhnValidator.isValid("059"));
|
31
|
31
|
}
|
32
|
32
|
|
33
|
33
|
@Ignore("Remove to run test")
|
34
|
34
|
@Test
|
35
|
|
- public void testThatAValidCanadianSocialInsuranceNumberIsIdentifiedAsValidV1() {
|
36
|
|
- assertTrue(luhnValidator.isValid("046 454 286"));
|
|
35
|
+ public void testSimpleValidSINReversedBecomesInvalid() {
|
|
36
|
+ assertTrue(luhnValidator.isValid("59"));
|
37
|
37
|
}
|
38
|
38
|
|
39
|
39
|
@Ignore("Remove to run test")
|
40
|
40
|
@Test
|
41
|
|
- public void testThatAValidCanadianSocialInsuranceNumberIsIdentifiedAsValidV2() {
|
|
41
|
+ public void testValidCanadianSINValid() {
|
42
|
42
|
assertTrue(luhnValidator.isValid("055 444 285"));
|
43
|
43
|
}
|
44
|
44
|
|
45
|
45
|
@Ignore("Remove to run test")
|
46
|
46
|
@Test
|
47
|
|
- public void testThatAnInvalidCanadianSocialInsuranceNumberIsIdentifiedAsInvalid() {
|
48
|
|
- assertFalse(luhnValidator.isValid("046 454 287"));
|
|
47
|
+ public void testInvalidCanadianSINInvalid() {
|
|
48
|
+ assertFalse(luhnValidator.isValid("055 444 286"));
|
49
|
49
|
}
|
50
|
50
|
|
51
|
51
|
@Ignore("Remove to run test")
|
52
|
52
|
@Test
|
53
|
|
- public void testThatAnInvalidCreditCardIsIdentifiedAsInvalid() {
|
|
53
|
+ public void testInvalidCreditCardInvalid() {
|
54
|
54
|
assertFalse(luhnValidator.isValid("8273 1232 7352 0569"));
|
55
|
55
|
}
|
56
|
56
|
|
57
|
57
|
@Ignore("Remove to run test")
|
58
|
58
|
@Test
|
59
|
|
- public void testThatAddingANonDigitCharacterToAValidStringInvalidatesTheString() {
|
60
|
|
- assertFalse(luhnValidator.isValid("046a 454 286"));
|
|
59
|
+ public void testStringsContainingNonDigitInvalid() {
|
|
60
|
+ assertFalse(luhnValidator.isValid("055a 444 285"));
|
61
|
61
|
}
|
62
|
62
|
|
63
|
63
|
@Ignore("Remove to run test")
|
64
|
64
|
@Test
|
65
|
|
- public void testThatStringContainingPunctuationIsInvalid() {
|
|
65
|
+ public void testStringContainingPunctuationInvalid() {
|
66
|
66
|
assertFalse(luhnValidator.isValid("055-444-285"));
|
67
|
67
|
}
|
68
|
68
|
|
|
@@ -73,26 +73,38 @@ public class LuhnValidatorTest {
|
73
|
73
|
*/
|
74
|
74
|
@Ignore("Remove to run test")
|
75
|
75
|
@Test
|
76
|
|
- public void testThatStringContainingSymbolsIsInvalid() {
|
77
|
|
- assertFalse(luhnValidator.isValid("34&"));
|
|
76
|
+ public void testStringContainingSymbolsInvalidJavaTrackSpecific() {
|
|
77
|
+ assertFalse(luhnValidator.isValid("85&"));
|
78
|
78
|
}
|
79
|
79
|
|
80
|
80
|
@Ignore("Remove to run test")
|
81
|
81
|
@Test
|
82
|
|
- public void testThatTheStringConsistingOfASpaceAndASingleZeroIsInvalid() {
|
|
82
|
+ public void testStringContainingSymbolsInvalid() {
|
|
83
|
+ assertFalse(luhnValidator.isValid("055£ 444$ 285"));
|
|
84
|
+ }
|
|
85
|
+
|
|
86
|
+ @Ignore("Remove to run test")
|
|
87
|
+ @Test
|
|
88
|
+ public void testSingleSpaceWithZeroInvalid() {
|
83
|
89
|
assertFalse(luhnValidator.isValid(" 0"));
|
84
|
90
|
}
|
85
|
91
|
|
86
|
92
|
@Ignore("Remove to run test")
|
87
|
93
|
@Test
|
88
|
|
- public void testThatStringContainingMultipleZerosIsValid() {
|
89
|
|
- assertTrue(luhnValidator.isValid(" 00000"));
|
|
94
|
+ public void testMoreThanSingleZeroValid() {
|
|
95
|
+ assertTrue(luhnValidator.isValid("0000 0"));
|
90
|
96
|
}
|
91
|
97
|
|
92
|
98
|
@Ignore("Remove to run test")
|
93
|
99
|
@Test
|
94
|
|
- public void testThatDoublingNineIsHandledCorrectly() {
|
|
100
|
+ public void testDigitNineConvertedToOutputNine() {
|
95
|
101
|
assertTrue(luhnValidator.isValid("091"));
|
96
|
102
|
}
|
97
|
103
|
|
|
104
|
+ @Ignore("Remove to run test")
|
|
105
|
+ @Test
|
|
106
|
+ public void testStringsWithNonDigitsInvalid() {
|
|
107
|
+ assertFalse(luhnValidator.isValid(":9"));
|
|
108
|
+ }
|
|
109
|
+
|
98
|
110
|
}
|