diff --git a/test/build.py b/test/build.py index 78fd9342a..8a9a44523 100644 --- a/test/build.py +++ b/test/build.py @@ -54,6 +54,7 @@ else: visual/report.cpp visual/runner.cpp visual/run.cpp + visual/parse_map_sizes.cpp """ ) test_program3 = test_env_local.Program('visual/run', source=source) diff --git a/test/visual/map_sizes_grammar.hpp b/test/visual/parse_map_sizes.cpp similarity index 55% rename from test/visual/map_sizes_grammar.hpp rename to test/visual/parse_map_sizes.cpp index 2c79d90d8..7cea5df4a 100644 --- a/test/visual/map_sizes_grammar.hpp +++ b/test/visual/parse_map_sizes.cpp @@ -2,7 +2,7 @@ * * This file is part of Mapnik (c++ mapping toolkit) * - * Copyright (C) 2015 Artem Pavlenko + * Copyright (C) 2016 Artem Pavlenko * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,40 +20,36 @@ * *****************************************************************************/ -#ifndef MAP_SIZES_GRAMMAR_HPP -#define MAP_SIZES_GRAMMAR_HPP +#include "parse_map_sizes.hpp" #pragma GCC diagnostic push #include -#include -#include +#include +#include #pragma GCC diagnostic pop -namespace visual_tests -{ +BOOST_FUSION_ADAPT_STRUCT ( + visual_tests::map_size, + (std::size_t, width) + (std::size_t, height) + ) -namespace qi = boost::spirit::qi; -namespace ascii = boost::spirit::ascii; +namespace visual_tests { -template -struct map_sizes_grammar : qi::grammar(), ascii::space_type> +namespace x3 = boost::spirit::x3; +using x3::ulong_; +auto const map_sizes_grammar = x3::rule >{} = + (ulong_ >> ',' >> ulong_) % ';' ; + +void parse_map_sizes(std::string const & str, std::vector & sizes) { - map_sizes_grammar() : map_sizes_grammar::base_type(start) + boost::spirit::x3::ascii::space_type space; + std::string::const_iterator iter = str.begin(); + std::string::const_iterator end = str.end(); + if (!boost::spirit::x3::phrase_parse(iter, end, map_sizes_grammar, space, sizes)) { - using namespace boost::spirit::qi; - using namespace boost::phoenix; - - int_type int_; - _1_type _1; - _2_type _2; - _val_type _val; - - start = (int_ >> ',' >> int_)[push_back(_val, construct(_1, _2))] % ';'; + throw std::runtime_error("Failed to parse list of sizes: '" + str + "'"); } - - qi::rule(), ascii::space_type> start; -}; - } -#endif +} diff --git a/test/visual/parse_map_sizes.hpp b/test/visual/parse_map_sizes.hpp new file mode 100644 index 000000000..5d0f0125b --- /dev/null +++ b/test/visual/parse_map_sizes.hpp @@ -0,0 +1,36 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2016 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +#ifndef VISUAL_TESTS_PARSE_MAP_SIZES_HPP +#define VISUAL_TESTS_PARSE_MAP_SIZES_HPP + +#include "config.hpp" +#include +#include + +namespace visual_tests { + +void parse_map_sizes(std::string const & str, std::vector & sizes); + +} + +#endif //VISUAL_TESTS_PARSE_MAP_SIZES_HPP diff --git a/test/visual/runner.cpp b/test/visual/runner.cpp index d0c7222fb..18e6506ec 100644 --- a/test/visual/runner.cpp +++ b/test/visual/runner.cpp @@ -2,7 +2,7 @@ * * This file is part of Mapnik (c++ mapping toolkit) * - * Copyright (C) 2015 Artem Pavlenko + * Copyright (C) 2016 Artem Pavlenko * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -25,9 +25,11 @@ #include #include + #include #include "runner.hpp" +#include "parse_map_sizes.hpp" namespace visual_tests { @@ -348,19 +350,7 @@ result_list runner::test_one(runner::path_type const& style_path, } } } - return results; } -void runner::parse_map_sizes(std::string const & str, std::vector & sizes) const -{ - boost::spirit::ascii::space_type space; - std::string::const_iterator iter = str.begin(); - std::string::const_iterator end = str.end(); - if (!boost::spirit::qi::phrase_parse(iter, end, map_sizes_parser_, space, sizes)) - { - throw std::runtime_error("Failed to parse list of sizes: '" + str + "'"); - } -} - } diff --git a/test/visual/runner.hpp b/test/visual/runner.hpp index e38e39422..b5c031627 100644 --- a/test/visual/runner.hpp +++ b/test/visual/runner.hpp @@ -2,7 +2,7 @@ * * This file is part of Mapnik (c++ mapping toolkit) * - * Copyright (C) 2015 Artem Pavlenko + * Copyright (C) 2016 Artem Pavlenko * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -26,7 +26,6 @@ #include "config.hpp" #include "report.hpp" #include "renderer.hpp" -#include "map_sizes_grammar.hpp" namespace visual_tests { @@ -58,9 +57,7 @@ private: result_list test_one(path_type const & style_path, report_type & report, std::atomic & fail_limit) const; - void parse_map_sizes(std::string const & str, std::vector & sizes) const; - const map_sizes_grammar map_sizes_parser_; const path_type styles_dir_; const config defaults_; const std::size_t jobs_; @@ -71,4 +68,4 @@ private: } -#endif +#endif //VISUAL_TEST_RUNNER_HPP