-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalculatorTest.java
More file actions
36 lines (29 loc) · 1.04 KB
/
CalculatorTest.java
File metadata and controls
36 lines (29 loc) · 1.04 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
package com.houarizegai.calculator;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
class CalculatorTest {
private Calculator calculator;
@BeforeEach
void setUp() { // Create object before compilation
calculator = new Calculator();
}
/*
* testCalc() test method
*/
@Test
void testCalc() {
double first = 3;
String second = "5";
try {
Assertions.assertEquals(8, calculator.calc(first, second, '+'));
Assertions.assertEquals(-2, calculator.calc(first, second, '-'));
Assertions.assertEquals(15, calculator.calc(first, second, '*'));
Assertions.assertEquals(0.6, calculator.calc(first, second, '/'));
Assertions.assertEquals(3d, calculator.calc(first, second, '%'));
Assertions.assertEquals(243, calculator.calc(first, second, '^'));
} catch (Exception e) {
e.printStackTrace();
}
}
}