1*6ed40418SPiotr Fusik //===----------------------------------------------------------------------===//
2*6ed40418SPiotr Fusik //
3*6ed40418SPiotr Fusik // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*6ed40418SPiotr Fusik // See https://llvm.org/LICENSE.txt for license information.
5*6ed40418SPiotr Fusik // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*6ed40418SPiotr Fusik //
7*6ed40418SPiotr Fusik //===----------------------------------------------------------------------===//
8*6ed40418SPiotr Fusik 
9*6ed40418SPiotr Fusik // UNSUPPORTED: c++03, c++11, c++14, c++17
10*6ed40418SPiotr Fusik 
11*6ed40418SPiotr Fusik // <sstream>
12*6ed40418SPiotr Fusik 
13*6ed40418SPiotr Fusik // template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
14*6ed40418SPiotr Fusik // class basic_ostringstream
15*6ed40418SPiotr Fusik 
16*6ed40418SPiotr Fusik // template <class SAlloc>
17*6ed40418SPiotr Fusik // basic_string<charT, traits, SAlloc> str(const SAlloc& sa) const;
18*6ed40418SPiotr Fusik 
19*6ed40418SPiotr Fusik #include <sstream>
20*6ed40418SPiotr Fusik #include <cassert>
21*6ed40418SPiotr Fusik 
22*6ed40418SPiotr Fusik #include "make_string.h"
23*6ed40418SPiotr Fusik #include "test_allocator.h"
24*6ed40418SPiotr Fusik #include "test_macros.h"
25*6ed40418SPiotr Fusik 
26*6ed40418SPiotr Fusik #define STR(S) MAKE_STRING(CharT, S)
27*6ed40418SPiotr Fusik #define SV(S) MAKE_STRING_VIEW(CharT, S)
28*6ed40418SPiotr Fusik 
29*6ed40418SPiotr Fusik template <class CharT>
test()30*6ed40418SPiotr Fusik static void test() {
31*6ed40418SPiotr Fusik   const std::basic_ostringstream<CharT> ss(STR("testing"));
32*6ed40418SPiotr Fusik   const test_allocator<CharT> a(1);
33*6ed40418SPiotr Fusik   const std::basic_string<CharT, std::char_traits<CharT>, test_allocator<CharT>> s = ss.str(a);
34*6ed40418SPiotr Fusik   assert(s == SV("testing"));
35*6ed40418SPiotr Fusik   assert(s.get_allocator() == a);
36*6ed40418SPiotr Fusik }
37*6ed40418SPiotr Fusik 
main(int,char **)38*6ed40418SPiotr Fusik int main(int, char**) {
39*6ed40418SPiotr Fusik   test<char>();
40*6ed40418SPiotr Fusik #ifndef TEST_HAS_NO_WIDE_CHARACTERS
41*6ed40418SPiotr Fusik   test<wchar_t>();
42*6ed40418SPiotr Fusik #endif
43*6ed40418SPiotr Fusik   return 0;
44*6ed40418SPiotr Fusik }
45