1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
11 // void swap(basic_string& s);
18 #include "test_macros.h"
19 #include "min_allocator.h"
28 LIBCPP_ASSERT(s1
.__invariants());
29 LIBCPP_ASSERT(s2
.__invariants());
37 typedef std::string S
;
39 test(S(""), S("12345"));
40 test(S(""), S("1234567890"));
41 test(S(""), S("12345678901234567890"));
42 test(S("abcde"), S(""));
43 test(S("abcde"), S("12345"));
44 test(S("abcde"), S("1234567890"));
45 test(S("abcde"), S("12345678901234567890"));
46 test(S("abcdefghij"), S(""));
47 test(S("abcdefghij"), S("12345"));
48 test(S("abcdefghij"), S("1234567890"));
49 test(S("abcdefghij"), S("12345678901234567890"));
50 test(S("abcdefghijklmnopqrst"), S(""));
51 test(S("abcdefghijklmnopqrst"), S("12345"));
52 test(S("abcdefghijklmnopqrst"), S("1234567890"));
53 test(S("abcdefghijklmnopqrst"), S("12345678901234567890"));
55 #if TEST_STD_VER >= 11
57 typedef std::basic_string
<char, std::char_traits
<char>, min_allocator
<char>> S
;
59 test(S(""), S("12345"));
60 test(S(""), S("1234567890"));
61 test(S(""), S("12345678901234567890"));
62 test(S("abcde"), S(""));
63 test(S("abcde"), S("12345"));
64 test(S("abcde"), S("1234567890"));
65 test(S("abcde"), S("12345678901234567890"));
66 test(S("abcdefghij"), S(""));
67 test(S("abcdefghij"), S("12345"));
68 test(S("abcdefghij"), S("1234567890"));
69 test(S("abcdefghij"), S("12345678901234567890"));
70 test(S("abcdefghijklmnopqrst"), S(""));
71 test(S("abcdefghijklmnopqrst"), S("12345"));
72 test(S("abcdefghijklmnopqrst"), S("1234567890"));
73 test(S("abcdefghijklmnopqrst"), S("12345678901234567890"));