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