Updated tests so that they use REQUIRE_THROWS

This commit is contained in:
Blake Thompson 2015-05-11 15:51:39 -05:00
parent 5220afb9f2
commit ba0cc39046

View file

@ -25,26 +25,10 @@ SECTION("readers") {
REQUIRE( mapnik::util::exists( should_throw ) ); REQUIRE( mapnik::util::exists( should_throw ) );
type = mapnik::type_from_filename(should_throw); type = mapnik::type_from_filename(should_throw);
REQUIRE( type ); REQUIRE( type );
try REQUIRE_THROWS(std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type)));
{
std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type));
REQUIRE( false );
}
catch (std::exception const&)
{
REQUIRE( true );
}
#endif #endif
try REQUIRE_THROWS(mapnik::image_rgba8 im(-10,-10)); // should throw rather than overflow
{
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
}
#if defined(HAVE_CAIRO) #if defined(HAVE_CAIRO)
mapnik::cairo_surface_ptr image_surface( mapnik::cairo_surface_ptr image_surface(
@ -63,29 +47,13 @@ SECTION("readers") {
REQUIRE( mapnik::util::exists( should_throw ) ); REQUIRE( mapnik::util::exists( should_throw ) );
type = mapnik::type_from_filename(should_throw); type = mapnik::type_from_filename(should_throw);
REQUIRE( type ); REQUIRE( type );
try REQUIRE_THROWS(std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type)));
{
std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type));
REQUIRE( false );
}
catch (std::exception const&)
{
REQUIRE( true );
}
should_throw = "./test/data/images/xcode-CgBI.png"; should_throw = "./test/data/images/xcode-CgBI.png";
REQUIRE( mapnik::util::exists( should_throw ) ); REQUIRE( mapnik::util::exists( should_throw ) );
type = mapnik::type_from_filename(should_throw); type = mapnik::type_from_filename(should_throw);
REQUIRE( type ); REQUIRE( type );
try REQUIRE_THROWS(std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type)));
{
std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type));
REQUIRE( false );
}
catch (std::exception const&)
{
REQUIRE( true );
}
#endif #endif
#if defined(HAVE_TIFF) #if defined(HAVE_TIFF)
@ -93,15 +61,7 @@ SECTION("readers") {
REQUIRE( mapnik::util::exists( should_throw ) ); REQUIRE( mapnik::util::exists( should_throw ) );
type = mapnik::type_from_filename(should_throw); type = mapnik::type_from_filename(should_throw);
REQUIRE( type ); REQUIRE( type );
try REQUIRE_THROWS(std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type)));
{
std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type));
REQUIRE( false );
}
catch (std::exception const&)
{
REQUIRE( true );
}
#endif #endif
#if defined(HAVE_WEBP) #if defined(HAVE_WEBP)
@ -109,15 +69,7 @@ SECTION("readers") {
REQUIRE( mapnik::util::exists( should_throw ) ); REQUIRE( mapnik::util::exists( should_throw ) );
type = mapnik::type_from_filename(should_throw); type = mapnik::type_from_filename(should_throw);
REQUIRE( type ); REQUIRE( type );
try REQUIRE_THROWS(std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type)));
{
std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type));
REQUIRE( false );
}
catch (std::exception const&)
{
REQUIRE( true );
}
#endif #endif
} }
catch (std::exception const & ex) catch (std::exception const & ex)