-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathStringCalculatorTest.java
More file actions
54 lines (42 loc) · 1.24 KB
/
StringCalculatorTest.java
File metadata and controls
54 lines (42 loc) · 1.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
package calculator;
import calculator.StringCalculator;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class StringCalculatorTest {
private StringCalculator stCal;
@BeforeEach
public void setUp() throws Exception {
stCal = new StringCalculator();
}
@Test
public void add_null_or_emptyText() throws Exception {
assertEquals(0, stCal.add(""));
assertEquals(0, stCal.add(null));
}
@Test
public void add_oneNum() throws Exception {
assertEquals(1, stCal.add("1"));
}
@Test
public void add_delimiter_comma() throws Exception {
assertEquals(3, stCal.add("2, 3"));
}
@Test
public void add_delimiter_commaOrColon() throws Exception {
assertEquals(3, stCal.add("2:3"));
assertEquals(6, stCal.add("1,2:3"));
}
@Test
public void add_delimiter_customed() throws Exception {
assertEquals(6, stCal.add("//;\n1;2:3"));
}
@Test
public void add_negative_num() throws Exception {
stCal.add("-2, 2; 3");
}
@AfterEach
public void tearDown() throws Exception {
}
}