mirror of
https://github.com/clang-retro/llvm.git
synced 2026-12-05 00:29:35 -08:00
[libc++] Refactor string unit tests to ease addition of new allocators
While doing this, I also found a few tests that were either clearly incorrect (e.g. testing the wrong function) or that lacked basic test coverage like testing std::string itself (e.g. the test was only checking std::basic_string with a custom allocator). In these cases, I did a few conservative drive-by changes. Differential Revision: https://reviews.llvm.org/D140550 Co-authored-by: Brendan Emery <brendan.emery@esrlabs.com>
This commit is contained in:
1 parent
47b7f33b13
commit
6e1dcc9335
149 files changed
+2959
-4153
No files matched your search
+10
-13
@@ -18,20 +18,17 @@
|
||||
#include "test_macros.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
TEST_CONSTEXPR_CXX20 void test_string() {
|
||||
S s("123456");
|
||||
typename S::iterator i = s.insert(s.begin() + 3, {'a', 'b', 'c'});
|
||||
assert(i - s.begin() == 3);
|
||||
assert(s == "123abc456");
|
||||
}
|
||||
|
||||
TEST_CONSTEXPR_CXX20 bool test() {
|
||||
{
|
||||
std::string s("123456");
|
||||
std::string::iterator i = s.insert(s.begin() + 3, {'a', 'b', 'c'});
|
||||
assert(i - s.begin() == 3);
|
||||
assert(s == "123abc456");
|
||||
}
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
S s("123456");
|
||||
S::iterator i = s.insert(s.begin() + 3, {'a', 'b', 'c'});
|
||||
assert(i - s.begin() == 3);
|
||||
assert(s == "123abc456");
|
||||
}
|
||||
test_string<std::string>();
|
||||
test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user