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 | |
| 12 | // explicit basic_string(const Allocator& a = Allocator()); |
| 13 | |
| 14 | #include <string> |
| 15 | #include <cassert> |
| 16 | |
| 17 | #include "../test_allocator.h" |
| 18 | |
| 19 | template <class S> |
| 20 | void |
| 21 | test() |
| 22 | { |
| 23 | { |
| 24 | S s; |
| 25 | assert(s.__invariants()); |
| 26 | assert(s.data()); |
| 27 | assert(s.size() == 0); |
| 28 | assert(s.capacity() >= s.size()); |
| 29 | assert(s.get_allocator() == typename S::allocator_type()); |
| 30 | } |
| 31 | { |
| 32 | S s(typename S::allocator_type(5)); |
| 33 | assert(s.__invariants()); |
| 34 | assert(s.data()); |
| 35 | assert(s.size() == 0); |
| 36 | assert(s.capacity() >= s.size()); |
| 37 | assert(s.get_allocator() == typename S::allocator_type(5)); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | int main() |
| 42 | { |
| 43 | test<std::basic_string<char, std::char_traits<char>, test_allocator<char> > >(); |
| 44 | } |