1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // <string> 11 12 // allocator_type get_allocator() const; 13 14 #include <string> 15 #include <cassert> 16 17 #include "test_allocator.h" 18 #include "min_allocator.h" 19 20 template <class S> 21 void 22 test(const S& s, const typename S::allocator_type& a) 23 { 24 assert(s.get_allocator() == a); 25 } 26 27 int main() 28 { 29 { 30 typedef test_allocator<char> A; 31 typedef std::basic_string<char, std::char_traits<char>, A> S; 32 test(S(""), A()); 33 test(S("abcde", A(1)), A(1)); 34 test(S("abcdefghij", A(2)), A(2)); 35 test(S("abcdefghijklmnopqrst", A(3)), A(3)); 36 } 37 #if __cplusplus >= 201103L 38 { 39 typedef min_allocator<char> A; 40 typedef std::basic_string<char, std::char_traits<char>, A> S; 41 test(S(""), A()); 42 test(S("abcde", A()), A()); 43 test(S("abcdefghij", A()), A()); 44 test(S("abcdefghijklmnopqrst", A()), A()); 45 } 46 #endif 47 } 48