mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-22 16:37:40 +08:00
Implement P0966 - string::reserve should not shrink
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@347789 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -9,7 +9,9 @@
|
||||
|
||||
// <string>
|
||||
|
||||
// void reserve(size_type res_arg=0);
|
||||
// Split into two calls for C++20
|
||||
// void reserve();
|
||||
// void reserve(size_type res_arg);
|
||||
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
@@ -44,6 +46,9 @@ test(S s, typename S::size_type res_arg)
|
||||
assert(s == s0);
|
||||
assert(s.capacity() >= res_arg);
|
||||
assert(s.capacity() >= s.size());
|
||||
#if TEST_STD_VER > 17
|
||||
assert(s.capacity() >= old_cap); // resize never shrinks as of P0966
|
||||
#endif
|
||||
}
|
||||
#ifndef TEST_HAS_NO_EXCEPTIONS
|
||||
else
|
||||
@@ -90,6 +95,7 @@ int main()
|
||||
test(s, 10);
|
||||
test(s, 50);
|
||||
test(s, 100);
|
||||
test(s, 1000);
|
||||
test(s, S::npos);
|
||||
}
|
||||
}
|
||||
@@ -121,6 +127,7 @@ int main()
|
||||
test(s, 10);
|
||||
test(s, 50);
|
||||
test(s, 100);
|
||||
test(s, 1000);
|
||||
test(s, S::npos);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user