Skip to content

Commit

Permalink
Update IteratorTester example with a greater "steps" value
Browse files Browse the repository at this point in the history
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 google#5281

RELNOTES=n/a

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=337541752
  • Loading branch information
jbduncan authored and cpovirk committed Oct 16, 2020
1 parent dfb0001 commit 33f2b15
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Expand Up @@ -50,6 +50,9 @@
* verify() method, which is called <em>after</em> each sequence and is guaranteed to be called
* using the latest values obtained from {@link IteratorTester#newTargetIterator()}.
*
* <p>The value you pass to the parameter {@code steps} should be greater than the length of your
* iterator, so that this class can check that your iterator behaves correctly when it is exhausted.
*
* <p>For example, to test {@link java.util.Collections#unmodifiableList(java.util.List)
* Collections.unmodifiableList}'s iterator:
*
Expand All @@ -61,7 +64,7 @@
* Arrays.asList("a", "b", "c", "d", "e"));
* IteratorTester<String> iteratorTester =
* new IteratorTester<String>(
* 5,
* 6,
* IteratorFeature.UNMODIFIABLE,
* expectedElements,
* IteratorTester.KnownOrder.KNOWN_ORDER) {
Expand All @@ -75,7 +78,7 @@
* }</pre>
*
* <p><b>Note</b>: It is necessary to use {@code IteratorTester.KnownOrder} as shown above, rather
* than {@code KnownOrder} directly, because otherwise the code is not compilable.
* than {@code KnownOrder} directly, because otherwise the code cannot be compiled.
*
* @author Kevin Bourrillion
* @author Chris Povirk
Expand Down
Expand Up @@ -50,6 +50,9 @@
* verify() method, which is called <em>after</em> each sequence and is guaranteed to be called
* using the latest values obtained from {@link IteratorTester#newTargetIterator()}.
*
* <p>The value you pass to the parameter {@code steps} should be greater than the length of your
* iterator, so that this class can check that your iterator behaves correctly when it is exhausted.
*
* <p>For example, to test {@link java.util.Collections#unmodifiableList(java.util.List)
* Collections.unmodifiableList}'s iterator:
*
Expand All @@ -61,7 +64,7 @@
* Arrays.asList("a", "b", "c", "d", "e"));
* IteratorTester<String> iteratorTester =
* new IteratorTester<String>(
* 5,
* 6,
* IteratorFeature.UNMODIFIABLE,
* expectedElements,
* IteratorTester.KnownOrder.KNOWN_ORDER) {
Expand All @@ -75,7 +78,7 @@
* }</pre>
*
* <p><b>Note</b>: It is necessary to use {@code IteratorTester.KnownOrder} as shown above, rather
* than {@code KnownOrder} directly, because otherwise the code is not compilable.
* than {@code KnownOrder} directly, because otherwise the code cannot be compiled.
*
* @author Kevin Bourrillion
* @author Chris Povirk
Expand Down

0 comments on commit 33f2b15

Please sign in to comment.