summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/junit/scala/collection/mutable/ArrayBufferTest.scala36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/junit/scala/collection/mutable/ArrayBufferTest.scala b/test/junit/scala/collection/mutable/ArrayBufferTest.scala
new file mode 100644
index 0000000000..8c83164027
--- /dev/null
+++ b/test/junit/scala/collection/mutable/ArrayBufferTest.scala
@@ -0,0 +1,36 @@
+package scala.collection.mutable
+
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import org.junit.{Assert, Test}
+
+import scala.tools.testing.AssertUtil
+
+/* Test for SI-9043 */
+@RunWith(classOf[JUnit4])
+class ArrayBufferTest {
+ @Test
+ def testInsertAll: Unit = {
+ val traver = ArrayBuffer(2, 4, 5, 7)
+ val testSeq = List(1, 3, 6, 9)
+
+ def insertAt(x: Int) = {
+ val clone = traver.clone()
+ clone.insertAll(x, testSeq)
+ clone
+ }
+
+ // Just insert some at position 0
+ Assert.assertEquals(ArrayBuffer(1, 3, 6, 9, 2, 4, 5, 7), insertAt(0))
+
+ // Insert in the middle
+ Assert.assertEquals(ArrayBuffer(2, 4, 1, 3, 6, 9, 5, 7), insertAt(2))
+
+ // No strange last position weirdness
+ Assert.assertEquals(ArrayBuffer(2, 4, 5, 7, 1, 3, 6, 9), insertAt(traver.size))
+
+ // Overflow is caught
+ AssertUtil.assertThrows[IndexOutOfBoundsException] { insertAt(-1) }
+ AssertUtil.assertThrows[IndexOutOfBoundsException] { insertAt(traver.size + 10) }
+ }
+}