diff --git a/tests/cpp_tests/agg_blend_src_over_test.cpp b/tests/cpp_tests/agg_blend_src_over_test.cpp index 8f0427bb9..7fbcb18a6 100644 --- a/tests/cpp_tests/agg_blend_src_over_test.cpp +++ b/tests/cpp_tests/agg_blend_src_over_test.cpp @@ -4,6 +4,8 @@ #include #include #include +#include +#include #include "agg_color_rgba.h" #include "agg_pixfmt_rgba.h" #include "agg_rendering_buffer.h" @@ -130,8 +132,15 @@ template struct comp_op_rgba_src_over2 } -int main( int, char*[] ) +int main(int argc, char** argv) { + std::vector args; + for (int i=1;i source_over_old_agg; typedef agg::comp_op_rgba_src_over source_over; @@ -194,7 +203,8 @@ int main( int, char*[] ) */ if (!::boost::detail::test_errors()) { - std::clog << "C++ AGG blending: \x1b[1;32m✓ \x1b[0m\n"; + if (quiet) std::clog << "\x1b[1;32m.\x1b[0m"; + else std::clog << "C++ AGG blending: \x1b[1;32m✓ \x1b[0m\n"; #if BOOST_VERSION >= 104600 ::boost::detail::report_errors_remind().called_report_errors_function = true; #endif diff --git a/tests/cpp_tests/build.py b/tests/cpp_tests/build.py index dd244b19d..fe199e99b 100644 --- a/tests/cpp_tests/build.py +++ b/tests/cpp_tests/build.py @@ -6,38 +6,40 @@ Import ('env') test_env = env.Clone() -test_env['LIBS'] = copy(env['LIBMAPNIK_LIBS']) -test_env.AppendUnique(LIBS='mapnik') -test_env.AppendUnique(LIBS='sqlite3') -test_env.AppendUnique(CXXFLAGS='-g') - -test_env['CXXFLAGS'] = copy(test_env['LIBMAPNIK_CXXFLAGS']) - -if test_env['HAS_CAIRO']: - test_env.PrependUnique(CPPPATH=test_env['CAIRO_CPPPATHS']) - test_env.Append(CPPDEFINES = '-DHAVE_CAIRO') - -for cpp_test in glob.glob('*_test.cpp'): - name = cpp_test.replace('.cpp','-bin') - source_files = [cpp_test] - test_program = None - if 'agg_blend_src_over_test' in cpp_test: - # customization here for faster compile - agg_env = Environment(ENV=os.environ) - agg_env['CXX'] = env['CXX'] - agg_env['CXXFLAGS'] = env['CXXFLAGS'] - if 'agg' in test_env['LIBS']: - agg_env.AppendUnique(LIBS='agg') - agg_env.Append(CPPPATH = '#deps/agg/include') - agg_env.Append(LIBPATH = '#deps/agg') - agg_env['CPPPATH'] = ['#deps/agg/include',env['BOOST_INCLUDES']] - test_program = agg_env.Program(name, source=source_files, LINKFLAGS=env['CUSTOM_LDFLAGS']) - else: - test_env_local = test_env.Clone() - if 'csv_parse' in cpp_test: - source_files += glob.glob('../../plugins/input/csv/' + '*.cpp') - test_program = test_env_local.Program(name, source=source_files, LINKFLAGS=env['CUSTOM_LDFLAGS']) - Depends(test_program, env.subst('../../src/%s' % env['MAPNIK_LIB_NAME'])) - # build locally if installing - if 'install' in COMMAND_LINE_TARGETS: - env.Alias('install',test_program) +if not env['CPP_TESTS']: + for cpp_test_bin in glob.glob('*-bin'): + os.unlink(cpp_test_bin) +else: + test_env['LIBS'] = copy(env['LIBMAPNIK_LIBS']) + test_env.AppendUnique(LIBS='mapnik') + test_env.AppendUnique(CXXFLAGS='-g') + test_env['CXXFLAGS'] = copy(test_env['LIBMAPNIK_CXXFLAGS']) + if test_env['HAS_CAIRO']: + test_env.PrependUnique(CPPPATH=test_env['CAIRO_CPPPATHS']) + test_env.Append(CPPDEFINES = '-DHAVE_CAIRO') + for cpp_test in glob.glob('*_test.cpp'): + name = cpp_test.replace('.cpp','-bin') + source_files = [cpp_test] + test_program = None + # enable for faster compile while developing just this test + #if 'agg_blend_src_over_test' in cpp_test: + if False: + # customization here for faster compile + agg_env = Environment(ENV=os.environ) + agg_env['CXX'] = env['CXX'] + agg_env['CXXFLAGS'] = env['CXXFLAGS'] + if 'agg' in test_env['LIBS']: + agg_env.AppendUnique(LIBS='agg') + agg_env.Append(CPPPATH = '#deps/agg/include') + agg_env.Append(LIBPATH = '#deps/agg') + agg_env['CPPPATH'] = ['#deps/agg/include',env['BOOST_INCLUDES']] + test_program = agg_env.Program(name, source=source_files, LINKFLAGS=env['CUSTOM_LDFLAGS']) + else: + test_env_local = test_env.Clone() + if 'csv_parse' in cpp_test: + source_files += glob.glob('../../plugins/input/csv/' + '*.cpp') + test_program = test_env_local.Program(name, source=source_files, LINKFLAGS=env['CUSTOM_LDFLAGS']) + Depends(test_program, env.subst('../../src/%s' % env['MAPNIK_LIB_NAME'])) + # build locally if installing + if 'install' in COMMAND_LINE_TARGETS: + env.Alias('install',test_program) diff --git a/tests/cpp_tests/clipping_test.cpp b/tests/cpp_tests/clipping_test.cpp index 457cacfec..6e6c6ca6e 100644 --- a/tests/cpp_tests/clipping_test.cpp +++ b/tests/cpp_tests/clipping_test.cpp @@ -9,10 +9,11 @@ #include // stl -#include +#include #include #include #include +#include // agg #include "agg_conv_clip_polygon.h" @@ -20,6 +21,7 @@ //#include "agg_path_storage.h" //#include "agg_conv_clipper.h" +#include "utils.hpp" template std::string dump_path(T & path) @@ -76,9 +78,19 @@ void parse_geom(mapnik::geometry_type & geom, } } -int main( int, char*[] ) +int main(int argc, char** argv) { + std::vector args; + for (int i=1;i= 104600 ::boost::detail::report_errors_remind().called_report_errors_function = true; #endif diff --git a/tests/cpp_tests/conversions_test.cpp b/tests/cpp_tests/conversions_test.cpp index 9144a7bb9..687f2ba4a 100644 --- a/tests/cpp_tests/conversions_test.cpp +++ b/tests/cpp_tests/conversions_test.cpp @@ -3,9 +3,25 @@ #include #include #include +#include +#include -int main( int, char*[] ) +#if defined(_MSC_VER) +#include +#endif + +int main(int argc, char** argv) { + #if defined(_MSC_VER) + unsigned int old = _set_output_format(_TWO_DIGIT_EXPONENT); + #endif + std::vector args; + for (int i=1;i= 104600 ::boost::detail::report_errors_remind().called_report_errors_function = true; #endif diff --git a/tests/cpp_tests/csv_parse_test.cpp b/tests/cpp_tests/csv_parse_test.cpp deleted file mode 100644 index edd0835d9..000000000 --- a/tests/cpp_tests/csv_parse_test.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include -#include -#include "plugins/input/csv/csv_datasource.hpp" -#include - - -int main( int, char*[] ) -{ - // test of directly instanciating a datasource - try { - mapnik::parameters params; - params["type"]="csv"; - params["file"]="./tests/data/csv/wkt.csv"; - csv_datasource ds(params); - BOOST_TEST(true); - } catch (std::exception const& ex) { - BOOST_TEST(false); - std::clog << "threw: " << ex.what() << "\n"; - } - - if (!::boost::detail::test_errors()) { - std::clog << "C++ CSV parse: \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(); - } -} diff --git a/tests/cpp_tests/data/cases.txt b/tests/cpp_tests/data/cases.txt index d161516d2..6ba17a96d 100644 --- a/tests/cpp_tests/data/cases.txt +++ b/tests/cpp_tests/data/cases.txt @@ -3,5 +3,7 @@ # SEG_END=0 SEG_MOVETO = 1 SEG_LINETO = 2 SEG_CLOSE = (0x40 | 0x0f) 50,50,150,150;0 0 1,200 200 2;50 50 1,150 150 2 50,50,150,150;50 50 1,150 50 2,150 150 2,50 150 2,50 50 2;50 50 1,150 50 2,150 150 2,50 150 2,50 50 2 +# points are dropped by line clipper +50,50,150,150;75 75 1; # TODO - should the close path be kept after clipping? # 50,50,150,150;50 50 1,150 50 2,150 150 2,50 150 2,50 50 2,0 0 79;50 50 1,150 50 2,150 150 2,50 150 2,50 50 2 diff --git a/tests/cpp_tests/exceptions_test.cpp b/tests/cpp_tests/exceptions_test.cpp index 2841a43ee..9205a93ae 100644 --- a/tests/cpp_tests/exceptions_test.cpp +++ b/tests/cpp_tests/exceptions_test.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include #include @@ -19,14 +18,23 @@ #include #include #include +#include +#include +#include -extern "C" { -#include -} +#include "utils.hpp" -int main( int, char*[] ) +int main(int argc, char** argv) { + std::vector args; + for (int i=1;i= 104600 ::boost::detail::report_errors_remind().called_report_errors_function = true; #endif diff --git a/tests/cpp_tests/font_registration_test.cpp b/tests/cpp_tests/font_registration_test.cpp index 41908c21d..93a9d5854 100644 --- a/tests/cpp_tests/font_registration_test.cpp +++ b/tests/cpp_tests/font_registration_test.cpp @@ -1,21 +1,36 @@ -#include -#include -namespace fs = boost::filesystem; -using fs::path; -namespace sys = boost::system; - -#include -#include #include +#include +#include -int main( int, char*[] ) +#include +#include + +#include +#include +#include + +#include "utils.hpp" + +int main(int argc, char** argv) { + std::vector args; + for (int i=1;i face_names; @@ -80,7 +95,8 @@ int main( int, char*[] ) } if (!::boost::detail::test_errors()) { - std::clog << "C++ fonts registration: \x1b[1;32m✓ \x1b[0m\n"; + if (quiet) std::clog << "\x1b[1;32m.\x1b[0m"; + else std::clog << "C++ fonts registration: \x1b[1;32m✓ \x1b[0m\n"; #if BOOST_VERSION >= 104600 ::boost::detail::report_errors_remind().called_report_errors_function = true; #endif diff --git a/tests/cpp_tests/fontset_runtime_test.cpp b/tests/cpp_tests/fontset_runtime_test.cpp index ca587620e..f6e351f93 100644 --- a/tests/cpp_tests/fontset_runtime_test.cpp +++ b/tests/cpp_tests/fontset_runtime_test.cpp @@ -17,51 +17,63 @@ #include #include #include +#include +#include +#include "utils.hpp" -int main( int, char*[] ) +int main(int argc, char** argv) { - // create a renderable map with a fontset and a text symbolizer - // and do not register any fonts, to ensure the error thrown is reasonable - mapnik::context_ptr ctx = boost::make_shared(); - ctx->push("name"); - mapnik::feature_ptr feature(mapnik::feature_factory::create(ctx,1)); - mapnik::transcoder tr("utf-8"); - UnicodeString ustr = tr.transcode("hello world!"); - feature->put("name",ustr); - mapnik::geometry_type * pt = new mapnik::geometry_type(mapnik::Point); - pt->move_to(128,128); - feature->add_geometry(pt); - mapnik::datasource_ptr memory_ds = boost::make_shared(); - mapnik::memory_datasource *cache = dynamic_cast(memory_ds.get()); - cache->push(feature); - mapnik::Map m(256,256); - mapnik::font_set fontset("fontset"); - // NOTE: this is a valid font, but will fail because none are registered - fontset.add_face_name("DejaVu Sans Book"); - m.insert_fontset("fontset", fontset); - mapnik::layer lyr("layer"); - lyr.set_datasource(memory_ds); - lyr.add_style("style"); - m.addLayer(lyr); - mapnik::feature_type_style the_style; - mapnik::rule the_rule; - mapnik::text_symbolizer text_sym(mapnik::parse_expression("[name]"),10,mapnik::color(0,0,0)); - text_sym.set_fontset(fontset); - the_rule.append(text_sym); - the_style.add_rule(the_rule); - m.insert_style("style",the_style ); - m.zoom_to_box(mapnik::box2d(-256,-256, - 256,256)); - mapnik::image_32 buf(m.width(),m.height()); - mapnik::agg_renderer ren(m,buf); + std::vector args; + for (int i=1;i(); + ctx->push("name"); + mapnik::feature_ptr feature(mapnik::feature_factory::create(ctx,1)); + mapnik::transcoder tr("utf-8"); + UnicodeString ustr = tr.transcode("hello world!"); + feature->put("name",ustr); + mapnik::geometry_type * pt = new mapnik::geometry_type(mapnik::Point); + pt->move_to(128,128); + feature->add_geometry(pt); + boost::shared_ptr ds = boost::make_shared(); + ds->push(feature); + mapnik::Map m(256,256); + mapnik::font_set fontset("fontset"); + // NOTE: this is a valid font, but will fail because none are registered + fontset.add_face_name("DejaVu Sans Book"); + m.insert_fontset("fontset", fontset); + mapnik::layer lyr("layer"); + lyr.set_datasource(ds); + lyr.add_style("style"); + m.addLayer(lyr); + mapnik::feature_type_style the_style; + mapnik::rule the_rule; + mapnik::text_symbolizer text_sym(mapnik::parse_expression("[name]"),10,mapnik::color(0,0,0)); + text_sym.set_fontset(fontset); + the_rule.append(text_sym); + the_style.add_rule(the_rule); + m.insert_style("style",the_style ); + m.zoom_to_box(mapnik::box2d(-256,-256, + 256,256)); + mapnik::image_32 buf(m.width(),m.height()); + mapnik::agg_renderer ren(m,buf); ren.apply(); } catch (std::exception const& ex) { BOOST_TEST_EQ(std::string(ex.what()),std::string("No valid font face could be loaded for font set: 'fontset'")); } if (!::boost::detail::test_errors()) { - std::clog << "C++ fontset runtime: \x1b[1;32m✓ \x1b[0m\n"; + if (quiet) std::clog << "\x1b[1;32m.\x1b[0m"; + else std::clog << "C++ fontset runtime: \x1b[1;32m✓ \x1b[0m\n"; #if BOOST_VERSION >= 104600 ::boost::detail::report_errors_remind().called_report_errors_function = true; #endif diff --git a/tests/cpp_tests/geometry_converters_test.cpp b/tests/cpp_tests/geometry_converters_test.cpp index fbf60a5c0..2444371cd 100644 --- a/tests/cpp_tests/geometry_converters_test.cpp +++ b/tests/cpp_tests/geometry_converters_test.cpp @@ -1,5 +1,11 @@ #include +#include +#include +#include +#include +#include "utils.hpp" +#if BOOST_VERSION >= 104700 #include #include #include @@ -8,15 +14,12 @@ #include #include #include - -#if BOOST_VERSION >= 104700 #include #include #include -#endif -#include -#include +// stl +#include struct output_geometry_backend { @@ -121,9 +124,21 @@ boost::optional polygon_bbox_clipping(mapnik::box2d bbox, return boost::optional(); } +#endif -int main( int, char*[] ) +int main(int argc, char** argv) { + std::vector args; + for (int i=1;i= 104700 + // LineString/bbox clipping { std::string wkt_in("LineString(0 0,200 200)"); @@ -161,9 +176,13 @@ int main( int, char*[] ) BOOST_TEST_EQ(*result,std::string("Polygon((50 50,50 100,75 150,125 150,150 100,150 50,50 50))")); } #endif + +#endif + if (!::boost::detail::test_errors()) { - std::clog << "C++ geometry conversions: \x1b[1;32m✓ \x1b[0m\n"; + if (quiet) std::clog << "\x1b[1;32m.\x1b[0m"; + else std::clog << "C++ geometry conversions: \x1b[1;32m✓ \x1b[0m\n"; #if BOOST_VERSION >= 104600 ::boost::detail::report_errors_remind().called_report_errors_function = true; #endif diff --git a/tests/cpp_tests/image_io_test.cpp b/tests/cpp_tests/image_io_test.cpp index f42718d85..06c229bbf 100644 --- a/tests/cpp_tests/image_io_test.cpp +++ b/tests/cpp_tests/image_io_test.cpp @@ -1,62 +1,86 @@ #include -#include -namespace fs = boost::filesystem; -using fs::path; -namespace sys = boost::system; #include #include #include #include +#include +#include +#include +#include "utils.hpp" -int main( int, char*[] ) +int main(int argc, char** argv) { - std::string blank; + std::vector args; + for (int i=1;i type; try { - blank = "./tests/cpp_tests/data/blank.jpg"; - BOOST_TEST( fs::exists( blank ) ); - type = mapnik::type_from_filename(blank); + BOOST_TEST(set_working_dir(args)); + + 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::auto_ptr reader(mapnik::get_image_reader(blank,*type)); - BOOST_TEST( false ); + std::auto_ptr reader(mapnik::get_image_reader(should_throw,*type)); + if (reader.get()) BOOST_TEST( false ); } catch (std::exception const&) { BOOST_TEST( true ); } - blank = "./tests/cpp_tests/data/blank.png"; - BOOST_TEST( fs::exists( blank ) ); - type = mapnik::type_from_filename(blank); + 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::auto_ptr reader(mapnik::get_image_reader(blank,*type)); - BOOST_TEST( false ); + std::auto_ptr reader(mapnik::get_image_reader(should_throw,*type)); + if (reader.get()) BOOST_TEST( false ); } catch (std::exception const&) { BOOST_TEST( true ); } - blank = "./tests/cpp_tests/data/blank.tiff"; - BOOST_TEST( fs::exists( blank ) ); - type = mapnik::type_from_filename(blank); + 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::auto_ptr reader(mapnik::get_image_reader(blank,*type)); - BOOST_TEST( false ); + std::auto_ptr reader(mapnik::get_image_reader(should_throw,*type)); + if (reader.get()) 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 reader(mapnik::get_image_reader(should_throw,*type)); + if (reader.get()) BOOST_TEST( false ); + } + catch (std::exception const&) + { + BOOST_TEST( true ); + } + } catch (std::exception const & ex) { @@ -65,7 +89,8 @@ int main( int, char*[] ) } if (!::boost::detail::test_errors()) { - std::clog << "C++ image i/o: \x1b[1;32m✓ \x1b[0m\n"; + 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 diff --git a/tests/cpp_tests/label_algo_test.cpp b/tests/cpp_tests/label_algo_test.cpp index e2d36328b..d997d19b9 100644 --- a/tests/cpp_tests/label_algo_test.cpp +++ b/tests/cpp_tests/label_algo_test.cpp @@ -3,10 +3,18 @@ #include #include #include +#include +#include - -int main( int, char*[] ) +int main(int argc, char** argv) { + std::vector args; + for (int i=1;i= 104600 ::boost::detail::report_errors_remind().called_report_errors_function = true; #endif diff --git a/tests/cpp_tests/map_request_test.cpp b/tests/cpp_tests/map_request_test.cpp index d14474750..fabfd34ab 100644 --- a/tests/cpp_tests/map_request_test.cpp +++ b/tests/cpp_tests/map_request_test.cpp @@ -18,6 +18,10 @@ #include #include #include +#include +#include + +#include "utils.hpp" bool compare_images(std::string const& src_fn,std::string const& dest_fn) { @@ -56,11 +60,23 @@ bool compare_images(std::string const& src_fn,std::string const& dest_fn) return true; } -int main( int, char*[] ) +int main(int argc, char** argv) { + std::vector args; + for (int i=1;i= 104600 ::boost::detail::report_errors_remind().called_report_errors_function = true; #endif diff --git a/tests/cpp_tests/params_test.cpp b/tests/cpp_tests/params_test.cpp index fe2e717dd..a02e546e9 100644 --- a/tests/cpp_tests/params_test.cpp +++ b/tests/cpp_tests/params_test.cpp @@ -4,11 +4,18 @@ #include #include #include - +#include +#include #include -int main( int, char*[] ) +int main(int argc, char** argv) { + std::vector args; + for (int i=1;i("null")/* && *params.get("null") == mapnik::value_null()*/) ); if (!::boost::detail::test_errors()) { - std::clog << "C++ parameters: \x1b[1;32m✓ \x1b[0m\n"; + if (quiet) std::clog << "\x1b[1;32m.\x1b[0m"; + else std::clog << "C++ parameters: \x1b[1;32m✓ \x1b[0m\n"; #if BOOST_VERSION >= 104600 ::boost::detail::report_errors_remind().called_report_errors_function = true; #endif diff --git a/tests/cpp_tests/support/map-request-marker-text-line-expected-cairo.png b/tests/cpp_tests/support/map-request-marker-text-line-expected-cairo.png index b09606829..cb8e47826 100644 Binary files a/tests/cpp_tests/support/map-request-marker-text-line-expected-cairo.png and b/tests/cpp_tests/support/map-request-marker-text-line-expected-cairo.png differ diff --git a/tests/cpp_tests/support/map-request-marker-text-line-expected.png b/tests/cpp_tests/support/map-request-marker-text-line-expected.png index 2a7be3ddc..9de752a29 100644 Binary files a/tests/cpp_tests/support/map-request-marker-text-line-expected.png and b/tests/cpp_tests/support/map-request-marker-text-line-expected.png differ