Skip to content

Commit 55eaf47

Browse files
committed
Make test portable
1 parent 798bb80 commit 55eaf47

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

libcxx/test/std/containers/sequences/vector/trivial_relocation.pass.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,18 @@ TEST_CONSTEXPR_CXX20 bool tests() {
4444

4545
// Fill the vector at its capacity, such that any subsequent push_back would require growing.
4646
v.reserve(5);
47-
for (std::size_t i = 0; i != 5; ++i) {
47+
std::size_t const capacity = v.capacity(); // could technically be more than 5
48+
while (v.size() < v.capacity()) {
4849
v.emplace_back(&track);
4950
}
5051
assert(track.move_constructs == 0);
51-
assert(v.size() == 5);
52+
assert(v.capacity() == capacity);
53+
assert(v.size() == capacity);
5254

5355
// Force a reallocation of the buffer + relocalization of the elements.
5456
// All the existing elements of the vector should be move-constructed to their new location.
5557
v.emplace_back(&track);
56-
assert(track.move_constructs == 5);
58+
assert(track.move_constructs == capacity);
5759

5860
return true;
5961
}

0 commit comments

Comments
 (0)