Fix ArrayList tests.
This commit is contained in:
@@ -259,27 +259,22 @@ fun testSubListLastIndexOf() {
|
|||||||
fun testIteratorRemove() {
|
fun testIteratorRemove() {
|
||||||
val a = makeList12345()
|
val a = makeList12345()
|
||||||
val it = a.iterator()
|
val it = a.iterator()
|
||||||
var i = 1
|
while (it.hasNext())
|
||||||
while (it.hasNext()) {
|
if (it.next()[0].toInt() % 2 == 0)
|
||||||
if (i++ % 2 == 0) {
|
|
||||||
it.remove()
|
it.remove()
|
||||||
}
|
|
||||||
it.next()
|
|
||||||
}
|
|
||||||
|
|
||||||
assertEquals(makeList135(), a)
|
assertEquals(makeList135(), a)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun testIteratorAdd() {
|
fun testIteratorAdd() {
|
||||||
val a = makeList12345()
|
val a = makeList12345()
|
||||||
val it = a.listIterator()
|
val it = a.listIterator()
|
||||||
var i = 0
|
var i = 1
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
val next = it.next()
|
val next = it.next()
|
||||||
if (i++ % 2 == 0)
|
if (i++ % 2 == 0)
|
||||||
it.add("-" + next)
|
it.add("-" + next)
|
||||||
}
|
}
|
||||||
//assertEquals(listOf("1", "2", "-2", "3", "4", "-4", "5"), a)
|
assertEquals("[1, 2, -2, 3, 4, -4, 5]", a.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -299,7 +294,7 @@ fun main(args : Array<String>) {
|
|||||||
testSubListContains()
|
testSubListContains()
|
||||||
testSubListIndexOf()
|
testSubListIndexOf()
|
||||||
testSubListLastIndexOf()
|
testSubListLastIndexOf()
|
||||||
// testIteratorAdd() runtime assert: Throwing is unsupported
|
testIteratorAdd()
|
||||||
// testIteratorRemove() assertEquals fails
|
testIteratorRemove()
|
||||||
println("OK")
|
println("OK")
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user