[libc++][doc] Updates format status.
[llvm-project.git] / libcxx / test / std / input.output / string.streams / istringstream / istringstream.members / str.pass.cpp
blob5ab126a76d58639359274d760cffe1438688db43
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 //===----------------------------------------------------------------------===//
9 // <sstream>
11 // template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
12 // class basic_istringstream
14 // void str(const basic_string<charT,traits,Allocator>& s);
16 #include <sstream>
17 #include <cassert>
19 #include "test_macros.h"
21 int main(int, char**)
24 std::istringstream ss(" 123 456");
25 assert(ss.rdbuf() != 0);
26 assert(ss.good());
27 assert(ss.str() == " 123 456");
28 int i = 0;
29 ss >> i;
30 assert(i == 123);
31 ss >> i;
32 assert(i == 456);
33 ss.str(" 789");
34 ss.clear();
35 assert(ss.good());
36 assert(ss.str() == " 789");
37 ss >> i;
38 assert(i == 789);
40 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
42 std::wistringstream ss(L" 123 456");
43 assert(ss.rdbuf() != 0);
44 assert(ss.good());
45 assert(ss.str() == L" 123 456");
46 int i = 0;
47 ss >> i;
48 assert(i == 123);
49 ss >> i;
50 assert(i == 456);
51 ss.str(L" 789");
52 ss.clear();
53 assert(ss.good());
54 assert(ss.str() == L" 789");
55 ss >> i;
56 assert(i == 789);
58 #endif
60 return 0;