제공 함수로 변경하는 것이 얼마나 쉬운지 알 수 있는가? 컬렉션을 이런 관점에서 보면 흥미롭
다. 다음과 같이 컬렉션을 바라볼 수 있다.
타입보고 싶은 함수 타입변환하는 방법
List
<
T
>(
index
:
Int
) ->
TList
.
get
(
index
)
Set
<
T
>(
item
:
T
) ->
BooleanSet
.
contains
(
item
)
Map
<
K
,
V
>(
key
:
K
) ->
V
?
Map
.
get
(
key
)
코드의 의존 관계를 이런 타입 중 하나로 표현할 수 있다면, 고객과 테스트는 표준 컬렉션을 활
용해 구현을 제공할 수 있다.
이제 헤더가 있는 표를 읽는 기능을 구현했으므로, 인수 테스트를 실행할 상황이 됐다. 인수 테
스트는 다음과 같다.
예제
22.39
[
table
-
reader
.
26
:
src
/
test
/
java
/
travelator
/
tablereader
/
TableReaderAcceptanceTests
.
kt
]
@Disabled
@Test
fun `acceptance test`() {
val input = listOf(
“time,x,y”,
“0.0, 1, 1”,
“0.1,1.1,1.2”,
“0.2,1.2,1.4”,
)
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.