-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReversePolishNotationCalculatorTest.java
More file actions
43 lines (33 loc) · 1.18 KB
/
Copy pathReversePolishNotationCalculatorTest.java
File metadata and controls
43 lines (33 loc) · 1.18 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
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class ReversePolishNotationCalculatorTest {
private ReversePolishNotationCalculator calc = new ReversePolishNotationCalculator();
@Test
public void shouldWorkWithEmptyString() {
assertEquals("Should work with empty string", 0, calc.evaluate(""), 0);
}
@Test
public void shouldParseNumbers() {
assertEquals("Should parse numbers", 3, calc.evaluate("1 2 3"), 0);
}
@Test
public void shouldParseFloatNumbers() {
assertEquals("Should parse float numbers", 3.5, calc.evaluate("1 2 3.5"), 0);
}
@Test
public void shouldSupportAddition() {
assertEquals("Should support addition", 4, calc.evaluate("1 3 +"), 0);
}
@Test
public void shouldSupportMultiplication() {
assertEquals("Should support multiplication", 3, calc.evaluate("1 3 *"), 0);
}
@Test
public void shouldSupportSubstraction() {
assertEquals("Should support substraction", -2, calc.evaluate("1 3 -"), 0);
}
@Test
public void shouldSupportDivision() {
assertEquals("Should support division", 2, calc.evaluate("4 2 /"), 0);
}
}