Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4 | // |
Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // <string> |
| 11 | |
| 12 | // basic_string<charT,traits,Allocator>& operator=(charT c); |
| 13 | |
| 14 | #include <string> |
| 15 | #include <cassert> |
| 16 | |
Marshall Clow | 061d0cc | 2013-11-26 20:58:02 +0000 | [diff] [blame^] | 17 | #include "min_allocator.h" |
Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 18 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 19 | template <class S> |
| 20 | void |
| 21 | test(S s1, typename S::value_type s2) |
| 22 | { |
| 23 | typedef typename S::traits_type T; |
| 24 | s1 = s2; |
| 25 | assert(s1.__invariants()); |
| 26 | assert(s1.size() == 1); |
| 27 | assert(T::eq(s1[0], s2)); |
| 28 | assert(s1.capacity() >= s1.size()); |
| 29 | } |
| 30 | |
| 31 | int main() |
| 32 | { |
Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 33 | { |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 34 | typedef std::string S; |
| 35 | test(S(), 'a'); |
| 36 | test(S("1"), 'a'); |
| 37 | test(S("123456789"), 'a'); |
| 38 | test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), 'a'); |
Howard Hinnant | 9dcdcde | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 39 | } |
| 40 | #if __cplusplus >= 201103L |
| 41 | { |
| 42 | typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; |
| 43 | test(S(), 'a'); |
| 44 | test(S("1"), 'a'); |
| 45 | test(S("123456789"), 'a'); |
| 46 | test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), 'a'); |
| 47 | } |
| 48 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 49 | } |