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 // <streambuf>
11
12 // template <class charT, class traits = char_traits<charT> >
13 // class basic_streambuf;
14
15 // basic_streambuf(const basic_streambuf& rhs);
16
17 #include <streambuf>
18 #include <cassert>
19
20 #include "platform_support.h" // locale name macros
21
22 template <class CharT>
23 struct test
24 : public std::basic_streambuf<CharT>
25 {
26 typedef std::basic_streambuf<CharT> base;
testtest27 test() {}
28
testtest29 test(const test& t)
30 : std::basic_streambuf<CharT>(t)
31 {
32 assert(this->eback() == t.eback());
33 assert(this->gptr() == t.gptr());
34 assert(this->egptr() == t.egptr());
35 assert(this->pbase() == t.pbase());
36 assert(this->pptr() == t.pptr());
37 assert(this->epptr() == t.epptr());
38 assert(this->getloc() == t.getloc());
39 }
40
setgtest41 void setg(CharT* gbeg, CharT* gnext, CharT* gend)
42 {
43 base::setg(gbeg, gnext, gend);
44 }
setptest45 void setp(CharT* pbeg, CharT* pend)
46 {
47 base::setp(pbeg, pend);
48 }
49 };
50
main()51 int main()
52 {
53 {
54 test<char> t;
55 test<char> t2 = t;
56 }
57 {
58 test<wchar_t> t;
59 test<wchar_t> 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 = t;
67 }
68 {
69 wchar_t g1, g2, g3, p1, p3;
70 test<wchar_t> t;
71 t.setg(&g1, &g2, &g3);
72 t.setp(&p1, &p3);
73 test<wchar_t> t2 = t;
74 }
75 std::locale::global(std::locale(LOCALE_en_US_UTF_8));
76 {
77 test<char> t;
78 test<char> t2 = t;
79 }
80 {
81 test<wchar_t> t;
82 test<wchar_t> t2 = t;
83 }
84 }
85