pword.pass.cpp revision d712a59c7fdebbbdc32598e3b0e6894600b6379a
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// <ios>
11
12// class ios_base
13
14// void*& pword(int idx);
15
16#include <ios>
17#include <string>
18#include <cassert>
19#include <cstdint>
20
21class test
22    : public std::ios
23{
24public:
25    test()
26    {
27        init(0);
28    }
29};
30
31int main()
32{
33    test t;
34    std::ios_base& b = t;
35    for (std::intptr_t i = 0; i < 10000; ++i)
36    {
37        assert(b.pword(i) == 0);
38        b.pword(i) = (void*)i;
39        assert(b.pword(i) == (void*)i);
40        for (std::intptr_t j = 0; j <= i; ++j)
41            assert(b.pword(j) == (void*)j);
42    }
43}
44