[PowerPC][NFC] Cleanup PPCCTRLoopsVerify pass
[llvm-project.git] / libcxx / test / std / strings / basic.string / string.require / contiguous.pass.cpp
blobaf34fc97ff5b2ea9fb2be735b55e32b7decb2294
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 // <array>
11 // An string is a contiguous container
13 #include <string>
14 #include <cassert>
16 #include "test_macros.h"
17 #include "test_allocator.h"
18 #include "min_allocator.h"
21 template <class C>
22 void test_contiguous ( const C &c )
24 for ( size_t i = 0; i < c.size(); ++i )
25 assert ( *(c.begin() + static_cast<typename C::difference_type>(i)) == *(std::addressof(*c.begin()) + i));
28 int main(int, char**)
31 typedef std::string S;
32 test_contiguous(S());
33 test_contiguous(S("1"));
34 test_contiguous(S("1234567890123456789012345678901234567890123456789012345678901234567890"));
38 typedef test_allocator<char> A;
39 typedef std::basic_string<char, std::char_traits<char>, A> S;
40 test_contiguous(S(A(3)));
41 test_contiguous(S("1", A(5)));
42 test_contiguous(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)));
44 #if TEST_STD_VER >= 11
46 typedef min_allocator<char> A;
47 typedef std::basic_string<char, std::char_traits<char>, A> S;
48 test_contiguous(S(A{}));
49 test_contiguous(S("1", A()));
50 test_contiguous(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()));
52 #endif
54 return 0;