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 | // |
| 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 Hinnant | 6e0a1f4 | 2010-08-22 00:47:54 +0000 | [diff] [blame^] | 12 | // basic_string<charT,traits,Allocator>& |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 13 | // assign(size_type n, charT c); |
| 14 | |
| 15 | #include <string> |
| 16 | #include <cassert> |
| 17 | |
| 18 | template <class S> |
| 19 | void |
| 20 | test(S s, typename S::size_type n, typename S::value_type c, S expected) |
| 21 | { |
| 22 | s.assign(n, c); |
| 23 | assert(s.__invariants()); |
| 24 | assert(s == expected); |
| 25 | } |
| 26 | |
| 27 | int main() |
| 28 | { |
| 29 | typedef std::string S; |
| 30 | test(S(), 0, 'a', S()); |
| 31 | test(S(), 1, 'a', S(1, 'a')); |
| 32 | test(S(), 10, 'a', S(10, 'a')); |
| 33 | test(S(), 100, 'a', S(100, 'a')); |
| 34 | |
| 35 | test(S("12345"), 0, 'a', S()); |
| 36 | test(S("12345"), 1, 'a', S(1, 'a')); |
| 37 | test(S("12345"), 10, 'a', S(10, 'a')); |
| 38 | |
| 39 | test(S("12345678901234567890"), 0, 'a', S()); |
| 40 | test(S("12345678901234567890"), 1, 'a', S(1, 'a')); |
| 41 | test(S("12345678901234567890"), 10, 'a', S(10, 'a')); |
| 42 | } |