|
|
@@ -1,175 +1,160 @@
|
|
1
|
|
-import static org.junit.Assert.*;
|
|
2
|
|
-
|
|
3
|
1
|
import org.junit.Ignore;
|
|
4
|
2
|
import org.junit.Test;
|
|
5
|
3
|
|
|
|
4
|
+import static org.junit.Assert.*;
|
|
|
5
|
+
|
|
6
|
6
|
public class SumOfMultiplesTest {
|
|
7
|
|
-
|
|
8
|
|
-
|
|
|
7
|
+
|
|
9
|
8
|
@Test
|
|
10
|
9
|
public void testSumOfMultiplesOf3and4UpToOne() {
|
|
11
|
|
-
|
|
|
10
|
+
|
|
12
|
11
|
int[] set = {
|
|
13
|
|
- 3,
|
|
14
|
|
- 5
|
|
|
12
|
+ 3,
|
|
|
13
|
+ 5
|
|
15
|
14
|
};
|
|
16
|
|
- int output = SumOfMultiples.sum(1, set);
|
|
|
15
|
+ int output = new SumOfMultiples(1, set).getSum();
|
|
17
|
16
|
assertEquals(0, output);
|
|
18
|
|
-
|
|
|
17
|
+
|
|
19
|
18
|
}
|
|
20
|
|
-
|
|
21
|
|
-
|
|
|
19
|
+
|
|
22
|
20
|
@Test
|
|
23
|
21
|
@Ignore
|
|
24
|
22
|
public void testSumOfMultiplesOf3and5UpToFour() {
|
|
25
|
|
-
|
|
|
23
|
+
|
|
26
|
24
|
int[] set = {
|
|
27
|
|
- 3,
|
|
28
|
|
- 5
|
|
|
25
|
+ 3,
|
|
|
26
|
+ 5
|
|
29
|
27
|
};
|
|
30
|
|
- int output = SumOfMultiples.sum(4, set);
|
|
|
28
|
+ int output = new SumOfMultiples(4, set).getSum();
|
|
31
|
29
|
assertEquals(3, output);
|
|
32
|
|
-
|
|
|
30
|
+
|
|
33
|
31
|
}
|
|
34
|
|
-
|
|
35
|
|
-
|
|
|
32
|
+
|
|
36
|
33
|
@Test
|
|
37
|
34
|
@Ignore
|
|
38
|
35
|
public void testSumOfMultiplesOf3and5UpToTen() {
|
|
39
|
|
-
|
|
|
36
|
+
|
|
40
|
37
|
int[] set = {
|
|
41
|
|
- 3,
|
|
42
|
|
- 5
|
|
|
38
|
+ 3,
|
|
|
39
|
+ 5
|
|
43
|
40
|
};
|
|
44
|
|
- int output = SumOfMultiples.sum(10, set);
|
|
|
41
|
+ int output = new SumOfMultiples(10, set).getSum();
|
|
45
|
42
|
assertEquals(23, output);
|
|
46
|
|
-
|
|
|
43
|
+
|
|
47
|
44
|
}
|
|
48
|
|
-
|
|
49
|
|
-
|
|
|
45
|
+
|
|
50
|
46
|
@Test
|
|
51
|
47
|
@Ignore
|
|
52
|
48
|
public void testSumOfMultiplesOf3and5UpToOneHundred() {
|
|
53
|
|
-
|
|
|
49
|
+
|
|
54
|
50
|
int[] set = {
|
|
55
|
|
- 3,
|
|
56
|
|
- 5
|
|
|
51
|
+ 3,
|
|
|
52
|
+ 5
|
|
57
|
53
|
};
|
|
58
|
|
- int output = SumOfMultiples.sum(100, set);
|
|
|
54
|
+ int output = new SumOfMultiples(100, set).getSum();
|
|
59
|
55
|
assertEquals(2318, output);
|
|
60
|
|
-
|
|
|
56
|
+
|
|
61
|
57
|
}
|
|
62
|
|
-
|
|
63
|
|
-
|
|
|
58
|
+
|
|
64
|
59
|
@Test
|
|
65
|
60
|
@Ignore
|
|
66
|
61
|
public void testSumOfMultiplesOf3and5UpToOneThousand() {
|
|
67
|
|
-
|
|
|
62
|
+
|
|
68
|
63
|
int[] set = {
|
|
69
|
|
- 3,
|
|
70
|
|
- 5
|
|
|
64
|
+ 3,
|
|
|
65
|
+ 5
|
|
71
|
66
|
};
|
|
72
|
|
- int output = SumOfMultiples.sum(1000, set);
|
|
|
67
|
+ int output = new SumOfMultiples(1000, set).getSum();
|
|
73
|
68
|
assertEquals(233168, output);
|
|
74
|
|
-
|
|
|
69
|
+
|
|
75
|
70
|
}
|
|
76
|
|
-
|
|
77
|
|
-
|
|
|
71
|
+
|
|
78
|
72
|
@Test
|
|
79
|
73
|
@Ignore
|
|
80
|
74
|
public void testSumOfMultiplesOf7and13and17UpToTwenty() {
|
|
81
|
|
-
|
|
|
75
|
+
|
|
82
|
76
|
int[] set = {
|
|
83
|
|
- 7,
|
|
84
|
|
- 13,
|
|
85
|
|
- 17
|
|
|
77
|
+ 7,
|
|
|
78
|
+ 13,
|
|
|
79
|
+ 17
|
|
86
|
80
|
};
|
|
87
|
|
- int output = SumOfMultiples.sum(20, set);
|
|
|
81
|
+ int output = new SumOfMultiples(20, set).getSum();
|
|
88
|
82
|
assertEquals(51, output);
|
|
89
|
|
-
|
|
|
83
|
+
|
|
90
|
84
|
}
|
|
91
|
|
-
|
|
92
|
|
-
|
|
|
85
|
+
|
|
93
|
86
|
@Test
|
|
94
|
87
|
@Ignore
|
|
95
|
88
|
public void testSumOfMultiplesOf4and6UpToFifteen() {
|
|
96
|
|
-
|
|
|
89
|
+
|
|
97
|
90
|
int[] set = {
|
|
98
|
|
- 4,
|
|
99
|
|
- 6
|
|
|
91
|
+ 4,
|
|
|
92
|
+ 6
|
|
100
|
93
|
};
|
|
101
|
|
- int output = SumOfMultiples.sum(15, set);
|
|
|
94
|
+ int output = new SumOfMultiples(15, set).getSum();
|
|
102
|
95
|
assertEquals(30, output);
|
|
103
|
|
-
|
|
|
96
|
+
|
|
104
|
97
|
}
|
|
105
|
|
-
|
|
106
|
|
-
|
|
|
98
|
+
|
|
107
|
99
|
@Test
|
|
108
|
100
|
@Ignore
|
|
109
|
101
|
public void testSumOfMultiplesOf5and6and8UpToOneHundredFifty() {
|
|
110
|
|
-
|
|
|
102
|
+
|
|
111
|
103
|
int[] set = {
|
|
112
|
|
- 5,
|
|
113
|
|
- 6,
|
|
114
|
|
- 8
|
|
|
104
|
+ 5,
|
|
|
105
|
+ 6,
|
|
|
106
|
+ 8
|
|
115
|
107
|
};
|
|
116
|
|
- int output = SumOfMultiples.sum(150, set);
|
|
|
108
|
+ int output = new SumOfMultiples(150, set).getSum();
|
|
117
|
109
|
assertEquals(4419, output);
|
|
118
|
|
-
|
|
|
110
|
+
|
|
119
|
111
|
}
|
|
120
|
|
-
|
|
121
|
|
-
|
|
|
112
|
+
|
|
122
|
113
|
@Test
|
|
123
|
114
|
@Ignore
|
|
124
|
115
|
public void testSumOfMultiplesOf5and25UpToTwoHundredSeventyFive() {
|
|
125
|
|
-
|
|
|
116
|
+
|
|
126
|
117
|
int[] set = {
|
|
127
|
|
- 5,
|
|
128
|
|
- 25
|
|
|
118
|
+ 5,
|
|
|
119
|
+ 25
|
|
129
|
120
|
};
|
|
130
|
|
- int output = SumOfMultiples.sum(51, set);
|
|
|
121
|
+ int output = new SumOfMultiples(51, set).getSum();
|
|
131
|
122
|
assertEquals(275, output);
|
|
132
|
|
-
|
|
|
123
|
+
|
|
133
|
124
|
}
|
|
134
|
|
-
|
|
135
|
|
-
|
|
|
125
|
+
|
|
136
|
126
|
@Test
|
|
137
|
127
|
@Ignore
|
|
138
|
128
|
public void testSumOfMultiplesOf43and47UpToTenThousand() {
|
|
139
|
|
-
|
|
|
129
|
+
|
|
140
|
130
|
int[] set = {
|
|
141
|
|
- 43,
|
|
142
|
|
- 47
|
|
|
131
|
+ 43,
|
|
|
132
|
+ 47
|
|
143
|
133
|
};
|
|
144
|
|
- int output = SumOfMultiples.sum(10000, set);
|
|
|
134
|
+ int output = new SumOfMultiples(10000, set).getSum();
|
|
145
|
135
|
assertEquals(2203160, output);
|
|
146
|
|
-
|
|
|
136
|
+
|
|
147
|
137
|
}
|
|
148
|
|
-
|
|
149
|
|
-
|
|
|
138
|
+
|
|
150
|
139
|
@Test
|
|
151
|
140
|
@Ignore
|
|
152
|
141
|
public void testSumOfMultiplesOfOneUpToOneHundred() {
|
|
153
|
|
-
|
|
|
142
|
+
|
|
154
|
143
|
int[] set = {
|
|
155
|
|
- 1
|
|
|
144
|
+ 1
|
|
156
|
145
|
};
|
|
157
|
|
- int output = SumOfMultiples.sum(100, set);
|
|
|
146
|
+ int output = new SumOfMultiples(100, set).getSum();
|
|
158
|
147
|
assertEquals(4950, output);
|
|
159
|
|
-
|
|
|
148
|
+
|
|
160
|
149
|
}
|
|
161
|
|
-
|
|
162
|
|
-
|
|
|
150
|
+
|
|
163
|
151
|
@Test
|
|
164
|
152
|
@Ignore
|
|
165
|
153
|
public void testSumOfMultiplesOfNoneUpToTenThousand() {
|
|
166
|
|
-
|
|
|
154
|
+
|
|
167
|
155
|
int[] set = {};
|
|
168
|
|
- int output = SumOfMultiples.sum(10000, set);
|
|
|
156
|
+ int output = new SumOfMultiples(10000, set).getSum();
|
|
169
|
157
|
assertEquals(0, output);
|
|
170
|
|
-
|
|
|
158
|
+
|
|
171
|
159
|
}
|
|
172
|
|
-
|
|
173
|
|
-
|
|
174
|
|
-
|
|
175
|
160
|
}
|