From ba0cc39046dbe0074873b1f9c09ef994606378e1 Mon Sep 17 00:00:00 2001 From: Blake Thompson Date: Mon, 11 May 2015 15:51:39 -0500 Subject: [PATCH] Updated tests so that they use REQUIRE_THROWS --- test/unit/imaging/image_io_test.cpp | 62 ++++------------------------- 1 file changed, 7 insertions(+), 55 deletions(-) diff --git a/test/unit/imaging/image_io_test.cpp b/test/unit/imaging/image_io_test.cpp index 299801008..b6380ea84 100644 --- a/test/unit/imaging/image_io_test.cpp +++ b/test/unit/imaging/image_io_test.cpp @@ -25,26 +25,10 @@ SECTION("readers") { REQUIRE( mapnik::util::exists( should_throw ) ); type = mapnik::type_from_filename(should_throw); REQUIRE( type ); - try - { - std::unique_ptr reader(mapnik::get_image_reader(should_throw,*type)); - REQUIRE( false ); - } - catch (std::exception const&) - { - REQUIRE( true ); - } + REQUIRE_THROWS(std::unique_ptr reader(mapnik::get_image_reader(should_throw,*type))); #endif - try - { - mapnik::image_rgba8 im(-10,-10); // should throw rather than overflow - REQUIRE( im.width() < 10 ); // should not get here, but if we did this test should fail - } - catch (std::exception const& ex) - { - REQUIRE( true ); // should hit bad alloc here - } + REQUIRE_THROWS(mapnik::image_rgba8 im(-10,-10)); // should throw rather than overflow #if defined(HAVE_CAIRO) mapnik::cairo_surface_ptr image_surface( @@ -63,29 +47,13 @@ SECTION("readers") { REQUIRE( mapnik::util::exists( should_throw ) ); type = mapnik::type_from_filename(should_throw); REQUIRE( type ); - try - { - std::unique_ptr reader(mapnik::get_image_reader(should_throw,*type)); - REQUIRE( false ); - } - catch (std::exception const&) - { - REQUIRE( true ); - } + REQUIRE_THROWS(std::unique_ptr reader(mapnik::get_image_reader(should_throw,*type))); should_throw = "./test/data/images/xcode-CgBI.png"; REQUIRE( mapnik::util::exists( should_throw ) ); type = mapnik::type_from_filename(should_throw); REQUIRE( type ); - try - { - std::unique_ptr reader(mapnik::get_image_reader(should_throw,*type)); - REQUIRE( false ); - } - catch (std::exception const&) - { - REQUIRE( true ); - } + REQUIRE_THROWS(std::unique_ptr reader(mapnik::get_image_reader(should_throw,*type))); #endif #if defined(HAVE_TIFF) @@ -93,15 +61,7 @@ SECTION("readers") { REQUIRE( mapnik::util::exists( should_throw ) ); type = mapnik::type_from_filename(should_throw); REQUIRE( type ); - try - { - std::unique_ptr reader(mapnik::get_image_reader(should_throw,*type)); - REQUIRE( false ); - } - catch (std::exception const&) - { - REQUIRE( true ); - } + REQUIRE_THROWS(std::unique_ptr reader(mapnik::get_image_reader(should_throw,*type))); #endif #if defined(HAVE_WEBP) @@ -109,15 +69,7 @@ SECTION("readers") { REQUIRE( mapnik::util::exists( should_throw ) ); type = mapnik::type_from_filename(should_throw); REQUIRE( type ); - try - { - std::unique_ptr reader(mapnik::get_image_reader(should_throw,*type)); - REQUIRE( false ); - } - catch (std::exception const&) - { - REQUIRE( true ); - } + REQUIRE_THROWS(std::unique_ptr reader(mapnik::get_image_reader(should_throw,*type))); #endif } catch (std::exception const & ex) @@ -127,4 +79,4 @@ SECTION("readers") { } } -} \ No newline at end of file +}