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>& |
| 13 | // assign(const basic_string<charT,traits>& str); |
| 14 | |
| 15 | #include <string> |
| 16 | #include <cassert> |
| 17 | |
| 18 | template <class S> |
| 19 | void |
| 20 | test(S s, S str, S expected) |
| 21 | { |
| 22 | s.assign(str); |
| 23 | assert(s.__invariants()); |
| 24 | assert(s == expected); |
| 25 | } |
| 26 | |
| 27 | int main() |
| 28 | { |
| 29 | typedef std::string S; |
| 30 | test(S(), S(), S()); |
| 31 | test(S(), S("12345"), S("12345")); |
| 32 | test(S(), S("1234567890"), S("1234567890")); |
| 33 | test(S(), S("12345678901234567890"), S("12345678901234567890")); |
| 34 | |
| 35 | test(S("12345"), S(), S()); |
| 36 | test(S("12345"), S("12345"), S("12345")); |
| 37 | test(S("12345"), S("1234567890"), S("1234567890")); |
| 38 | test(S("12345"), S("12345678901234567890"), S("12345678901234567890")); |
| 39 | |
| 40 | test(S("1234567890"), S(), S()); |
| 41 | test(S("1234567890"), S("12345"), S("12345")); |
| 42 | test(S("1234567890"), S("1234567890"), S("1234567890")); |
| 43 | test(S("1234567890"), S("12345678901234567890"), S("12345678901234567890")); |
| 44 | |
| 45 | test(S("12345678901234567890"), S(), S()); |
| 46 | test(S("12345678901234567890"), S("12345"), S("12345")); |
| 47 | test(S("12345678901234567890"), S("1234567890"), S("1234567890")); |
| 48 | test(S("12345678901234567890"), S("12345678901234567890"), |
| 49 | S("12345678901234567890")); |
| 50 | } |