Skip to content

Commit 33f2b15

Browse files
jbduncancpovirk
authored andcommitted
Update IteratorTester example with a greater "steps" value
This allows IteratorTester to check the edge case that when an iterator has been exhausted (that is, "next" has been called repeatedly until "hasNext" returns false) then calling "next" on the iterator again exhibits the same behavior as the user's chosen "known good" reference implementation. Fixes #5281 RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=337541752
1 parent dfb0001 commit 33f2b15

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

android/guava-testlib/src/com/google/common/collect/testing/IteratorTester.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@
5050
* verify() method, which is called <em>after</em> each sequence and is guaranteed to be called
5151
* using the latest values obtained from {@link IteratorTester#newTargetIterator()}.
5252
*
53+
* <p>The value you pass to the parameter {@code steps} should be greater than the length of your
54+
* iterator, so that this class can check that your iterator behaves correctly when it is exhausted.
55+
*
5356
* <p>For example, to test {@link java.util.Collections#unmodifiableList(java.util.List)
5457
* Collections.unmodifiableList}'s iterator:
5558
*
@@ -61,7 +64,7 @@
6164
* Arrays.asList("a", "b", "c", "d", "e"));
6265
* IteratorTester<String> iteratorTester =
6366
* new IteratorTester<String>(
64-
* 5,
67+
* 6,
6568
* IteratorFeature.UNMODIFIABLE,
6669
* expectedElements,
6770
* IteratorTester.KnownOrder.KNOWN_ORDER) {
@@ -75,7 +78,7 @@
7578
* }</pre>
7679
*
7780
* <p><b>Note</b>: It is necessary to use {@code IteratorTester.KnownOrder} as shown above, rather
78-
* than {@code KnownOrder} directly, because otherwise the code is not compilable.
81+
* than {@code KnownOrder} directly, because otherwise the code cannot be compiled.
7982
*
8083
* @author Kevin Bourrillion
8184
* @author Chris Povirk

guava-testlib/src/com/google/common/collect/testing/IteratorTester.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@
5050
* verify() method, which is called <em>after</em> each sequence and is guaranteed to be called
5151
* using the latest values obtained from {@link IteratorTester#newTargetIterator()}.
5252
*
53+
* <p>The value you pass to the parameter {@code steps} should be greater than the length of your
54+
* iterator, so that this class can check that your iterator behaves correctly when it is exhausted.
55+
*
5356
* <p>For example, to test {@link java.util.Collections#unmodifiableList(java.util.List)
5457
* Collections.unmodifiableList}'s iterator:
5558
*
@@ -61,7 +64,7 @@
6164
* Arrays.asList("a", "b", "c", "d", "e"));
6265
* IteratorTester<String> iteratorTester =
6366
* new IteratorTester<String>(
64-
* 5,
67+
* 6,
6568
* IteratorFeature.UNMODIFIABLE,
6669
* expectedElements,
6770
* IteratorTester.KnownOrder.KNOWN_ORDER) {
@@ -75,7 +78,7 @@
7578
* }</pre>
7679
*
7780
* <p><b>Note</b>: It is necessary to use {@code IteratorTester.KnownOrder} as shown above, rather
78-
* than {@code KnownOrder} directly, because otherwise the code is not compilable.
81+
* than {@code KnownOrder} directly, because otherwise the code cannot be compiled.
7982
*
8083
* @author Kevin Bourrillion
8184
* @author Chris Povirk

0 commit comments

Comments
 (0)