Skip to content

Commit 2a3ea3b

Browse files
committed
test for the extra bounds check iff 'n > M'
1 parent f23336a commit 2a3ea3b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

libcxx/test/std/iterators/iterator.primitives/range.iter.ops/range.iter.ops.advance/iterator_count_sentinel.pass.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,13 @@ constexpr void check_forward(int* first, int* last, std::iter_difference_t<It> n
4545
if (n == 0) {
4646
assert(it.equals_count() == 0);
4747
} else {
48-
assert(it.equals_count() == M || it.equals_count() == M + 1);
48+
if (n > M) {
49+
// We "hit" the bound, so there is one extra equality check.
50+
assert(it.equals_count() == M + 1);
51+
} else {
52+
assert(it.equals_count() == M);
53+
}
54+
// In any case, there must not be more than `n` bounds checks.
4955
assert(it.equals_count() <= n);
5056
}
5157
}

0 commit comments

Comments
 (0)