xref: /llvm-project/libcxx/test/std/input.output/iostreams.base/ios.base/ios.base.storage/iword.pass.cpp (revision d486c5b11757be769051c1b2b6d6a18e2857dbbd)
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 // <ios>
10 
11 // class ios_base
12 
13 // long& iword(int idx);
14 
15 // This test compiles but never completes when compiled against the MSVC STL
16 // UNSUPPORTED: stdlib=msvc
17 
18 #include <ios>
19 #include <string>
20 #include <cassert>
21 
22 #include "test_macros.h"
23 
24 class test
25     : public std::ios
26 {
27 public:
test()28     test()
29     {
30         init(0);
31     }
32 };
33 
main(int,char **)34 int main(int, char**)
35 {
36     test t;
37     std::ios_base& b = t;
38     for (int i = 0; i < 10000; ++i)
39     {
40         assert(b.iword(i) == 0);
41         b.iword(i) = i;
42         assert(b.iword(i) == i);
43         for (int j = 0; j <= i; ++j)
44             assert(b.iword(j) == j);
45     }
46 
47   return 0;
48 }
49