Update catch.hpp to v2.13.1 + fix tests

This commit is contained in:
Artem Pavlenko 2020-09-10 15:34:52 +01:00
parent ea7003628f
commit d6d69df498
5 changed files with 9874 additions and 8073 deletions

File diff suppressed because it is too large Load diff

View file

@ -67,6 +67,16 @@ std::pair<mapnik::datasource_ptr,mapnik::feature_ptr> fetch_first_feature(std::s
return std::make_pair(ds,feature);
}
void iterate_over_features(mapnik::featureset_ptr features)
{
auto feature = features->next();
while (feature != nullptr)
{
feature = features->next();
}
}
}
TEST_CASE("geojson") {
@ -673,12 +683,7 @@ TEST_CASE("geojson") {
auto fields = ds->get_descriptor().get_descriptors();
mapnik::query query(ds->envelope());
auto features = ds->features(query);
REQUIRE_THROWS(
auto feature = features->next();
while (feature != nullptr)
{
feature = features->next();
});
REQUIRE_THROWS(iterate_over_features(features));
}
// cleanup

View file

@ -19,16 +19,14 @@ SECTION("test bad filter input") {
mapnik::fill(im,mapnik::color("blue"));
mapnik::set_pixel(im, 1, 1, mapnik::color("red"));
REQUIRE_THROWS( mapnik::filter::filter_image(im, "foo,asdfasdf()"); );
REQUIRE_THROWS( mapnik::filter::filter_image(im, "colorize-alpha("); );
REQUIRE_THROWS( mapnik::filter::filter_image(im, "color-to-alpha(blue"); );
REQUIRE_THROWS( mapnik::filter::filter_image(im, "color-to-alpha(,blue)"); );
REQUIRE_THROWS( mapnik::filter::filter_image(im, "colorize-alpha()"); );
REQUIRE_THROWS( mapnik::filter::filter_image(im, "foo,asdfasdf()"));
REQUIRE_THROWS( mapnik::filter::filter_image(im, "colorize-alpha("));
REQUIRE_THROWS( mapnik::filter::filter_image(im, "color-to-alpha(blue"));
REQUIRE_THROWS( mapnik::filter::filter_image(im, "color-to-alpha(,blue)"));
REQUIRE_THROWS( mapnik::filter::filter_image(im, "colorize-alpha()"));
REQUIRE_THROWS(
mapnik::image_rgba8 const& im2 = im;
mapnik::image_rgba8 new_im = mapnik::filter::filter_image(im2, "foo");
);
REQUIRE_THROWS(mapnik::filter::filter_image(im2, "foo"));
CHECK(im(0,0) == 0xffff0000);
CHECK(im(0,1) == 0xffff0000);
@ -158,7 +156,7 @@ SECTION("test scale-hsla 2") {
// Should not throw on values out of [0, 1]
// https://github.com/mapnik/mapnik/issues/3052
REQUIRE_NOTHROW(mapnik::filter::filter_image(im, "scale-hsla(0.0,1.5,-1.0,1.0,-1.0,2.0,1.0,1.0)"););
REQUIRE_NOTHROW(mapnik::filter::filter_image(im, "scale-hsla(0.0,1.5,-1.0,1.0,-1.0,2.0,1.0,1.0)"));
CHECK(im(0,0) == 0xff0000ff);
CHECK(im(0,1) == 0xffefeff4);

View file

@ -16,6 +16,7 @@
#include <mapnik/warning_ignore.hpp>
#include <boost/format.hpp>
#include <boost/filesystem/convenience.hpp>
#include <boost/optional/optional_io.hpp>
#pragma GCC diagnostic pop
inline void make_directory(std::string const& dir) {
@ -65,7 +66,7 @@ SECTION("readers") {
REQUIRE( mapnik::util::exists( should_throw ) );
type = mapnik::type_from_filename(should_throw);
REQUIRE( type );
REQUIRE_THROWS(std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type)));
REQUIRE_THROWS(mapnik::get_image_reader(should_throw,*type));
// actually a png so jpeg reader should throw
should_throw = "./test/data/images/landusepattern.jpg";
@ -84,7 +85,7 @@ SECTION("readers") {
#endif
REQUIRE_THROWS(mapnik::image_rgba8 im(-10,-10)); // should throw rather than overflow
REQUIRE_THROWS(mapnik::image_rgba8(-10,-10)); // should throw rather than overflow
#if defined(HAVE_CAIRO)
mapnik::cairo_surface_ptr image_surface(
@ -103,13 +104,13 @@ SECTION("readers") {
REQUIRE( mapnik::util::exists( should_throw ) );
type = mapnik::type_from_filename(should_throw);
REQUIRE( type );
REQUIRE_THROWS(std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type)));
REQUIRE_THROWS(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 );
REQUIRE_THROWS(std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type)));
REQUIRE_THROWS(mapnik::get_image_reader(should_throw,*type));
#endif
#if defined(HAVE_TIFF)
@ -117,7 +118,7 @@ SECTION("readers") {
REQUIRE( mapnik::util::exists( should_throw ) );
type = mapnik::type_from_filename(should_throw);
REQUIRE( type );
REQUIRE_THROWS(std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type)));
REQUIRE_THROWS(mapnik::get_image_reader(should_throw,*type));
#endif
#if defined(HAVE_WEBP)
@ -125,7 +126,7 @@ SECTION("readers") {
REQUIRE( mapnik::util::exists( should_throw ) );
type = mapnik::type_from_filename(should_throw);
REQUIRE( type );
REQUIRE_THROWS(std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type)));
REQUIRE_THROWS(mapnik::get_image_reader(should_throw,*type));
#endif
}
catch (std::exception const & ex)

View file

@ -8,33 +8,22 @@
#include "cleanup.hpp" // run_cleanup()
std::string plugin_path;
inline void set_plugin_path(Catch::ConfigData&, std::string const& _plugin_path ) {
plugin_path = _plugin_path;
}
std::string working_dir;
inline void set_working_dir(Catch::ConfigData&, std::string const& _working_dir ) {
working_dir = _working_dir;
}
int main (int argc, char* const argv[])
int main (int argc, char** argv)
{
Catch::Session session;
std::string plugin_path;
std::string working_dir;
auto cli = session.cli()
|
Catch::clara::Opt(plugin_path, "plugins")
["-p"]["--plugins"] ("path to mapnik plugins")
|
Catch::clara::Opt(working_dir, "working directory")
["-C"]["--working-directory"] ("change working directory")
;
auto & cli = session.cli();
cli["-p"]["--plugins"]
.describe("path to mapnik plugins")
.bind(&set_plugin_path, "plugins");
cli["-C"]["--working-directory"]
.describe("change working directory")
.bind(&set_working_dir, "working directory");
session.cli(cli);
int result = session.applyCommandLine(argc, argv);
if (!plugin_path.empty())