diff options
author | Alon Zakai <azakai@google.com> | 2022-01-13 12:57:41 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-13 12:57:41 -0800 |
commit | 6d92ba9ceb14563fb4d1e573f8644eb06a8cea2a (patch) | |
tree | be2f0163eabae3c0506854b9aa7f65332e4599c5 /test | |
parent | 3168fa227eeb3b964b6d3c773d95e0a2014b396a (diff) | |
download | binaryen-6d92ba9ceb14563fb4d1e573f8644eb06a8cea2a.tar.gz binaryen-6d92ba9ceb14563fb4d1e573f8644eb06a8cea2a.tar.bz2 binaryen-6d92ba9ceb14563fb4d1e573f8644eb06a8cea2a.zip |
LiteralList => Literals (#4451)
LiteralList overlaps with Literals, but is less efficient as it is not a
SmallVector.
Add reserve/capacity methods to SmallVector which are now
necessary to compile.
Diffstat (limited to 'test')
-rw-r--r-- | test/example/small_vector.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/test/example/small_vector.cpp b/test/example/small_vector.cpp index cb2e22e79..29d964997 100644 --- a/test/example/small_vector.cpp +++ b/test/example/small_vector.cpp @@ -5,7 +5,7 @@ using namespace wasm; -template<typename T> void test() { +template<typename T> void test(size_t N) { { T t; // build up @@ -55,12 +55,23 @@ template<typename T> void test() { u.push_back(2); assert(t != u); } + { + // Test reserve/capacity. + T t; + + // Capacity begins at the size of the fixed storage. + assert(t.capacity() == N); + + // Reserving more increases the capacity (but how much is impl-defined). + t.reserve(t.capacity() + 100); + assert(t.capacity() >= N + 100); + } } int main() { - test<SmallVector<int, 0>>(); - test<SmallVector<int, 1>>(); - test<SmallVector<int, 2>>(); - test<SmallVector<int, 10>>(); + test<SmallVector<int, 0>>(0); + test<SmallVector<int, 1>>(1); + test<SmallVector<int, 2>>(2); + test<SmallVector<int, 10>>(10); std::cout << "ok.\n"; } |