-
Notifications
You must be signed in to change notification settings - Fork 20
/
AddTwoNumbersTest.kt
46 lines (37 loc) · 1.36 KB
/
AddTwoNumbersTest.kt
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
44
45
46
import org.junit.Test
class AddTwoNumbersTest {
@Test
fun testAddTwoNumbers() {
val atn = AddTwoNumbers()
val node0 = AddTwoNumbers.ListNode(0)
val node5 = AddTwoNumbers.ListNode(5)
assert(atn.addTwoNumbers(node0, node0) == AddTwoNumbers.ListNode(0))
assert(atn.addTwoNumbers(node5, node5) == AddTwoNumbers.ListNode(0).apply {
next = AddTwoNumbers.ListNode(1)
})
val node243 = AddTwoNumbers.ListNode(2).apply {
next = AddTwoNumbers.ListNode(4).apply {
next = AddTwoNumbers.ListNode(3)
}
}
val node564 = AddTwoNumbers.ListNode(5).apply {
next = AddTwoNumbers.ListNode(6).apply {
next = AddTwoNumbers.ListNode(4)
}
}
assert(atn.addTwoNumbers(node243, node564) == AddTwoNumbers.ListNode(7).apply {
next = AddTwoNumbers.ListNode(0).apply {
next = AddTwoNumbers.ListNode(8)
}
})
val node1 = AddTwoNumbers.ListNode(1)
val node99 = AddTwoNumbers.ListNode(9).apply {
next = AddTwoNumbers.ListNode(9)
}
assert(atn.addTwoNumbers(node1, node99) == AddTwoNumbers.ListNode(0).apply {
next = AddTwoNumbers.ListNode(0).apply {
next = AddTwoNumbers.ListNode(1)
}
})
}
}