/* IosSavepoint(Test) - manipulate and restore output stream formatting Copyright (C) 2022, Hermann Vosseler   **Lumiera** is free software; you can redistribute it and/or modify it   under the terms of the GNU General Public License as published by the   Free Software Foundation; either version 2 of the License, or (at your   option) any later version. See the file COPYING for further details. * *****************************************************************/ /** @file ios-savepoint-test.cpp ** unit test \ref IosSavepoint_test */ #include "lib/test/run.hpp" #include "lib/format-cout.hpp" #include "lib/ios-savepoint.hpp" #include #include using std::string; namespace util { namespace test { /***************************************************************************//** * @test verifies capturing and restoring of std::ostream formatting state. * @see ios-savepoint.hpp */ class IosSavepoint_test : public Test { void run (Arg) { switchToHex(); __verifySane(); setFill(); __verifySane(); nested(); __verifySane(); try { restoreAfterException(); } catch(...){ cout << "Tilt" < float { throw 42; }; IosSavepoint save{cout}; cout << std::hexfloat << 1234 << endl << boom() << endl; } }; LAUNCHER (IosSavepoint_test, "unit common"); }} // namespace util::test