blob: bde0480dd8ca342b0d07f54ab6daff33cbbe359c [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 charT* s);
14
15#include <string>
16#include <cassert>
17
18template <class S>
19void
20test(S s1, const typename S::value_type* s2)
21{
22 typedef typename S::traits_type T;
23 s1 = s2;
24 assert(s1.__invariants());
25 assert(s1.size() == T::length(s2));
26 assert(T::compare(s1.data(), s2, s1.size()) == 0);
27 assert(s1.capacity() >= s1.size());
28}
29
30int main()
31{
32 typedef std::string S;
33 test(S(), "");
34 test(S("1"), "");
35 test(S(), "1");
36 test(S("1"), "2");
37 test(S("1"), "2");
38
39 test(S(),
40 "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
41 test(S("123456789"),
42 "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
43 test(S("1234567890123456789012345678901234567890123456789012345678901234567890"),
44 "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
45 test(S("1234567890123456789012345678901234567890123456789012345678901234567890"
46 "1234567890123456789012345678901234567890123456789012345678901234567890"),
47 "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
48}