4f4e2b001e
Conflicts: SConstruct benchmark/run.cpp bindings/python/mapnik_datasource.cpp bindings/python/mapnik_feature.cpp bindings/python/python_optional.hpp include/mapnik/css_color_grammar.hpp include/mapnik/expression_grammar.hpp include/mapnik/feature.hpp include/mapnik/feature_style_processor_impl.hpp include/mapnik/image_filter_types.hpp include/mapnik/image_util.hpp include/mapnik/json/geometry_generator_grammar.hpp include/mapnik/json/geometry_grammar.hpp include/mapnik/processed_text.hpp include/mapnik/tiff_io.hpp include/mapnik/util/geometry_svg_generator.hpp include/mapnik/util/geometry_wkt_generator.hpp include/mapnik/utils.hpp include/mapnik/webp_io.hpp include/mapnik/wkt/wkt_grammar.hpp plugins/input/shape/shape_datasource.cpp plugins/input/shape/shapefile.hpp src/expression_grammar.cpp src/expression_string.cpp src/image_util.cpp src/json/feature_collection_parser.cpp src/json/feature_parser.cpp src/miniz.c src/symbolizer_helpers.cpp src/tiff_reader.cpp src/webp_reader.cpp tests/cpp_tests/geometry_converters_test.cpp tests/cpp_tests/image_io_test.cpp tests/cpp_tests/map_request_test.cpp tests/python_tests/image_test.py tests/visual_tests/test.py
134 lines
3.9 KiB
C++
134 lines
3.9 KiB
C++
#include <boost/version.hpp>
|
|
|
|
#include <boost/detail/lightweight_test.hpp>
|
|
#include <iostream>
|
|
#include <mapnik/image_reader.hpp>
|
|
#include <mapnik/image_util.hpp>
|
|
#include <mapnik/util/fs.hpp>
|
|
#include <vector>
|
|
#include <algorithm>
|
|
|
|
#include "utils.hpp"
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
std::vector<std::string> args;
|
|
for (int i=1;i<argc;++i)
|
|
{
|
|
args.push_back(argv[i]);
|
|
}
|
|
bool quiet = std::find(args.begin(), args.end(), "-q")!=args.end();
|
|
|
|
std::string should_throw;
|
|
boost::optional<std::string> type;
|
|
try
|
|
{
|
|
BOOST_TEST(set_working_dir(args));
|
|
|
|
#if defined(HAVE_JPEG)
|
|
should_throw = "./tests/cpp_tests/data/blank.jpg";
|
|
BOOST_TEST( mapnik::util::exists( should_throw ) );
|
|
type = mapnik::type_from_filename(should_throw);
|
|
BOOST_TEST( type );
|
|
try
|
|
{
|
|
std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type));
|
|
BOOST_TEST( false );
|
|
}
|
|
catch (std::exception const&)
|
|
{
|
|
BOOST_TEST( true );
|
|
}
|
|
#endif
|
|
|
|
#if defined(HAVE_PNG)
|
|
should_throw = "./tests/cpp_tests/data/blank.png";
|
|
BOOST_TEST( mapnik::util::exists( should_throw ) );
|
|
type = mapnik::type_from_filename(should_throw);
|
|
BOOST_TEST( type );
|
|
try
|
|
{
|
|
std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type));
|
|
BOOST_TEST( false );
|
|
}
|
|
catch (std::exception const&)
|
|
{
|
|
BOOST_TEST( true );
|
|
}
|
|
|
|
should_throw = "./tests/cpp_tests/data/blank.webp";
|
|
BOOST_TEST( mapnik::util::exists( should_throw ) );
|
|
type = mapnik::type_from_filename(should_throw);
|
|
BOOST_TEST( type );
|
|
try
|
|
{
|
|
std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type));
|
|
BOOST_TEST( false );
|
|
}
|
|
catch (std::exception const&)
|
|
{
|
|
BOOST_TEST( true );
|
|
}
|
|
should_throw = "./tests/data/images/xcode-CgBI.png";
|
|
BOOST_TEST( mapnik::util::exists( should_throw ) );
|
|
type = mapnik::type_from_filename(should_throw);
|
|
BOOST_TEST( type );
|
|
try
|
|
{
|
|
std::auto_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type));
|
|
if (reader.get()) BOOST_TEST( false );
|
|
}
|
|
catch (std::exception const&)
|
|
{
|
|
BOOST_TEST( true );
|
|
}
|
|
#endif
|
|
|
|
#if defined(HAVE_TIFF)
|
|
should_throw = "./tests/cpp_tests/data/blank.tiff";
|
|
BOOST_TEST( mapnik::util::exists( should_throw ) );
|
|
type = mapnik::type_from_filename(should_throw);
|
|
BOOST_TEST( type );
|
|
try
|
|
{
|
|
std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type));
|
|
BOOST_TEST( false );
|
|
}
|
|
catch (std::exception const&)
|
|
{
|
|
BOOST_TEST( true );
|
|
}
|
|
#endif
|
|
|
|
#if defined(HAVE_WEBP)
|
|
should_throw = "./tests/cpp_tests/data/blank.webp";
|
|
BOOST_TEST( mapnik::util::exists( should_throw ) );
|
|
type = mapnik::type_from_filename(should_throw);
|
|
BOOST_TEST( type );
|
|
try
|
|
{
|
|
std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type));
|
|
BOOST_TEST( false );
|
|
}
|
|
catch (std::exception const&)
|
|
{
|
|
BOOST_TEST( true );
|
|
}
|
|
#endif
|
|
}
|
|
catch (std::exception const & ex)
|
|
{
|
|
std::clog << "C++ image i/o problem: " << ex.what() << "\n";
|
|
BOOST_TEST(false);
|
|
}
|
|
|
|
if (!::boost::detail::test_errors()) {
|
|
if (quiet) std::clog << "\x1b[1;32m.\x1b[0m";
|
|
else std::clog << "C++ image i/o: \x1b[1;32m✓ \x1b[0m\n";
|
|
#if BOOST_VERSION >= 104600
|
|
::boost::detail::report_errors_remind().called_report_errors_function = true;
|
|
#endif
|
|
} else {
|
|
return ::boost::report_errors();
|
|
}
|
|
}
|