xref: /llvm-project/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.cons/alloc.pass.cpp (revision 81ad5a5cb87740c62b30a4f8232770bd5eb7fc45)
1*81ad5a5cSPiotr Fusik //===----------------------------------------------------------------------===//
2*81ad5a5cSPiotr Fusik //
3*81ad5a5cSPiotr Fusik // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*81ad5a5cSPiotr Fusik // See https://llvm.org/LICENSE.txt for license information.
5*81ad5a5cSPiotr Fusik // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*81ad5a5cSPiotr Fusik //
7*81ad5a5cSPiotr Fusik //===----------------------------------------------------------------------===//
8*81ad5a5cSPiotr Fusik 
9*81ad5a5cSPiotr Fusik // UNSUPPORTED: c++03, c++11, c++14, c++17
10*81ad5a5cSPiotr Fusik 
11*81ad5a5cSPiotr Fusik // <sstream>
12*81ad5a5cSPiotr Fusik 
13*81ad5a5cSPiotr Fusik // template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
14*81ad5a5cSPiotr Fusik // class basic_stringbuf
15*81ad5a5cSPiotr Fusik 
16*81ad5a5cSPiotr Fusik // explicit basic_stringbuf(const Allocator& a)
17*81ad5a5cSPiotr Fusik //     : basic_stringbuf(ios_base::in | ios_base::out, a) {}
18*81ad5a5cSPiotr Fusik 
19*81ad5a5cSPiotr Fusik #include <sstream>
20*81ad5a5cSPiotr Fusik #include <cassert>
21*81ad5a5cSPiotr Fusik 
22*81ad5a5cSPiotr Fusik #include "test_allocator.h"
23*81ad5a5cSPiotr Fusik #include "test_macros.h"
24*81ad5a5cSPiotr Fusik 
25*81ad5a5cSPiotr Fusik template <class CharT>
test()26*81ad5a5cSPiotr Fusik static void test() {
27*81ad5a5cSPiotr Fusik   const test_allocator<CharT> a(1);
28*81ad5a5cSPiotr Fusik   const std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>> buf(a);
29*81ad5a5cSPiotr Fusik   assert(buf.get_allocator() == a);
30*81ad5a5cSPiotr Fusik   assert(buf.view().empty());
31*81ad5a5cSPiotr Fusik }
32*81ad5a5cSPiotr Fusik 
main(int,char **)33*81ad5a5cSPiotr Fusik int main(int, char**) {
34*81ad5a5cSPiotr Fusik   test<char>();
35*81ad5a5cSPiotr Fusik #ifndef TEST_HAS_NO_WIDE_CHARACTERS
36*81ad5a5cSPiotr Fusik   test<wchar_t>();
37*81ad5a5cSPiotr Fusik #endif
38*81ad5a5cSPiotr Fusik   return 0;
39*81ad5a5cSPiotr Fusik }
40