From e986bce7f6a9b77072a7f3e312e4007793884f2d Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 16 Apr 2012 22:33:37 -0700 Subject: [PATCH] format c++ tests --- tests/cpp_tests/font_registration_test.cpp | 110 +++++++++--------- tests/cpp_tests/params_test.cpp | 98 ++++++++-------- .../background_color_test.cpp | 96 +++++++-------- .../svg_renderer_tests/combined_test.cpp | 28 ++--- .../svg_renderer_tests/file_output_test.cpp | 10 +- .../svg_renderer_tests/path_element_test.cpp | 104 ++++++++--------- .../svg_renderer_tests/root_element_test.cpp | 84 ++++++------- .../format_source_files.sh | 2 +- 8 files changed, 266 insertions(+), 266 deletions(-) diff --git a/tests/cpp_tests/font_registration_test.cpp b/tests/cpp_tests/font_registration_test.cpp index 1d200df86..57874272d 100644 --- a/tests/cpp_tests/font_registration_test.cpp +++ b/tests/cpp_tests/font_registration_test.cpp @@ -9,70 +9,70 @@ namespace sys = boost::system; int main( int, char*[] ) { - std::string fontdir("fonts/"); - - BOOST_TEST( fs::exists( fontdir ) ); - BOOST_TEST( fs::is_directory( fontdir ) ); + std::string fontdir("fonts/"); - std::vector face_names; + BOOST_TEST( fs::exists( fontdir ) ); + BOOST_TEST( fs::is_directory( fontdir ) ); - std::string foo("foo"); + std::vector face_names; - // fake directories - BOOST_TEST( !mapnik::freetype_engine::register_fonts(foo , true ) ); - face_names = mapnik::freetype_engine::face_names(); - BOOST_TEST( face_names.size() == 0 ); - BOOST_TEST( !mapnik::freetype_engine::register_fonts(foo) ); - face_names = mapnik::freetype_engine::face_names(); - BOOST_TEST( face_names.size() == 0 ); + std::string foo("foo"); - // directories without fonts - std::string src("src"); - // an empty directory will not return true - // we need to register at least one font and not fail on any - // to return true - BOOST_TEST( mapnik::freetype_engine::register_font(src) == false ); - BOOST_TEST( mapnik::freetype_engine::register_fonts(src, true) == false ); - BOOST_TEST( mapnik::freetype_engine::face_names().size() == 0 ); + // fake directories + BOOST_TEST( !mapnik::freetype_engine::register_fonts(foo , true ) ); + face_names = mapnik::freetype_engine::face_names(); + BOOST_TEST( face_names.size() == 0 ); + BOOST_TEST( !mapnik::freetype_engine::register_fonts(foo) ); + face_names = mapnik::freetype_engine::face_names(); + BOOST_TEST( face_names.size() == 0 ); - // bogus, emtpy file that looks like font - BOOST_TEST( mapnik::freetype_engine::register_font("tests/data/fonts/fake.ttf") == false ); - BOOST_TEST( mapnik::freetype_engine::register_fonts("tests/data/fonts/fake.ttf") == false ); - BOOST_TEST( mapnik::freetype_engine::face_names().size() == 0 ); + // directories without fonts + std::string src("src"); + // an empty directory will not return true + // we need to register at least one font and not fail on any + // to return true + BOOST_TEST( mapnik::freetype_engine::register_font(src) == false ); + BOOST_TEST( mapnik::freetype_engine::register_fonts(src, true) == false ); + BOOST_TEST( mapnik::freetype_engine::face_names().size() == 0 ); - BOOST_TEST( mapnik::freetype_engine::register_font("tests/data/fonts/intentionally-broken.ttf") == false ); - BOOST_TEST( mapnik::freetype_engine::register_fonts("tests/data/fonts/intentionally-broken.ttf") == false ); - BOOST_TEST( mapnik::freetype_engine::face_names().size() == 0 ); + // bogus, emtpy file that looks like font + BOOST_TEST( mapnik::freetype_engine::register_font("tests/data/fonts/fake.ttf") == false ); + BOOST_TEST( mapnik::freetype_engine::register_fonts("tests/data/fonts/fake.ttf") == false ); + BOOST_TEST( mapnik::freetype_engine::face_names().size() == 0 ); - // register unifont, since we know it sits in the root fonts/ dir - BOOST_TEST( mapnik::freetype_engine::register_fonts(fontdir) ); - face_names = mapnik::freetype_engine::face_names(); - //std::clog << "number of registered fonts: " << face_names.size() << std::endl; - BOOST_TEST( face_names.size() > 0 ); - BOOST_TEST( face_names.size() == 1 ); + BOOST_TEST( mapnik::freetype_engine::register_font("tests/data/fonts/intentionally-broken.ttf") == false ); + BOOST_TEST( mapnik::freetype_engine::register_fonts("tests/data/fonts/intentionally-broken.ttf") == false ); + BOOST_TEST( mapnik::freetype_engine::face_names().size() == 0 ); - // re-register unifont, should not have any affect - BOOST_TEST( mapnik::freetype_engine::register_fonts(fontdir, false) ); - face_names = mapnik::freetype_engine::face_names(); - //std::clog << "number of registered fonts: " << face_names.size() << std::endl; - BOOST_TEST( face_names.size() == 1 ); + // register unifont, since we know it sits in the root fonts/ dir + BOOST_TEST( mapnik::freetype_engine::register_fonts(fontdir) ); + face_names = mapnik::freetype_engine::face_names(); + //std::clog << "number of registered fonts: " << face_names.size() << std::endl; + BOOST_TEST( face_names.size() > 0 ); + BOOST_TEST( face_names.size() == 1 ); - // register a single dejavu font - std::string dejavu_bold_oblique("tests/data/fonts/DejaVuSansMono-BoldOblique.ttf"); - BOOST_TEST( mapnik::freetype_engine::register_font(dejavu_bold_oblique) ); - face_names = mapnik::freetype_engine::face_names(); - //std::clog << "number of registered fonts: " << face_names.size() << std::endl; - BOOST_TEST( face_names.size() == 2 ); + // re-register unifont, should not have any affect + BOOST_TEST( mapnik::freetype_engine::register_fonts(fontdir, false) ); + face_names = mapnik::freetype_engine::face_names(); + //std::clog << "number of registered fonts: " << face_names.size() << std::endl; + BOOST_TEST( face_names.size() == 1 ); - // recurse to find all dejavu fonts - BOOST_TEST( mapnik::freetype_engine::register_fonts(fontdir, true) ); - face_names = mapnik::freetype_engine::face_names(); - //std::clog << "number of registered fonts: " << face_names.size() << std::endl; - BOOST_TEST( face_names.size() == 22 ); + // register a single dejavu font + std::string dejavu_bold_oblique("tests/data/fonts/DejaVuSansMono-BoldOblique.ttf"); + BOOST_TEST( mapnik::freetype_engine::register_font(dejavu_bold_oblique) ); + face_names = mapnik::freetype_engine::face_names(); + //std::clog << "number of registered fonts: " << face_names.size() << std::endl; + BOOST_TEST( face_names.size() == 2 ); - if (!::boost::detail::test_errors()) { - std::clog << "C++ fonts registration: \x1b[1;32m✓ \x1b[0m\n"; - } else { - return ::boost::report_errors(); - } + // recurse to find all dejavu fonts + BOOST_TEST( mapnik::freetype_engine::register_fonts(fontdir, true) ); + face_names = mapnik::freetype_engine::face_names(); + //std::clog << "number of registered fonts: " << face_names.size() << std::endl; + BOOST_TEST( face_names.size() == 22 ); + + if (!::boost::detail::test_errors()) { + std::clog << "C++ fonts registration: \x1b[1;32m✓ \x1b[0m\n"; + } else { + return ::boost::report_errors(); + } } diff --git a/tests/cpp_tests/params_test.cpp b/tests/cpp_tests/params_test.cpp index baf430e19..42291d858 100644 --- a/tests/cpp_tests/params_test.cpp +++ b/tests/cpp_tests/params_test.cpp @@ -7,71 +7,71 @@ int main( int, char*[] ) { - mapnik::parameters params; - - // true - params["bool"] = true; - BOOST_TEST( (params.get("bool") && *params.get("bool") == true)); + mapnik::parameters params; - params["bool"] = "true"; - BOOST_TEST( (params.get("bool") && *params.get("bool") == true)); + // true + params["bool"] = true; + BOOST_TEST( (params.get("bool") && *params.get("bool") == true)); - params["bool"] = 1; - BOOST_TEST( (params.get("bool") && *params.get("bool") == true)); + params["bool"] = "true"; + BOOST_TEST( (params.get("bool") && *params.get("bool") == true)); - params["bool"] = "1"; - BOOST_TEST( (params.get("bool") && *params.get("bool") == true)); + params["bool"] = 1; + BOOST_TEST( (params.get("bool") && *params.get("bool") == true)); - params["bool"] = "True"; - BOOST_TEST( (params.get("bool") && *params.get("bool") == true)); + params["bool"] = "1"; + BOOST_TEST( (params.get("bool") && *params.get("bool") == true)); - params["bool"] = "on"; - BOOST_TEST( (params.get("bool") && *params.get("bool") == true)); + params["bool"] = "True"; + BOOST_TEST( (params.get("bool") && *params.get("bool") == true)); - params["bool"] = "yes"; - BOOST_TEST( (params.get("bool") && *params.get("bool") == true)); + params["bool"] = "on"; + BOOST_TEST( (params.get("bool") && *params.get("bool") == true)); - // false - params["bool"] = false; - BOOST_TEST( (params.get("bool") && *params.get("bool") == false) ); + params["bool"] = "yes"; + BOOST_TEST( (params.get("bool") && *params.get("bool") == true)); - params["bool"] = "false"; - BOOST_TEST( (params.get("bool") && *params.get("bool") == false) ); + // false + params["bool"] = false; + BOOST_TEST( (params.get("bool") && *params.get("bool") == false) ); - params["bool"] = 0; - BOOST_TEST( (params.get("bool") && *params.get("bool") == false)); + params["bool"] = "false"; + BOOST_TEST( (params.get("bool") && *params.get("bool") == false) ); - params["bool"] = "0"; - BOOST_TEST( (params.get("bool") && *params.get("bool") == false)); + params["bool"] = 0; + BOOST_TEST( (params.get("bool") && *params.get("bool") == false)); - params["bool"] = "False"; - BOOST_TEST( (params.get("bool") && *params.get("bool") == false)); + params["bool"] = "0"; + BOOST_TEST( (params.get("bool") && *params.get("bool") == false)); - params["bool"] = "off"; - BOOST_TEST( (params.get("bool") && *params.get("bool") == false)); + params["bool"] = "False"; + BOOST_TEST( (params.get("bool") && *params.get("bool") == false)); - params["bool"] = "no"; - BOOST_TEST( (params.get("bool") && *params.get("bool") == false)); + params["bool"] = "off"; + BOOST_TEST( (params.get("bool") && *params.get("bool") == false)); - // strings - params["string"] = "hello"; - BOOST_TEST( (params.get("string") && *params.get("string") == "hello") ); + params["bool"] = "no"; + BOOST_TEST( (params.get("bool") && *params.get("bool") == false)); - // int - params["int"] = 1; - BOOST_TEST( (params.get("int") && *params.get("int") == 1) ); + // strings + params["string"] = "hello"; + BOOST_TEST( (params.get("string") && *params.get("string") == "hello") ); - // double - params["double"] = 1.5; - BOOST_TEST( (params.get("double") && *params.get("double") == 1.5) ); + // int + params["int"] = 1; + BOOST_TEST( (params.get("int") && *params.get("int") == 1) ); - // value_null - params["null"] = mapnik::value_null(); - //BOOST_TEST( (params.get("null")/* && *params.get("null") == mapnik::value_null()*/) ); + // double + params["double"] = 1.5; + BOOST_TEST( (params.get("double") && *params.get("double") == 1.5) ); - if (!::boost::detail::test_errors()) { - std::clog << "C++ parameters: \x1b[1;32m✓ \x1b[0m\n"; - } else { - return ::boost::report_errors(); - } + // value_null + params["null"] = mapnik::value_null(); + //BOOST_TEST( (params.get("null")/* && *params.get("null") == mapnik::value_null()*/) ); + + if (!::boost::detail::test_errors()) { + std::clog << "C++ parameters: \x1b[1;32m✓ \x1b[0m\n"; + } else { + return ::boost::report_errors(); + } } diff --git a/tests/cpp_tests/svg_renderer_tests/background_color_test.cpp b/tests/cpp_tests/svg_renderer_tests/background_color_test.cpp index 03cda25d6..7ff205836 100644 --- a/tests/cpp_tests/svg_renderer_tests/background_color_test.cpp +++ b/tests/cpp_tests/svg_renderer_tests/background_color_test.cpp @@ -1,7 +1,7 @@ #define BOOST_TEST_MODULE background_color_test /* - * This test module contains several generators for + * This test module contains several generators for * the implementation of a background color in SVG * using a rectangle. */ @@ -25,16 +25,16 @@ namespace repository = boost::spirit::repository; namespace fusion = boost::fusion; using namespace karma; -struct F +struct F { F() : - x(0), - y(0), - width(100), - height(100), - bgcolor("#ffffff"), - expected_output("") {} - + x(0), + y(0), + width(100), + height(100), + bgcolor("#ffffff"), + expected_output("") {} + ~F() {} const int x; @@ -61,14 +61,14 @@ struct F BOOST_FIXTURE_TEST_CASE(bgcolor_stream_test_case, F) { actual_output - << format( - "", - x, y, width, "px", height, "px", bgcolor); + << format( + "", + x, y, width, "px", height, "px", bgcolor); BOOST_CHECK_EQUAL(actual_output.str(), expected_output); } @@ -79,7 +79,7 @@ BOOST_FIXTURE_TEST_CASE(bgcolor_stream_test_case, F) * * Notice that the generators' attribute list contains also tuples. * Tuples are needed to specify each confix's attributes that contain - * more than one generator, like confix()[int_ << string] (this + * more than one generator, like confix()[int_ << string] (this * generator needs a tuple: tuple). * * The difference between this generator and the one in test case @@ -92,15 +92,15 @@ BOOST_FIXTURE_TEST_CASE(bgcolor_stream_confix_test_case, F) using fusion::tuple; actual_output - << format( - "", - x, y, tuple(width, "px"), tuple(height, "px"), bgcolor); - + << format( + "", + x, y, tuple(width, "px"), tuple(height, "px"), bgcolor); + BOOST_CHECK_EQUAL(actual_output.str(), expected_output); } @@ -109,11 +109,11 @@ BOOST_FIXTURE_TEST_CASE(bgcolor_stream_confix_test_case, F) * using confix. notice that a confix generator can be part of another * confix generator's expression. * - * Notice also that the attribute list is the same as in - * 'bgcolor_stream_confix_test_case'. From this one can see that each - * generator is meant to have a list of attributes if it has more than one. + * Notice also that the attribute list is the same as in + * 'bgcolor_stream_confix_test_case'. From this one can see that each + * generator is meant to have a list of attributes if it has more than one. * - * If the generator is nested inside another generator, the former's attribute + * If the generator is nested inside another generator, the former's attribute * list will be another list (a tuple, for example) inside the latter's. */ BOOST_FIXTURE_TEST_CASE(bgcolor_stream_confix_complete_test_case, F) @@ -122,15 +122,15 @@ BOOST_FIXTURE_TEST_CASE(bgcolor_stream_confix_complete_test_case, F) using fusion::tuple; actual_output - << format( - confix('<', "/>")[ - "rect x=" << confix('"', '"')[int_] - << " y=" << confix('"', '"')[int_] - << " width=" << confix('"', '"')[int_ << string] - << " height=" << confix('"', '"')[int_ << string] - << " style=" << confix('"', '"')["fill: " << string]], - x, y, tuple(width, "px"), tuple(height, "px"), bgcolor); - + << format( + confix('<', "/>")[ + "rect x=" << confix('"', '"')[int_] + << " y=" << confix('"', '"')[int_] + << " width=" << confix('"', '"')[int_ << string] + << " height=" << confix('"', '"')[int_ << string] + << " style=" << confix('"', '"')["fill: " << string]], + x, y, tuple(width, "px"), tuple(height, "px"), bgcolor); + BOOST_CHECK_EQUAL(actual_output.str(), expected_output); } @@ -152,14 +152,14 @@ BOOST_FIXTURE_TEST_CASE(bgcolor_stream_iterator_test_case, F) std::ostream_iterator actual_output_iterator(actual_output); generate( - actual_output_iterator, - confix("<", "/>")[ - "rect x=" << confix('"', '"')[int_] - << " y=" << confix('"', '"')[int_] - << " width=" << confix('"', '"')[int_ << string] - << " height=" << confix('"', '"')[int_ << string] - << " style=" << confix('"', '"')["fill: " << string]], - x, y, tuple(width, "px"), tuple(height, "px"), bgcolor); + actual_output_iterator, + confix("<", "/>")[ + "rect x=" << confix('"', '"')[int_] + << " y=" << confix('"', '"')[int_] + << " width=" << confix('"', '"')[int_ << string] + << " height=" << confix('"', '"')[int_ << string] + << " style=" << confix('"', '"')["fill: " << string]], + x, y, tuple(width, "px"), tuple(height, "px"), bgcolor); BOOST_CHECK_EQUAL(actual_output.str(), expected_output); } diff --git a/tests/cpp_tests/svg_renderer_tests/combined_test.cpp b/tests/cpp_tests/svg_renderer_tests/combined_test.cpp index d4e250f75..38c22aa3a 100644 --- a/tests/cpp_tests/svg_renderer_tests/combined_test.cpp +++ b/tests/cpp_tests/svg_renderer_tests/combined_test.cpp @@ -37,21 +37,21 @@ BOOST_AUTO_TEST_CASE(combined_test_case) svg_ren renderer(map, output_stream_iterator); renderer.apply(); - /*std::string expected_output = - svg_ren::XML_DECLARATION - + "\n" - + svg_ren::SVG_DTD - + "\n" - + "" - +"\n" - +"" - +"\n" - +""; + /*std::string expected_output = + svg_ren::XML_DECLARATION + + "\n" + + svg_ren::SVG_DTD + + "\n" + + "" + +"\n" + +"" + +"\n" + +""; - std::string actual_output = output_stream.str(); - BOOST_CHECK_EQUAL(actual_output, expected_output); + std::string actual_output = output_stream.str(); + BOOST_CHECK_EQUAL(actual_output, expected_output); */ } diff --git a/tests/cpp_tests/svg_renderer_tests/file_output_test.cpp b/tests/cpp_tests/svg_renderer_tests/file_output_test.cpp index 0b0e0aee4..fb71a557b 100644 --- a/tests/cpp_tests/svg_renderer_tests/file_output_test.cpp +++ b/tests/cpp_tests/svg_renderer_tests/file_output_test.cpp @@ -51,15 +51,15 @@ BOOST_AUTO_TEST_CASE(file_output_test_case) if(output_stream) { std::ostream_iterator output_stream_iterator(output_stream); - + svg_ren renderer(map, output_stream_iterator); renderer.apply(); - + output_stream.close(); - - filesystem::path output_filename_path = + + filesystem::path output_filename_path = filesystem::system_complete(filesystem::path(".")) / filesystem::path(output_filename); - + BOOST_CHECK_MESSAGE(filesystem::exists(output_filename_path), "File '"+output_filename_path.string()+"' was created."); } else diff --git a/tests/cpp_tests/svg_renderer_tests/path_element_test.cpp b/tests/cpp_tests/svg_renderer_tests/path_element_test.cpp index 317227430..14089fa59 100644 --- a/tests/cpp_tests/svg_renderer_tests/path_element_test.cpp +++ b/tests/cpp_tests/svg_renderer_tests/path_element_test.cpp @@ -25,54 +25,54 @@ namespace filesystem = boost::filesystem; using namespace mapnik; void prepare_map(Map& m) -{ +{ const std::string mapnik_dir("/usr/local/lib/mapnik/"); std::cout << " looking for 'shape.input' plugin in... " << mapnik_dir << "input/" << "\n"; - datasource_cache::instance()->register_datasources(mapnik_dir + "input/"); + datasource_cache::instance()->register_datasources(mapnik_dir + "input/"); // create styles // Provinces (polygon) feature_type_style provpoly_style; - + rule provpoly_rule_on; provpoly_rule_on.set_filter(parse_expression("[NAME_EN] = 'Ontario'")); provpoly_rule_on.append(polygon_symbolizer(color(250, 190, 183))); provpoly_style.add_rule(provpoly_rule_on); - + rule provpoly_rule_qc; provpoly_rule_qc.set_filter(parse_expression("[NOM_FR] = 'Québec'")); provpoly_rule_qc.append(polygon_symbolizer(color(217, 235, 203))); provpoly_style.add_rule(provpoly_rule_qc); - + m.insert_style("provinces",provpoly_style); // Provinces (polyline) feature_type_style provlines_style; - + stroke provlines_stk (color(0,0,0),1.0); provlines_stk.add_dash(8, 4); provlines_stk.add_dash(2, 2); provlines_stk.add_dash(2, 2); - + rule provlines_rule; provlines_rule.append(line_symbolizer(provlines_stk)); provlines_style.add_rule(provlines_rule); - + m.insert_style("provlines",provlines_style); - - // Drainage + + // Drainage feature_type_style qcdrain_style; - + rule qcdrain_rule; qcdrain_rule.set_filter(parse_expression("[HYC] = 8")); qcdrain_rule.append(polygon_symbolizer(color(153, 204, 255))); qcdrain_style.add_rule(qcdrain_rule); - + m.insert_style("drainage",qcdrain_style); - + // Roads 3 and 4 (The "grey" roads) - feature_type_style roads34_style; + feature_type_style roads34_style; rule roads34_rule; roads34_rule.set_filter(parse_expression("[CLASS] = 3 or [CLASS] = 4")); stroke roads34_rule_stk(color(171,158,137),2.0); @@ -80,9 +80,9 @@ void prepare_map(Map& m) roads34_rule_stk.set_line_join(ROUND_JOIN); roads34_rule.append(line_symbolizer(roads34_rule_stk)); roads34_style.add_rule(roads34_rule); - + m.insert_style("smallroads",roads34_style); - + // Roads 2 (The thin yellow ones) feature_type_style roads2_style_1; rule roads2_rule_1; @@ -92,9 +92,9 @@ void prepare_map(Map& m) roads2_rule_stk_1.set_line_join(ROUND_JOIN); roads2_rule_1.append(line_symbolizer(roads2_rule_stk_1)); roads2_style_1.add_rule(roads2_rule_1); - + m.insert_style("road-border", roads2_style_1); - + feature_type_style roads2_style_2; rule roads2_rule_2; roads2_rule_2.set_filter(parse_expression("[CLASS] = 2")); @@ -103,9 +103,9 @@ void prepare_map(Map& m) roads2_rule_stk_2.set_line_join(ROUND_JOIN); roads2_rule_2.append(line_symbolizer(roads2_rule_stk_2)); roads2_style_2.add_rule(roads2_rule_2); - + m.insert_style("road-fill", roads2_style_2); - + // Roads 1 (The big orange ones, the highways) feature_type_style roads1_style_1; rule roads1_rule_1; @@ -116,7 +116,7 @@ void prepare_map(Map& m) roads1_rule_1.append(line_symbolizer(roads1_rule_stk_1)); roads1_style_1.add_rule(roads1_rule_1); m.insert_style("highway-border", roads1_style_1); - + feature_type_style roads1_style_2; rule roads1_rule_2; roads1_rule_2.set_filter(parse_expression("[CLASS] = 1")); @@ -125,21 +125,21 @@ void prepare_map(Map& m) roads1_rule_stk_2.set_line_join(ROUND_JOIN); roads1_rule_2.append(line_symbolizer(roads1_rule_stk_2)); roads1_style_2.add_rule(roads1_rule_2); - m.insert_style("highway-fill", roads1_style_2); - + m.insert_style("highway-fill", roads1_style_2); + // layers // Provincial polygons { parameters p; p["type"]="shape"; p["file"]="../../../demo/data/boundaries"; - - layer lyr("Provinces"); + + layer lyr("Provinces"); lyr.set_datasource(datasource_cache::instance()->create(p)); - lyr.add_style("provinces"); + lyr.add_style("provinces"); m.addLayer(lyr); } - + // Drainage { parameters p; @@ -147,46 +147,46 @@ void prepare_map(Map& m) p["file"]="../../../demo/data/qcdrainage"; layer lyr("Quebec Hydrography"); lyr.set_datasource(datasource_cache::instance()->create(p)); - lyr.add_style("drainage"); + lyr.add_style("drainage"); m.addLayer(lyr); } - + { parameters p; p["type"]="shape"; p["file"]="../../../demo/data/ontdrainage"; - - layer lyr("Ontario Hydrography"); + + layer lyr("Ontario Hydrography"); lyr.set_datasource(datasource_cache::instance()->create(p)); - lyr.add_style("drainage"); + lyr.add_style("drainage"); m.addLayer(lyr); } - + // Provincial boundaries { parameters p; p["type"]="shape"; p["file"]="../../../demo/data/boundaries_l"; - layer lyr("Provincial borders"); + layer lyr("Provincial borders"); lyr.set_datasource(datasource_cache::instance()->create(p)); - lyr.add_style("provlines"); + lyr.add_style("provlines"); m.addLayer(lyr); } - + // Roads { parameters p; p["type"]="shape"; - p["file"]="../../../demo/data/roads"; - layer lyr("Roads"); + p["file"]="../../../demo/data/roads"; + layer lyr("Roads"); lyr.set_datasource(datasource_cache::instance()->create(p)); lyr.add_style("smallroads"); lyr.add_style("road-border"); lyr.add_style("road-fill"); lyr.add_style("highway-border"); lyr.add_style("highway-fill"); - - m.addLayer(lyr); + + m.addLayer(lyr); } } @@ -197,19 +197,19 @@ void render_to_file(Map const& m, const std::string output_filename) if(output_stream) { typedef svg_renderer > svg_ren; - + std::ostream_iterator output_stream_iterator(output_stream); - + svg_ren renderer(m, output_stream_iterator); renderer.apply(); - + output_stream.close(); - - filesystem::path output_filename_path = + + filesystem::path output_filename_path = filesystem::system_complete(filesystem::path(".")) / filesystem::path(output_filename); - - BOOST_CHECK_MESSAGE(filesystem::exists(output_filename_path), - "File '"+output_filename_path.string()+"' was created."); + + BOOST_CHECK_MESSAGE(filesystem::exists(output_filename_path), + "File '"+output_filename_path.string()+"' was created."); } else { @@ -220,12 +220,12 @@ void render_to_file(Map const& m, const std::string output_filename) BOOST_AUTO_TEST_CASE(path_element_test_case_1) { Map m(800,600); - m.set_background(color_factory::from_string("steelblue")); + m.set_background(color_factory::from_string("steelblue")); prepare_map(m); - + //m.zoom_to_box(box2d(1405120.04127408, -247003.813399447, - //1706357.31328276, -25098.593149577)); - m.zoom_all(); + //1706357.31328276, -25098.593149577)); + m.zoom_all(); render_to_file(m, "path_element_test_case_1.svg"); } diff --git a/tests/cpp_tests/svg_renderer_tests/root_element_test.cpp b/tests/cpp_tests/svg_renderer_tests/root_element_test.cpp index c98755bf8..a3c2c4275 100644 --- a/tests/cpp_tests/svg_renderer_tests/root_element_test.cpp +++ b/tests/cpp_tests/svg_renderer_tests/root_element_test.cpp @@ -1,7 +1,7 @@ #define BOOST_TEST_MODULE root_element_test /* - * This test module contains several generators for + * This test module contains several generators for * the SVG root element. */ @@ -24,14 +24,14 @@ namespace repository = boost::spirit::repository; namespace fusion = boost::fusion; using namespace karma; -struct F +struct F { F() : - width(100), - height(100), - version(1.1), - xmlns("http://www.w3.org/2000/svg"), - expected_output("") {} + width(100), + height(100), + version(1.1), + xmlns("http://www.w3.org/2000/svg"), + expected_output("") {} ~F() {} @@ -58,13 +58,13 @@ struct F BOOST_FIXTURE_TEST_CASE(bgcolor_stream_test_case, F) { actual_output - << format( - "", - width, "px", height, "px", version, xmlns); + << format( + "", + width, "px", height, "px", version, xmlns); BOOST_CHECK_EQUAL(actual_output.str(), expected_output); } @@ -75,7 +75,7 @@ BOOST_FIXTURE_TEST_CASE(bgcolor_stream_test_case, F) * * Notice that the generators' attribute list contains also tuples. * Tuples are needed to specify each confix's attributes that contain - * more than one generator, like confix()[int_ << string] (this + * more than one generator, like confix()[int_ << string] (this * generator needs a tuple: tuple). * * The difference between this generator and the one in test case @@ -88,14 +88,14 @@ BOOST_FIXTURE_TEST_CASE(bgcolor_stream_confix_test_case, F) using fusion::tuple; actual_output - << format( - "", - tuple(width, "px"), tuple(height, "px"), version, xmlns); - + << format( + "", + tuple(width, "px"), tuple(height, "px"), version, xmlns); + BOOST_CHECK_EQUAL(actual_output.str(), expected_output); } @@ -104,11 +104,11 @@ BOOST_FIXTURE_TEST_CASE(bgcolor_stream_confix_test_case, F) * using confix. notice that a confix generator can be part of another * confix generator's expression. * - * Notice also that the attribute list is the same as in - * 'bgcolor_stream_confix_test_case'. From this one can see that each - * generator is meant to have a list of attributes if it has more than one. + * Notice also that the attribute list is the same as in + * 'bgcolor_stream_confix_test_case'. From this one can see that each + * generator is meant to have a list of attributes if it has more than one. * - * If the generator is nested inside another generator, the former's attribute + * If the generator is nested inside another generator, the former's attribute * list will be another list (a tuple, for example) inside the latter's. */ BOOST_FIXTURE_TEST_CASE(bgcolor_stream_confix_complete_test_case, F) @@ -117,14 +117,14 @@ BOOST_FIXTURE_TEST_CASE(bgcolor_stream_confix_complete_test_case, F) using fusion::tuple; actual_output - << format( - confix('<', ">")[ - "svg width=" << confix('"', '"')[int_ << string] - << " height=" << confix('"', '"')[int_ << string] - << " version=" << confix('"', '"')[float_] - << " xmlns=" << confix('"', '"')[string]], - tuple(width, "px"), tuple(height, "px"), version, xmlns); - + << format( + confix('<', ">")[ + "svg width=" << confix('"', '"')[int_ << string] + << " height=" << confix('"', '"')[int_ << string] + << " version=" << confix('"', '"')[float_] + << " xmlns=" << confix('"', '"')[string]], + tuple(width, "px"), tuple(height, "px"), version, xmlns); + BOOST_CHECK_EQUAL(actual_output.str(), expected_output); } @@ -146,13 +146,13 @@ BOOST_FIXTURE_TEST_CASE(bgcolor_stream_iterator_test_case, F) std::ostream_iterator actual_output_iterator(actual_output); generate( - actual_output_iterator, - confix("<", ">")[ - "svg width=" << confix('"', '"')[int_ << string] - << " height=" << confix('"', '"')[int_ << string] - << " version=" << confix('"', '"')[float_] - << " xmlns=" << confix('"', '"')[string]], - tuple(width, "px"), tuple(height, "px"), version, xmlns); + actual_output_iterator, + confix("<", ">")[ + "svg width=" << confix('"', '"')[int_ << string] + << " height=" << confix('"', '"')[int_ << string] + << " version=" << confix('"', '"')[float_] + << " xmlns=" << confix('"', '"')[string]], + tuple(width, "px"), tuple(height, "px"), version, xmlns); BOOST_CHECK_EQUAL(actual_output.str(), expected_output); } diff --git a/utils/format_source_files/format_source_files.sh b/utils/format_source_files/format_source_files.sh index dc0dc6103..90dc8fef7 100755 --- a/utils/format_source_files/format_source_files.sh +++ b/utils/format_source_files/format_source_files.sh @@ -3,7 +3,7 @@ # batch format *.{hpp,cpp} files MAPNIK_DIR=`pwd` -DIRS="$MAPNIK_DIR/plugins $MAPNIK_DIR/demo/c++ $MAPNIK_DIR/src $MAPNIK_DIR/include $MAPNIK_DIR/bindings $MAPNIK_DIR/utils" +DIRS="$MAPNIK_DIR/plugins $MAPNIK_DIR/demo/c++ $MAPNIK_DIR/src $MAPNIK_DIR/include $MAPNIK_DIR/bindings $MAPNIK_DIR/utils $MAPNIK_DIR/tests" EMACS="emacs" for file in $(find $DIRS -name '*.cpp' -o -name '*.hpp')