1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 // <sstream> 10 11 // template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > 12 // class basic_stringbuf 13 14 // template <class charT, class traits, class Allocator> 15 // void swap(basic_stringbuf<charT, traits, Allocator>& x, 16 // basic_stringbuf<charT, traits, Allocator>& y); 17 18 #include <sstream> 19 #include <cassert> 20 21 #include "test_macros.h" 22 23 int main(int, char**) 24 { 25 { 26 std::stringbuf buf1("testing"); 27 std::stringbuf buf; 28 swap(buf, buf1); 29 assert(buf.str() == "testing"); 30 assert(buf1.str() == ""); 31 } 32 { 33 std::stringbuf buf1("testing", std::ios_base::in); 34 std::stringbuf buf; 35 swap(buf, buf1); 36 assert(buf.str() == "testing"); 37 assert(buf1.str() == ""); 38 } 39 { 40 std::stringbuf buf1("testing", std::ios_base::out); 41 std::stringbuf buf; 42 swap(buf, buf1); 43 assert(buf.str() == "testing"); 44 assert(buf1.str() == ""); 45 } 46 { 47 std::wstringbuf buf1(L"testing"); 48 std::wstringbuf buf; 49 swap(buf, buf1); 50 assert(buf.str() == L"testing"); 51 assert(buf1.str() == L""); 52 } 53 { 54 std::wstringbuf buf1(L"testing", std::ios_base::in); 55 std::wstringbuf buf; 56 swap(buf, buf1); 57 assert(buf.str() == L"testing"); 58 assert(buf1.str() == L""); 59 } 60 { 61 std::wstringbuf buf1(L"testing", std::ios_base::out); 62 std::wstringbuf buf; 63 swap(buf, buf1); 64 assert(buf.str() == L"testing"); 65 assert(buf1.str() == L""); 66 } 67 68 return 0; 69 } 70