mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 06:11:16 +00:00
Changed C++'s SharedVector::clear() to not preserve capacity when shared
This commit is contained in:
parent
d65af654d7
commit
a752c798b8
2 changed files with 8 additions and 6 deletions
|
@ -100,6 +100,7 @@ TEST_CASE("SharedVector")
|
|||
using namespace sixtyfps;
|
||||
|
||||
SharedVector<SharedString> vec;
|
||||
vec.clear();
|
||||
vec.push_back("Hello");
|
||||
vec.push_back("World");
|
||||
vec.push_back("of");
|
||||
|
@ -112,11 +113,13 @@ TEST_CASE("SharedVector")
|
|||
REQUIRE(orig_cap >= vec.size());
|
||||
vec.clear();
|
||||
REQUIRE(vec.size() == 0);
|
||||
REQUIRE(vec.capacity() == orig_cap);
|
||||
REQUIRE(vec.capacity() == 0); // vec was shared, so start with new empty vector.
|
||||
vec.push_back("Welcome back");
|
||||
REQUIRE(vec.size() == 1);
|
||||
REQUIRE(vec.capacity() == orig_cap);
|
||||
REQUIRE(vec.capacity() >= vec.size());
|
||||
|
||||
REQUIRE(copy.size() == 4);
|
||||
REQUIRE(copy.capacity() == orig_cap);
|
||||
copy.clear(); // copy is not shared (anymore), retain capacity.
|
||||
REQUIRE(copy.capacity() == orig_cap);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue