1// Copyright (C) 2004-2015 Free Software Foundation, Inc.
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// 27.6.1.3 unformatted input functions
19
20#include <istream>
21#include <sstream>
22#include <testsuite_hooks.h>
23
24void
25test01()
26{
27  bool test __attribute__((unused)) = true;
28  const std::wstring str_01;
29  const std::wstring str_02(L"soul eyes: john coltrane quartet");
30  std::wstring strtmp;
31
32  std::wstringbuf isbuf_03(str_02, std::ios_base::in);
33  std::wstringbuf isbuf_04(str_02, std::ios_base::in);
34  std::wstringbuf isbuf_05(str_02, std::ios_base::in);
35
36  std::wistream is_00(&isbuf_05);
37  std::wistream is_03(&isbuf_03);
38  std::wistream is_04(&isbuf_04);
39  std::ios_base::iostate state1, state2;
40
41  // istream& putback(char_type c)
42  is_04.ignore(30);
43  is_04.clear();
44  state1 = is_04.rdstate();
45  is_04.putback(L't');
46  VERIFY( is_04.gcount() == 0 );  // DR 60
47  state2 = is_04.rdstate();
48  VERIFY( state1 == state2 );
49  VERIFY( is_04.peek() == L't' );
50
51  // istream& unget()
52  is_04.clear();
53  state1 = is_04.rdstate();
54  is_04.unget();
55  VERIFY( is_04.gcount() == 0 );  // DR 60
56  state2 = is_04.rdstate();
57  VERIFY( state1 == state2 );
58  VERIFY( is_04.peek() == L'r' );
59
60  // int sync()
61  is_00.ignore(10);
62  int count1 = is_00.gcount();
63  is_00.sync();
64  int count2 = is_00.gcount();
65  VERIFY (count1 == count2 );     // DR 60
66}
67
68int
69main()
70{
71  test01();
72  return 0;
73}
74