Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Howard Hinnant | 5b08a8a | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 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>& operator=(charT c); |
| 13 | |
| 14 | #include <string> |
| 15 | #include <cassert> |
| 16 | |
| 17 | template <class S> |
| 18 | void |
| 19 | test(S s1, typename S::value_type s2) |
| 20 | { |
| 21 | typedef typename S::traits_type T; |
| 22 | s1 = s2; |
| 23 | assert(s1.__invariants()); |
| 24 | assert(s1.size() == 1); |
| 25 | assert(T::eq(s1[0], s2)); |
| 26 | assert(s1.capacity() >= s1.size()); |
| 27 | } |
| 28 | |
| 29 | int main() |
| 30 | { |
| 31 | typedef std::string S; |
| 32 | test(S(), 'a'); |
| 33 | test(S("1"), 'a'); |
| 34 | test(S("123456789"), 'a'); |
| 35 | test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), 'a'); |
| 36 | } |