mirror of
https://github.com/clang-retro/llvm.git
synced 2026-12-04 08:09:27 -08:00
[libc++] Apply clang formatting to all string unit tests
This applies clang-format to the std::string unit tests in preparation for landing https://reviews.llvm.org/D140550. Differential Revision: https://reviews.llvm.org/D140612
This commit is contained in:
1 parent
823151f0cf
commit
a40bada91a
417 files changed
+56733
-58199
No files matched your search
@@ -18,33 +18,25 @@
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
TEST_CONSTEXPR_CXX20 void
|
||||
test_const(const S& s)
|
||||
{
|
||||
typedef typename S::traits_type T;
|
||||
const typename S::value_type* str = s.data();
|
||||
if (s.size() > 0)
|
||||
{
|
||||
assert(T::compare(str, &s[0], s.size()) == 0);
|
||||
assert(T::eq(str[s.size()], typename S::value_type()));
|
||||
}
|
||||
else
|
||||
assert(T::eq(str[0], typename S::value_type()));
|
||||
TEST_CONSTEXPR_CXX20 void test_const(const S& s) {
|
||||
typedef typename S::traits_type T;
|
||||
const typename S::value_type* str = s.data();
|
||||
if (s.size() > 0) {
|
||||
assert(T::compare(str, &s[0], s.size()) == 0);
|
||||
assert(T::eq(str[s.size()], typename S::value_type()));
|
||||
} else
|
||||
assert(T::eq(str[0], typename S::value_type()));
|
||||
}
|
||||
|
||||
template <class S>
|
||||
TEST_CONSTEXPR_CXX20 void
|
||||
test_nonconst(S& s)
|
||||
{
|
||||
typedef typename S::traits_type T;
|
||||
typename S::value_type* str = s.data();
|
||||
if (s.size() > 0)
|
||||
{
|
||||
assert(T::compare(str, &s[0], s.size()) == 0);
|
||||
assert(T::eq(str[s.size()], typename S::value_type()));
|
||||
}
|
||||
else
|
||||
assert(T::eq(str[0], typename S::value_type()));
|
||||
TEST_CONSTEXPR_CXX20 void test_nonconst(S& s) {
|
||||
typedef typename S::traits_type T;
|
||||
typename S::value_type* str = s.data();
|
||||
if (s.size() > 0) {
|
||||
assert(T::compare(str, &s[0], s.size()) == 0);
|
||||
assert(T::eq(str[s.size()], typename S::value_type()));
|
||||
} else
|
||||
assert(T::eq(str[0], typename S::value_type()));
|
||||
}
|
||||
|
||||
TEST_CONSTEXPR_CXX20 bool test() {
|
||||
@@ -67,18 +59,21 @@ TEST_CONSTEXPR_CXX20 bool test() {
|
||||
#if TEST_STD_VER > 14
|
||||
{
|
||||
typedef std::string S;
|
||||
S s1(""); test_nonconst(s1);
|
||||
S s2("abcde"); test_nonconst(s2);
|
||||
S s3("abcdefghij"); test_nonconst(s3);
|
||||
S s4("abcdefghijklmnopqrst"); test_nonconst(s4);
|
||||
S s1("");
|
||||
test_nonconst(s1);
|
||||
S s2("abcde");
|
||||
test_nonconst(s2);
|
||||
S s3("abcdefghij");
|
||||
test_nonconst(s3);
|
||||
S s4("abcdefghijklmnopqrst");
|
||||
test_nonconst(s4);
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
int main(int, char**) {
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
static_assert(test());
|
||||
|
||||
Reference in new issue
Block a user