/
NCounterTest.java
57 lines (48 loc) · 1.48 KB
/
NCounterTest.java
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
package com.algorithm.coding.dojang;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.util.Arrays;
import java.util.Collection;
import static org.junit.Assert.*;
/**
* @author tomining
*/
@RunWith(Parameterized.class)
public class NCounterTest {
@Parameterized.Parameters
public static Collection<Object[]> parameters() {
return Arrays.asList(new Object[][]{
{1, 10, 8, 1},
{1, 100, 8, 20},
{1, 587, 8, 116}, //countN(to)에서는 실패 케이스
{1, 1000, 8, 300},
{1, 10000, 8, 4000}
});
}
private int from;
private int to;
private int findNum;
private int expectedCount;
public NCounterTest(int from, int to, int findNum, int expectedCount) {
this.from = from;
this.to = to;
this.findNum = findNum;
this.expectedCount = expectedCount;
}
@Test
public void 숫자_세기() {
NCounter counter = new NCounter(this.findNum);
assertEquals(this.expectedCount, counter.countN(from, to));
}
@Test
public void 숫자_세기_10의_배수인_경우() {
NCounter counter = new NCounter(this.findNum);
assertEquals(this.expectedCount, counter.countN(to));
}
@Test
public void 숫자_세기_V2() {
NCounter counter = new NCounter(this.findNum);
assertEquals(this.expectedCount, counter.countNV2(this.to));
}
}