blob: d9dccb3f791c652ddaf95dc1530e51236dbc6fea [file] [log] [blame]
Howard Hinnant3e519522010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
3// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// <string>
11
12// basic_string<charT,traits,Allocator>&
13// assign(const basic_string<charT,traits>& str);
14
15#include <string>
16#include <cassert>
17
18template <class S>
19void
20test(S s, S str, S expected)
21{
22 s.assign(str);
23 assert(s.__invariants());
24 assert(s == expected);
25}
26
27int main()
28{
29 typedef std::string S;
30 test(S(), S(), S());
31 test(S(), S("12345"), S("12345"));
32 test(S(), S("1234567890"), S("1234567890"));
33 test(S(), S("12345678901234567890"), S("12345678901234567890"));
34
35 test(S("12345"), S(), S());
36 test(S("12345"), S("12345"), S("12345"));
37 test(S("12345"), S("1234567890"), S("1234567890"));
38 test(S("12345"), S("12345678901234567890"), S("12345678901234567890"));
39
40 test(S("1234567890"), S(), S());
41 test(S("1234567890"), S("12345"), S("12345"));
42 test(S("1234567890"), S("1234567890"), S("1234567890"));
43 test(S("1234567890"), S("12345678901234567890"), S("12345678901234567890"));
44
45 test(S("12345678901234567890"), S(), S());
46 test(S("12345678901234567890"), S("12345"), S("12345"));
47 test(S("12345678901234567890"), S("1234567890"), S("1234567890"));
48 test(S("12345678901234567890"), S("12345678901234567890"),
49 S("12345678901234567890"));
50}