-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringCalcultorTest.java
More file actions
44 lines (35 loc) · 877 Bytes
/
StringCalcultorTest.java
File metadata and controls
44 lines (35 loc) · 877 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
42
43
44
import static org.junit.Assert.*;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
public class StringCalcultorTest {
StringCalculator sc = new StringCalculator();
@Test
public void blankStringReturnsZero(){
assertEquals(sc.add(""), 0);
}
@Test
public void oneLengthStringReturnsSum(){
assertEquals(sc.add("1"), 1);
}
@Test
public void twoLengthStringReturnsSum(){
assertEquals(sc.add("1,2"), 3);
}
@Test
public void unlimitedLenghtStringReturnsSum(){
assertEquals(sc.add("1,2,3,4,5"),1+2+3+4+5);
}
@Test
public void stringWithOtherSeparatorThanComma(){
assertEquals(sc.add("1\n2"),3);
}
@Test
public void stringWithDelimiterInBeggining(){
assertEquals(sc.add("//;\n1;2"), 3);
}
@Test(expected = IllegalArgumentException.class)
public void stringWithNegativeNumbers(){
sc.add("1,-1");
}
}