blob: c6e34e1b85ce52aac4649150585556c83309d375 [file] [log] [blame]
Howard Hinnant3e519522010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnant5b08a8a2010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnant3e519522010-05-11 19:42:16 +00004//
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
Howard Hinnantbf2897c2010-08-22 00:47:54 +000012// basic_string<charT,traits,Allocator>&
Howard Hinnant3e519522010-05-11 19:42:16 +000013// operator=(const basic_string<charT,traits,Allocator>& str);
14
15#include <string>
16#include <cassert>
17
18template <class S>
19void
20test(S s1, const S& s2)
21{
22 s1 = s2;
23 assert(s1.__invariants());
24 assert(s1 == s2);
25 assert(s1.capacity() >= s1.size());
26}
27
28int main()
29{
30 typedef std::string S;
31 test(S(), S());
32 test(S("1"), S());
33 test(S(), S("1"));
34 test(S("1"), S("2"));
35 test(S("1"), S("2"));
36
37 test(S(),
38 S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
39 test(S("123456789"),
40 S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
41 test(S("1234567890123456789012345678901234567890123456789012345678901234567890"),
42 S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
43 test(S("1234567890123456789012345678901234567890123456789012345678901234567890"
44 "1234567890123456789012345678901234567890123456789012345678901234567890"),
45 S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
46}