15a83710eSEric Fiselier //===----------------------------------------------------------------------===//
25a83710eSEric Fiselier //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
65a83710eSEric Fiselier //
75a83710eSEric Fiselier //===----------------------------------------------------------------------===//
85a83710eSEric Fiselier 
95a83710eSEric Fiselier // <sstream>
105a83710eSEric Fiselier 
115a83710eSEric Fiselier // template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
125a83710eSEric Fiselier // class basic_stringbuf
135a83710eSEric Fiselier 
145a83710eSEric Fiselier // template <class charT, class traits, class Allocator>
155a83710eSEric Fiselier //   void swap(basic_stringbuf<charT, traits, Allocator>& x,
165a83710eSEric Fiselier //             basic_stringbuf<charT, traits, Allocator>& y);
175a83710eSEric Fiselier 
185a83710eSEric Fiselier #include <sstream>
195a83710eSEric Fiselier #include <cassert>
205a83710eSEric Fiselier 
217fc6a556SMarshall Clow #include "test_macros.h"
227fc6a556SMarshall Clow 
main(int,char **)232df59c50SJF Bastien int main(int, char**)
245a83710eSEric Fiselier {
255a83710eSEric Fiselier     {
265a83710eSEric Fiselier         std::stringbuf buf1("testing");
275a83710eSEric Fiselier         std::stringbuf buf;
285a83710eSEric Fiselier         swap(buf, buf1);
295a83710eSEric Fiselier         assert(buf.str() == "testing");
305a83710eSEric Fiselier         assert(buf1.str() == "");
315a83710eSEric Fiselier     }
325a83710eSEric Fiselier     {
335a83710eSEric Fiselier         std::stringbuf buf1("testing", std::ios_base::in);
345a83710eSEric Fiselier         std::stringbuf buf;
355a83710eSEric Fiselier         swap(buf, buf1);
365a83710eSEric Fiselier         assert(buf.str() == "testing");
375a83710eSEric Fiselier         assert(buf1.str() == "");
385a83710eSEric Fiselier     }
395a83710eSEric Fiselier     {
405a83710eSEric Fiselier         std::stringbuf buf1("testing", std::ios_base::out);
415a83710eSEric Fiselier         std::stringbuf buf;
425a83710eSEric Fiselier         swap(buf, buf1);
435a83710eSEric Fiselier         assert(buf.str() == "testing");
445a83710eSEric Fiselier         assert(buf1.str() == "");
455a83710eSEric Fiselier     }
46*f4c1258dSLouis Dionne #ifndef TEST_HAS_NO_WIDE_CHARACTERS
475a83710eSEric Fiselier     {
485a83710eSEric Fiselier         std::wstringbuf buf1(L"testing");
495a83710eSEric Fiselier         std::wstringbuf buf;
505a83710eSEric Fiselier         swap(buf, buf1);
515a83710eSEric Fiselier         assert(buf.str() == L"testing");
525a83710eSEric Fiselier         assert(buf1.str() == L"");
535a83710eSEric Fiselier     }
545a83710eSEric Fiselier     {
555a83710eSEric Fiselier         std::wstringbuf buf1(L"testing", std::ios_base::in);
565a83710eSEric Fiselier         std::wstringbuf buf;
575a83710eSEric Fiselier         swap(buf, buf1);
585a83710eSEric Fiselier         assert(buf.str() == L"testing");
595a83710eSEric Fiselier         assert(buf1.str() == L"");
605a83710eSEric Fiselier     }
615a83710eSEric Fiselier     {
625a83710eSEric Fiselier         std::wstringbuf buf1(L"testing", std::ios_base::out);
635a83710eSEric Fiselier         std::wstringbuf buf;
645a83710eSEric Fiselier         swap(buf, buf1);
655a83710eSEric Fiselier         assert(buf.str() == L"testing");
665a83710eSEric Fiselier         assert(buf1.str() == L"");
675a83710eSEric Fiselier     }
68*f4c1258dSLouis Dionne #endif // TEST_HAS_NO_WIDE_CHARACTERS
692df59c50SJF Bastien 
702df59c50SJF Bastien   return 0;
715a83710eSEric Fiselier }
72