Skip to content

Commit 5b0bc80

Browse files
committed
研修内ワーク
1 parent 34b6771 commit 5b0bc80

File tree

3 files changed

+80
-20
lines changed

3 files changed

+80
-20
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package tddbc;
2+
3+
public class ClosedRange {
4+
Integer lowerPoint;
5+
Integer upperPoint;
6+
7+
public ClosedRange(Integer input1, Integer input2){
8+
if (input1 <= input2) {
9+
lowerPoint = input1;
10+
upperPoint = input2;
11+
} else {
12+
lowerPoint = input2;
13+
upperPoint = input1;
14+
}
15+
}
16+
17+
public Integer getLowerPoint() {
18+
return lowerPoint;
19+
}
20+
21+
public Integer getUpperPoint() {
22+
return upperPoint;
23+
}
24+
25+
// "[" + input1.toString() +
26+
//hoge(closedRande) -> "[1,2]"
27+
28+
public String makeFormatedString(Integer lowerPoint, Integer upperPoint){
29+
30+
return "[" + lowerPoint.toString() + "," + upperPoint.toString() + "]";
31+
}
32+
}
33+

src/main/java/tddbc/Sample.java

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,57 @@
11
package tddbc;
22

3+
import org.junit.jupiter.api.BeforeEach;
34
import org.junit.jupiter.api.Test;
4-
import org.junit.jupiter.api.DisplayName;
5-
import static org.junit.jupiter.api.Assertions.*;
5+
import static org.junit.jupiter.api.Assertions.assertEquals;
66

77
public class SampleTest {
8+
ClosedRange closedRange;
9+
10+
@BeforeEach
11+
void beforeEach(){
12+
closedRange = new ClosedRange(1, 2);
13+
}
14+
15+
@Test
16+
void lowerPointを取得できる(){
17+
// given
18+
Integer actual = closedRange.getLowerPoint();
19+
Integer expected = 1;
20+
// when
21+
// then
22+
assertEquals(expected, actual);
23+
}
24+
25+
@Test
26+
void upperPointを取得できる(){
27+
// given
28+
Integer actual = closedRange.getUpperPoint();
29+
Integer expected = 2;
30+
// when
31+
// then
32+
assertEquals(expected, actual);
33+
}
34+
35+
@Test
36+
void 想定するフォーマットに整形できる(){
37+
// given
38+
String expected = "[1,2]";
39+
Integer input1 = 1;
40+
Integer input2 = 2;
41+
// when
42+
String actual = closedRange.makeFormatedString(input1, input2);
43+
// then
44+
assertEquals(expected, actual);
45+
}
846

947
@Test
10-
@DisplayName("should return Hello TDD Boot Camp")
11-
public void _should_return_Hello_TDD_BootCamp() throws Exception {
12-
// Setup
13-
Sample sut = new Sample();
14-
// Exercise
15-
String actual = sut.say();
16-
// Verify
17-
assertEquals("Hello TDD BootCamp!", actual);
48+
void 大小関係が整っている(){
49+
// given
50+
Boolean expected = true;
51+
Boolean actual = closedRange.getLowerPoint() <= closedRange.getUpperPoint();
52+
// when
53+
// then
54+
assertEquals(expected, actual);
1855
}
1956

2057
}

0 commit comments

Comments
 (0)