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 // REQUIRES: locale.en_US.UTF-8 10 11 // <streambuf> 12 13 // template <class charT, class traits = char_traits<charT> > 14 // class basic_streambuf; 15 16 // basic_streambuf& operator=(const basic_streambuf& rhs); 17 18 #include <streambuf> 19 #include <cassert> 20 21 #include "test_macros.h" 22 #include "platform_support.h" // locale name macros 23 24 template <class CharT> 25 struct test 26 : public std::basic_streambuf<CharT> 27 { 28 typedef std::basic_streambuf<CharT> base; 29 test() {} 30 31 test& operator=(const test& t) 32 { 33 base::operator=(t); 34 assert(this->eback() == t.eback()); 35 assert(this->gptr() == t.gptr()); 36 assert(this->egptr() == t.egptr()); 37 assert(this->pbase() == t.pbase()); 38 assert(this->pptr() == t.pptr()); 39 assert(this->epptr() == t.epptr()); 40 assert(this->getloc() == t.getloc()); 41 return *this; 42 } 43 44 void setg(CharT* gbeg, CharT* gnext, CharT* gend) 45 { 46 base::setg(gbeg, gnext, gend); 47 } 48 void setp(CharT* pbeg, CharT* pend) 49 { 50 base::setp(pbeg, pend); 51 } 52 }; 53 54 int main(int, char**) 55 { 56 { 57 test<char> t; 58 test<char> t2; 59 t2 = t; 60 } 61 { 62 char g1, g2, g3, p1, p3; 63 test<char> t; 64 t.setg(&g1, &g2, &g3); 65 t.setp(&p1, &p3); 66 test<char> t2; 67 t2 = t; 68 } 69 #ifndef TEST_HAS_NO_WIDE_CHARACTERS 70 { 71 test<wchar_t> t; 72 test<wchar_t> t2; 73 t2 = t; 74 } 75 { 76 wchar_t g1, g2, g3, p1, p3; 77 test<wchar_t> t; 78 t.setg(&g1, &g2, &g3); 79 t.setp(&p1, &p3); 80 test<wchar_t> t2; 81 t2 = t; 82 } 83 #endif 84 std::locale::global(std::locale(LOCALE_en_US_UTF_8)); 85 { 86 test<char> t; 87 test<char> t2; 88 t2 = t; 89 } 90 #ifndef TEST_HAS_NO_WIDE_CHARACTERS 91 { 92 test<wchar_t> t; 93 test<wchar_t> t2; 94 t2 = t; 95 } 96 #endif 97 98 return 0; 99 } 100