diff options
author | Seth Tisue <seth@tisue.net> | 2015-12-15 13:30:23 -0500 |
---|---|---|
committer | Seth Tisue <seth@tisue.net> | 2015-12-15 13:30:23 -0500 |
commit | 7559aed3c5b9ccf7e995d8094772340234769017 (patch) | |
tree | 917d8cfdad6b9c777dc9426e7dac829ecaaac2ad /test | |
parent | a0dabe37bd761f344109cde13d917575690371a5 (diff) | |
parent | c17b18e173e07f421f9171272d94d84908526609 (diff) | |
download | scala-7559aed3c5b9ccf7e995d8094772340234769017.tar.gz scala-7559aed3c5b9ccf7e995d8094772340234769017.tar.bz2 scala-7559aed3c5b9ccf7e995d8094772340234769017.zip |
Merge pull request #4876 from ruippeixotog/issue/9581
SI-9581 Fix overflow on Vector take and drop methods
Diffstat (limited to 'test')
-rw-r--r-- | test/junit/scala/collection/immutable/VectorTest.scala | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/junit/scala/collection/immutable/VectorTest.scala b/test/junit/scala/collection/immutable/VectorTest.scala new file mode 100644 index 0000000000..69f74872d0 --- /dev/null +++ b/test/junit/scala/collection/immutable/VectorTest.scala @@ -0,0 +1,30 @@ +package scala.collection.immutable + +import org.junit.Assert._ +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 +import org.junit.Test + +@RunWith(classOf[JUnit4]) +class VectorTest { + + @Test + def hasCorrectDropAndTakeMethods() { + val v = Vector(0) ++ Vector(1 to 64: _*) + + assertEquals(Vector(0, 1), v take 2) + assertEquals(Vector(63, 64), v takeRight 2) + assertEquals(Vector(2 to 64: _*), v drop 2) + assertEquals(Vector(0 to 62: _*), v dropRight 2) + + assertEquals(v, v take Int.MaxValue) + assertEquals(v, v takeRight Int.MaxValue) + assertEquals(Vector.empty[Int], v drop Int.MaxValue) + assertEquals(Vector.empty[Int], v dropRight Int.MaxValue) + + assertEquals(Vector.empty[Int], v take Int.MinValue) + assertEquals(Vector.empty[Int], v takeRight Int.MinValue) + assertEquals(v, v drop Int.MinValue) + assertEquals(v, v dropRight Int.MinValue) + } +} |