-
Notifications
You must be signed in to change notification settings - Fork 36
/
StringCalculator4Test.java
45 lines (34 loc) · 1.15 KB
/
StringCalculator4Test.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
package com.wordpress.technologyconversations.tddexamplewalkthrough;
import org.junit.Assert;
import org.junit.Test;
public class StringCalculator4Test {
// @Test(expected = RuntimeException.class)
// public final void whenMoreThan2NumbersAreUsedThenExceptionIsThrown() {
// StringCalculator4.add("1,2,3");
// }
@Test
public final void when2NumbersAreUsedThenNoExceptionIsThrown() {
StringCalculator4.add("1,2");
Assert.assertTrue(true);
}
@Test(expected = RuntimeException.class)
public final void whenNonNumberIsUsedThenExceptionIsThrown() {
StringCalculator4.add("1,X");
}
@Test
public final void whenEmptyStringIsUsedThenReturnValueIs0() {
Assert.assertEquals(0, StringCalculator4.add(""));
}
@Test
public final void whenOneNumberIsUsedThenReturnValueIsThatSameNumber() {
Assert.assertEquals(3, StringCalculator4.add("3"));
}
@Test
public final void whenTwoNumbersAreUsedThenReturnValueIsTheirSum() {
Assert.assertEquals(3+6, StringCalculator4.add("3,6"));
}
@Test
public final void whenAnyNumberOfNumbersIsUsedThenReturnValuesAreTheirSums() {
Assert.assertEquals(3+6+15+18+46+33, StringCalculator4.add("3,6,15,18,46,33"));
}
}