From f76d4d228b32e72c7de250cb37af264d38ee7e79 Mon Sep 17 00:00:00 2001 From: ljfa Date: Mon, 21 Sep 2015 10:21:17 +0200 Subject: Make close honor the exceptions mask --- test/zlibstream_test.h | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'test') diff --git a/test/zlibstream_test.h b/test/zlibstream_test.h index 204764e370..5f2ad64c55 100644 --- a/test/zlibstream_test.h +++ b/test/zlibstream_test.h @@ -224,12 +224,28 @@ public: void test_deflate_closed() { std::stringstream str; - ozlibstream ozls(str); - ozls.exceptions(std::ios::failbit | std::ios::badbit); - TS_ASSERT_THROWS_NOTHING(ozls << bigtest); - TS_ASSERT_THROWS_NOTHING(ozls.close()); - TS_ASSERT_THROWS(ozls << "foo" << std::flush, zlib_error); - TS_ASSERT(ozls.bad()); - TS_ASSERT(!str); + { + ozlibstream ozls(str); + ozls.exceptions(std::ios::failbit | std::ios::badbit); + TS_ASSERT_THROWS_NOTHING(ozls << bigtest); + TS_ASSERT_THROWS_NOTHING(ozls.close()); + TS_ASSERT_THROWS_NOTHING(ozls << "foo"); + TS_ASSERT_THROWS_ANYTHING(ozls.close()); + TS_ASSERT(ozls.bad()); + TS_ASSERT(!str); + } + str.clear(); + str.seekp(0); + { + ozlibstream ozls(str); + //this time without exceptions + TS_ASSERT_THROWS_NOTHING(ozls << bigtest); + TS_ASSERT_THROWS_NOTHING(ozls.close()); + TS_ASSERT_THROWS_NOTHING(ozls << "foo" << std::flush); + TS_ASSERT(ozls.bad()); + TS_ASSERT_THROWS_NOTHING(ozls.close()); + TS_ASSERT(ozls.bad()); + TS_ASSERT(!str); + } } }; -- cgit 0.0.5-2-1-g0f52