summaryrefslogtreecommitdiffstats
path: root/libcxx/test/strings/basic.string/string.modifiers/string::op+=/pointer.pass.cpp
blob: 4216fd419c628f1acfa03a6f584a4c4b8eb21b93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//===----------------------------------------------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <string>

// basic_string<charT,traits,Allocator>& operator+=(const charT* s);

#include <string>
#include <cassert>

template <class S>
void
test(S s, const typename S::value_type* str, S expected)
{
    s += str;
    assert(s.__invariants());
    assert(s == expected);
}

int main()
{
    typedef std::string S;
    test(S(), "", S());
    test(S(), "12345", S("12345"));
    test(S(), "1234567890", S("1234567890"));
    test(S(), "12345678901234567890", S("12345678901234567890"));

    test(S("12345"), "", S("12345"));
    test(S("12345"), "12345", S("1234512345"));
    test(S("12345"), "1234567890", S("123451234567890"));
    test(S("12345"), "12345678901234567890", S("1234512345678901234567890"));

    test(S("1234567890"), "", S("1234567890"));
    test(S("1234567890"), "12345", S("123456789012345"));
    test(S("1234567890"), "1234567890", S("12345678901234567890"));
    test(S("1234567890"), "12345678901234567890", S("123456789012345678901234567890"));

    test(S("12345678901234567890"), "", S("12345678901234567890"));
    test(S("12345678901234567890"), "12345", S("1234567890123456789012345"));
    test(S("12345678901234567890"), "1234567890", S("123456789012345678901234567890"));
    test(S("12345678901234567890"), "12345678901234567890",
         S("1234567890123456789012345678901234567890"));
}
OpenPOWER on IntegriCloud