]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/27_io/basic_istringstream/cons/wchar_t/1.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 27_io / basic_istringstream / cons / wchar_t / 1.cc
CommitLineData
99dee823 1// Copyright (C) 2020-2021 Free Software Foundation, Inc.
a0e4d7b4
TR
2//
3// This file is part of the GNU ISO C++ Library. This library is free
4// software; you can redistribute it and/or modify it under the
5// terms of the GNU General Public License as published by the
6// Free Software Foundation; either version 3, or (at your option)
7// any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License along
15// with this library; see the file COPYING3. If not see
16// <http://www.gnu.org/licenses/>.
17
18// C++20 29.8.2.2 basic_stringbuf constructors [stringbuf.cons
19
20// { dg-options "-std=gnu++2a" }
21// { dg-do run { target c++2a } }
22// { dg-require-effective-target cxx11-abi }
23
24#include <sstream>
25#include <string>
26#include <testsuite_allocator.h>
27#include <testsuite_hooks.h>
28
29void
30test01()
31{
32 std::wistringstream::allocator_type a;
33 std::wistringstream stm(std::ios_base::in, a);
34}
35
36auto const cstr = L"This is a test";
37
38void
39test02()
40{
41 std::wstring s1(cstr);
42 std::wistringstream stm(std::move(s1));
43 VERIFY( s1.empty() );
44
45 std::wstring s2(cstr);
46 VERIFY( stm.str() == s2 );
47}
48
49void
50test03()
51{
52 using alloc_type = __gnu_test::tracker_allocator<wchar_t>;
53 using str_type = std::basic_string<wchar_t, std::char_traits<wchar_t>, alloc_type>;
54
55 auto const mode = std::ios_base::in;
56 str_type s1(cstr);
57
58 {
59 std::wistringstream::allocator_type a;
60 std::wistringstream sbuf(s1, mode, a);
61 std::wstring s2(cstr);
62 VERIFY( sbuf.str() == s2 );
63 }
64
65 {
66 std::wistringstream sbuf(s1, mode);
67 std::wstring s2(cstr);
68 VERIFY( sbuf.str() == s2 );
69 }
70
71 {
72 std::wistringstream sbuf(s1);
73 std::wstring s2(cstr);
74 VERIFY( sbuf.str() == s2 );
75 }
76}
77
78int
79main()
80{
81 test01();
82 test02();
83 test03();
84 return 0;
85}