Repository navigation
Expand file tree
/
Copy pathLuhnValidatorTest.java
More file actions
134 lines (111 loc) · 3.69 KB
/
Copy pathLuhnValidatorTest.java
File metadata and controls
134 lines (111 loc) · 3.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import org.junit.Ignore;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class LuhnValidatorTest {
private LuhnValidator luhnValidator;
@Before
public void setUp() {
luhnValidator = new LuhnValidator();
}
@Test
public void testSingleDigitStringInvalid() {
assertFalse(luhnValidator.isValid("1"));
}
@Ignore("Remove to run test")
@Test
public void testSingleZeroIsInvalid() {
assertFalse(luhnValidator.isValid("0"));
}
@Ignore("Remove to run test")
@Test
public void testSimpleValidSINReversedRemainsValid() {
assertTrue(luhnValidator.isValid("059"));
}
@Ignore("Remove to run test")
@Test
public void testSimpleValidSINReversedBecomesInvalid() {
assertTrue(luhnValidator.isValid("59"));
}
@Ignore("Remove to run test")
@Test
public void testValidCanadianSINValid() {
assertTrue(luhnValidator.isValid("055 444 285"));
}
@Ignore("Remove to run test")
@Test
public void testInvalidCanadianSINInvalid() {
assertFalse(luhnValidator.isValid("055 444 286"));
}
@Ignore("Remove to run test")
@Test
public void testInvalidCreditCardInvalid() {
assertFalse(luhnValidator.isValid("8273 1232 7352 0569"));
}
@Ignore("Remove to run test")
@Test
public void testInvalidLongNumberWithAnEvenRemainder() {
assertFalse(luhnValidator.isValid("1 2345 6789 1234 5678 9012"));
}
@Ignore("Remove to run test")
@Test
public void testValidNumberWithAnEvenNumberOfDigits() {
assertTrue(luhnValidator.isValid("095 245 88"));
}
@Ignore("Remove to run test")
@Test
public void testValidNumberWithAnOddNumberOfSpaces() {
assertTrue(luhnValidator.isValid("234 567 891 234"));
}
@Ignore("Remove to run test")
@Test
public void testValidStringsWithANonDigitAtEndInvalid() {
assertFalse(luhnValidator.isValid("059a"));
}
@Ignore("Remove to run test")
@Test
public void testStringContainingPunctuationInvalid() {
assertFalse(luhnValidator.isValid("055-444-285"));
}
@Ignore("Remove to run test")
@Test
public void testStringContainingSymbolsInvalid() {
assertFalse(luhnValidator.isValid("055# 444$ 285"));
}
@Ignore("Remove to run test")
@Test
public void testSingleSpaceWithZeroInvalid() {
assertFalse(luhnValidator.isValid(" 0"));
}
@Ignore("Remove to run test")
@Test
public void testMoreThanSingleZeroValid() {
assertTrue(luhnValidator.isValid("0000 0"));
}
@Ignore("Remove to run test")
@Test
public void testDigitNineConvertedToOutputNine() {
assertTrue(luhnValidator.isValid("091"));
}
@Ignore("Remove to run test")
@Test
public void testUsingASCIIValueForNonDoubledNonDigitNotAllowed() {
assertFalse(luhnValidator.isValid("055b 444 285"));
}
@Ignore("Remove to run test")
@Test
public void testUsingASCIIValueForDoubledNonDigitNotAllowed() {
assertFalse(luhnValidator.isValid(":9"));
}
/* The following test diverges from the canonical test data. This is because the corresponding canonical test does
* not account for Java specific functions (such as Character.getNumericValue()), which can be part of incorrect yet
* passing implementations. For more detail, check out issue #972 here:
* (https://github.com/exercism/java/issues/972).
*/
@Ignore("Remove to run test")
@Test
public void testStringContainingSymbolsInvalidJavaTrackSpecific() {
assertFalse(luhnValidator.isValid("85&"));
}
}