-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathStringCalculator_Test.java
More file actions
41 lines (37 loc) · 956 Bytes
/
StringCalculator_Test.java
File metadata and controls
41 lines (37 loc) · 956 Bytes
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
package test;
import main.Main;
import org.junit.Before;
import org.junit.Test;
/*import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.BeforeEach;*/
import static org.junit.jupiter.api.Assertions.*;
public class StringCalculator_Test {
private Main.StringCalculator cal;
@Before
public void setup() {
cal = new Main.StringCalculator();
System.out.println("Before");
}
@Test
public void add_empty() {
assertEquals(0,cal.add(null));
assertEquals(0,cal.add(""));
}
@Test
public void add_string() {
assertEquals(3, cal.add("3"));
}
@Test
public void add_seperate() {
assertEquals(8,cal.add("6,2"));
assertEquals(9,cal.add("3,2:4"));
}
@Test
public void add_regx() {
assertEquals(8, cal.add("//;\n3;4;1"));
}
@Test(expected = RuntimeException.class)
public void add_minus() {
cal.add("-1,2,3");
}
}