diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2014-05-27 15:40:16 +0200 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2014-05-27 15:40:16 +0200 |
commit | 5551cf66e5b27ae398b527df6fe4247aed1ff307 (patch) | |
tree | 34cc550412c44edef803297db35d34dde21fdde9 /test | |
parent | b20bb5587fbd36b212027a04a62f65d6709d05af (diff) | |
parent | 71cfb57499bda80f5fb0a810f37d0f9c54e1afd3 (diff) | |
download | scala-5551cf66e5b27ae398b527df6fe4247aed1ff307.tar.gz scala-5551cf66e5b27ae398b527df6fe4247aed1ff307.tar.bz2 scala-5551cf66e5b27ae398b527df6fe4247aed1ff307.zip |
Merge pull request #3733 from retronym/topic/pr-3712-resubmit
SI-8475 Fix off by one in GroupedIterator when Streaming
Diffstat (limited to 'test')
-rw-r--r-- | test/junit/scala/collection/IteratorTest.scala | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/junit/scala/collection/IteratorTest.scala b/test/junit/scala/collection/IteratorTest.scala new file mode 100644 index 0000000000..cb7cbb40bc --- /dev/null +++ b/test/junit/scala/collection/IteratorTest.scala @@ -0,0 +1,20 @@ + +package scala.collection + +import org.junit.Assert._ +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 + +@RunWith(classOf[JUnit4]) +class IteratorTest { + + @Test + def groupedIteratorShouldNotAskForUnneededElement(): Unit = { + var counter = 0 + val it = new Iterator[Int] { var i = 0 ; def hasNext = { counter = i; true } ; def next = { i += 1; i } } + val slidingIt = it sliding 2 + slidingIt.next + assertEquals("Counter should be one, that means we didn't look further than needed", 1, counter) + } +} |