"William Rayner" [email protected] wrote:
I thought it was for the initial call to hasNext()
You are correct. I have hidden the original post as I think the wording was potentially misleading.
The statement I will make is as follows:
The testFilter()
test is correct as written.
Note that the first call to stats.expect(count, countit.getCount(), ...)
occurs after the first call to hasNext()
.
Consider the question: How can the filtered iterator know if it has a next element without testing the element using the predicate?
As has been mentioned in a previous post, the tests (and this test in particular) are not as strict as they could be. By the specification, your filtered iterator should not consume any elements from the given iterator except as required. But this test does not check the consumed count until after the first call to hasNext()
. It is therefore possible to pass this test without quite perfectly implementing the specification. I encourage everyone to read the marking rubric carefully, but put simply: If you pass the test you get the mark (even if the test is more forgiving than the specification). Indeed, some later tests explicitly have a margin for error built i n.
I hope that clarifies this matter.
Gozz