forked from exercism/java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLuhnTest.java
More file actions
95 lines (72 loc) · 2.24 KB
/
LuhnTest.java
File metadata and controls
95 lines (72 loc) · 2.24 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
import org.junit.Test;
import org.junit.Ignore;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
public class LuhnTest {
@Test
public void checkDigitIsRightMostDigit() {
Luhn luhn = new Luhn(34567);
int expectedOutput = 7;
assertEquals(expectedOutput, luhn.getCheckDigit());
}
@Ignore
@Test
public void addendsDoublesEveryOtherNumberFromRight() {
Luhn luhn = new Luhn(12121);
int[] expectedOutput = new int[]{1, 4, 1, 4, 1};
assertArrayEquals(expectedOutput, luhn.getAddends());
}
@Ignore
@Test
public void addendsSubtracts9WhenDoubledNumberIsMoreThan9() {
Luhn luhn = new Luhn(8631);
int[] expectedOutput = new int[]{7, 6, 6, 1};
assertArrayEquals(expectedOutput, luhn.getAddends());
}
@Ignore
@Test
public void checkSumAddsAddendsTogether1() {
Luhn luhn = new Luhn(4913);
int expectedOutput = 22;
assertEquals(expectedOutput, luhn.getCheckSum());
}
@Ignore
@Test
public void checkSumAddsAddendsTogether2() {
Luhn luhn = new Luhn(201773);
int expectedOutput = 21;
assertEquals(expectedOutput, luhn.getCheckSum());
}
@Ignore
@Test
public void numberIsValidWhenChecksumMod10IsZero1() {
Luhn luhn = new Luhn(738);
boolean expectedOutput = false;
assertEquals(expectedOutput, luhn.isValid());
}
@Ignore
@Test
public void numberIsValidWhenChecksumMod10IsZero2() {
Luhn luhn = new Luhn(8739567);
boolean expectedOutput = true;
assertEquals(expectedOutput, luhn.isValid());
}
@Ignore
@Test
public void luhnCanCreateSimpleNumbersWithValidCheckDigit() {
long expectedOutput = 1230;
assertEquals(expectedOutput, Luhn.create(123));
}
@Ignore
@Test
public void luhnCanCreateLargeNumbersWithValidCheckDigit() {
long expectedOutput = 8739567;
assertEquals(expectedOutput, Luhn.create(873956));
}
@Ignore
@Test
public void luhnCanCreateHugeNumbersWithValidCheckDigit() {
long expectedOutput = 8372637564L;
assertEquals(expectedOutput, Luhn.create(837263756));
}
}