1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
#include "catch.hpp"
#include "utils.hpp"
#include <osmium/handler.hpp>
#include <osmium/io/xml_input.hpp>
#include <osmium/relations/manager_util.hpp>
#include <osmium/util/progress_bar.hpp>
class TestHandler : public osmium::handler::Handler {
public:
int count = 0;
bool prep = false;
void relation(const osmium::Relation& /*relation*/) noexcept {
++count;
}
void prepare_for_lookup() noexcept {
prep = true;
}
}; // class TestHandler
TEST_CASE("Read relations with one handler") {
const osmium::io::File file{with_data_dir("t/relations/data.osm")};
TestHandler handler;
osmium::relations::read_relations(file, handler);
REQUIRE(handler.count == 3);
REQUIRE(handler.prep);
}
TEST_CASE("Read relations with two handlers") {
const osmium::io::File file{with_data_dir("t/relations/data.osm")};
TestHandler handler1;
TestHandler handler2;
osmium::relations::read_relations(file, handler1, handler2);
REQUIRE(handler1.count == 3);
REQUIRE(handler2.count == 3);
REQUIRE(handler1.prep);
REQUIRE(handler2.prep);
}
TEST_CASE("Read relations with progress bar and one handler") {
const osmium::io::File file{with_data_dir("t/relations/data.osm")};
osmium::ProgressBar progress_bar{file.size(), false};
TestHandler handler;
osmium::relations::read_relations(progress_bar, file, handler);
REQUIRE(handler.count == 3);
REQUIRE(handler.prep);
}
TEST_CASE("Read relations with progress bar and two handlers") {
const osmium::io::File file{with_data_dir("t/relations/data.osm")};
osmium::ProgressBar progress_bar{file.size(), false};
TestHandler handler1;
TestHandler handler2;
osmium::relations::read_relations(progress_bar, file, handler1, handler2);
REQUIRE(handler1.count == 3);
REQUIRE(handler2.count == 3);
REQUIRE(handler1.prep);
REQUIRE(handler2.prep);
}
|