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// <sstream>
11
12// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
13// class basic_stringbuf
14
15// void swap(basic_stringbuf& rhs);
16
17#include <sstream>
18#include <cassert>
19
20int main()
21{
22    {
23        std::stringbuf buf1("testing");
24        std::stringbuf buf;
25        buf.swap(buf1);
26        assert(buf.str() == "testing");
27        assert(buf1.str() == "");
28    }
29    {
30        std::stringbuf buf1("testing", std::ios_base::in);
31        std::stringbuf buf;
32        buf.swap(buf1);
33        assert(buf.str() == "testing");
34        assert(buf1.str() == "");
35    }
36    {
37        std::stringbuf buf1("testing", std::ios_base::out);
38        std::stringbuf buf;
39        buf.swap(buf1);
40        assert(buf.str() == "testing");
41        assert(buf1.str() == "");
42    }
43    {
44        std::wstringbuf buf1(L"testing");
45        std::wstringbuf buf;
46        buf.swap(buf1);
47        assert(buf.str() == L"testing");
48        assert(buf1.str() == L"");
49    }
50    {
51        std::wstringbuf buf1(L"testing", std::ios_base::in);
52        std::wstringbuf buf;
53        buf.swap(buf1);
54        assert(buf.str() == L"testing");
55        assert(buf1.str() == L"");
56    }
57    {
58        std::wstringbuf buf1(L"testing", std::ios_base::out);
59        std::wstringbuf buf;
60        buf.swap(buf1);
61        assert(buf.str() == L"testing");
62        assert(buf1.str() == L"");
63    }
64}
65