Skip to content

Commit e19fc41

Browse files
committed
Calculator & test 클래스 구현
1 parent b1c1e23 commit e19fc41

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ repositories {
1212
dependencies {
1313
testImplementation platform('org.junit:junit-bom:5.9.1')
1414
testImplementation('org.junit.jupiter:junit-jupiter')
15+
testImplementation ('org.junit.jupiter:junit-jupiter:5.10.0')
1516
}
1617

1718
test {

src/test/java/CalculatorTest.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import org.junit.jupiter.api.Test;
2+
3+
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
5+
public class CalculatorTest {
6+
@Test
7+
void testAdd(){
8+
int result = add(2,3);
9+
assertEquals(5,result);
10+
}
11+
@Test
12+
void testSubtract(){
13+
int result = subtract(2,3);
14+
assertEquals(-1,result);
15+
}
16+
17+
@Test
18+
void testMultiply(){
19+
int result = multiply(2,3);
20+
assertEquals(6,result);
21+
}
22+
@Test
23+
void testDivide(){
24+
int result = divide(6,3);
25+
assertEquals(2,result);
26+
}
27+
28+
int add(int a, int b){
29+
return a + b;
30+
}
31+
int subtract(int a, int b){
32+
return a - b;
33+
}
34+
int multiply(int a, int b){
35+
return a * b;
36+
}
37+
int divide(int a, int b){
38+
return a / b;
39+
}
40+
}

0 commit comments

Comments
 (0)