brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · 1db5608 Raw
90 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// <ios>10 11// class ios_base12 13// ~ios_base()14 15#include <ios>16#include <string>17#include <locale>18#include <cassert>19 20#include "test_macros.h"21 22class test23    : public std::ios24{25public:26    test()27    {28        init(0);29    }30};31 32bool f1_called = false;33bool f2_called = false;34bool f3_called = false;35 36void f1(std::ios_base::event ev, std::ios_base& stream, int index)37{38    if (ev == std::ios_base::erase_event)39    {40        assert(!f1_called);41        assert( f2_called);42        assert( f3_called);43        assert(stream.getloc().name() == "C");44        assert(index == 4);45        f1_called = true;46    }47}48 49void f2(std::ios_base::event ev, std::ios_base& stream, int index)50{51    if (ev == std::ios_base::erase_event)52    {53        assert(!f1_called);54        assert(!f2_called);55        assert( f3_called);56        assert(stream.getloc().name() == "C");57        assert(index == 5);58        f2_called = true;59    }60}61 62void f3(std::ios_base::event ev, std::ios_base& stream, int index)63{64    if (ev == std::ios_base::erase_event)65    {66        assert(!f1_called);67        assert(!f2_called);68        assert(!f3_called);69        assert(stream.getloc().name() == "C");70        assert(index == 6);71        f3_called = true;72    }73}74 75int main(int, char**)76{77    {78        test t;79        std::ios_base& b = t;80        b.register_callback(f1, 4);81        b.register_callback(f2, 5);82        b.register_callback(f3, 6);83    }84    assert(f1_called);85    assert(f2_called);86    assert(f3_called);87 88  return 0;89}90