|
| 1 | +#include <catch.hpp> |
| 2 | + |
| 3 | +#include "common-import.hpp" |
| 4 | +#include "common-options.hpp" |
| 5 | + |
| 6 | +static testing::db::import_t db; |
| 7 | + |
| 8 | +static char const *const conf_file = "test_output_flex_way.lua"; |
| 9 | + |
| 10 | +static const char *const tdata[] = { |
| 11 | + "n10 v1 dV x10.0 y10.0", |
| 12 | + "n11 v1 dV x10.0 y10.1", |
| 13 | + "n12 v1 dV x10.1 y10.0", |
| 14 | + "n13 v1 dV x10.1 y10.1", |
| 15 | + "n14 v1 dV x10.2 y10.0", |
| 16 | + "n15 v1 dV x10.2 y10.1", |
| 17 | + "n16 v1 dV x10.3 y10.0", |
| 18 | + "n17 v1 dV x10.3 y10.1", |
| 19 | + "n18 v1 dV x10.4 y10.0", |
| 20 | + "n19 v1 dV x10.4 y10.1", |
| 21 | + "w11 v1 dV Tt1=yes Nn12,n13", |
| 22 | + "w12 v1 dV Tt2=yes Nn14,n15", |
| 23 | + "w13 v1 dV Ttboth=yes Nn16,n17", |
| 24 | + "w14 v1 dV Ttboth=yes Nn18,n19", |
| 25 | + "r30 v1 dV Tt=ag Mw11@,w12@mark,w13@,w14@mark"}; |
| 26 | + |
| 27 | +TEST_CASE("add way") |
| 28 | +{ |
| 29 | + options_t options = testing::opt_t().slim().flex(conf_file); |
| 30 | + |
| 31 | + testing::data_t data{tdata}; |
| 32 | + |
| 33 | + REQUIRE_NOTHROW(db.run_import(options, data())); |
| 34 | + |
| 35 | + auto conn = db.db().connect(); |
| 36 | + |
| 37 | + CHECK(1 == conn.get_count("osm2pgsql_test_t1")); |
| 38 | + CHECK(1 == conn.get_count("osm2pgsql_test_t2")); |
| 39 | + CHECK(2 == conn.get_count("osm2pgsql_test_tboth")); |
| 40 | + |
| 41 | + options.append = true; |
| 42 | + |
| 43 | + SECTION("way is not relevant") |
| 44 | + { |
| 45 | + REQUIRE_NOTHROW(db.run_import( |
| 46 | + options, "w10 v1 dV Tt=ag Nn10,n11\n" |
| 47 | + "r30 v2 dV Tt=ag Mw10@,w11@,w12@mark,w13@,w14@mark\n")); |
| 48 | + |
| 49 | + CHECK(1 == conn.get_count("osm2pgsql_test_t1")); |
| 50 | + CHECK(1 == conn.get_count("osm2pgsql_test_t2")); |
| 51 | + CHECK(2 == conn.get_count("osm2pgsql_test_tboth")); |
| 52 | + } |
| 53 | + |
| 54 | + SECTION("add to t1") |
| 55 | + { |
| 56 | + REQUIRE_NOTHROW(db.run_import( |
| 57 | + options, "w10 v1 dV Tt1=yes Nn10,n11\n" |
| 58 | + "r30 v2 dV Tt=ag Mw10@,w11@,w12@mark,w13@,w14@mark\n")); |
| 59 | + |
| 60 | + CHECK(2 == conn.get_count("osm2pgsql_test_t1")); |
| 61 | + CHECK(1 == conn.get_count("osm2pgsql_test_t1", "way_id = 10")); |
| 62 | + CHECK(1 == conn.get_count("osm2pgsql_test_t2")); |
| 63 | + CHECK(2 == conn.get_count("osm2pgsql_test_tboth")); |
| 64 | + } |
| 65 | + |
| 66 | + SECTION("add to t2") |
| 67 | + { |
| 68 | + REQUIRE_NOTHROW(db.run_import( |
| 69 | + options, |
| 70 | + "w10 v1 dV Tt2=yes Nn10,n11\n" |
| 71 | + "r30 v2 dV Tt=ag Mw10@mark,w11@,w12@mark,w13@,w14@mark\n")); |
| 72 | + |
| 73 | + CHECK(1 == conn.get_count("osm2pgsql_test_t1")); |
| 74 | + CHECK(2 == conn.get_count("osm2pgsql_test_t2")); |
| 75 | + CHECK(1 == conn.get_count("osm2pgsql_test_t2", |
| 76 | + "way_id = 10 AND rel_ids = '{30}'")); |
| 77 | + CHECK(2 == conn.get_count("osm2pgsql_test_tboth")); |
| 78 | + } |
| 79 | + |
| 80 | + SECTION("add to t1 and t2") |
| 81 | + { |
| 82 | + REQUIRE_NOTHROW(db.run_import( |
| 83 | + options, |
| 84 | + "w10 v1 dV Tt1=yes,t2=yes Nn10,n11\n" |
| 85 | + "r30 v2 dV Tt=ag Mw10@mark,w11@,w12@mark,w13@,w14@mark\n")); |
| 86 | + |
| 87 | + CHECK(2 == conn.get_count("osm2pgsql_test_t1")); |
| 88 | + CHECK(1 == conn.get_count("osm2pgsql_test_t1", "way_id = 10")); |
| 89 | + CHECK(2 == conn.get_count("osm2pgsql_test_t2")); |
| 90 | + CHECK(1 == conn.get_count("osm2pgsql_test_t2", |
| 91 | + "way_id = 10 AND rel_ids = '{30}'")); |
| 92 | + CHECK(2 == conn.get_count("osm2pgsql_test_tboth")); |
| 93 | + } |
| 94 | + |
| 95 | + SECTION("add to tboth (only stage1)") |
| 96 | + { |
| 97 | + REQUIRE_NOTHROW(db.run_import( |
| 98 | + options, "w10 v1 dV Ttboth=yes Nn10,n11\n" |
| 99 | + "r30 v2 dV Tt=ag Mw10@,w11@,w12@mark,w13@,w14@mark\n")); |
| 100 | + |
| 101 | + CHECK(1 == conn.get_count("osm2pgsql_test_t1")); |
| 102 | + CHECK(1 == conn.get_count("osm2pgsql_test_t2")); |
| 103 | + CHECK(3 == conn.get_count("osm2pgsql_test_tboth")); |
| 104 | + CHECK(1 == conn.get_count("osm2pgsql_test_tboth", |
| 105 | + "way_id = 10 AND rel_ids IS NULL")); |
| 106 | + } |
| 107 | + |
| 108 | + SECTION("add to tboth (stage1 and stage2)") |
| 109 | + { |
| 110 | + REQUIRE_NOTHROW(db.run_import( |
| 111 | + options, |
| 112 | + "w10 v1 dV Ttboth=yes Nn10,n11\n" |
| 113 | + "r30 v2 dV Tt=ag Mw10@mark,w11@,w12@mark,w13@,w14@mark\n")); |
| 114 | + |
| 115 | + CHECK(1 == conn.get_count("osm2pgsql_test_t1")); |
| 116 | + CHECK(1 == conn.get_count("osm2pgsql_test_t2")); |
| 117 | + CHECK(3 == conn.get_count("osm2pgsql_test_tboth")); |
| 118 | + CHECK(1 == conn.get_count("osm2pgsql_test_tboth", |
| 119 | + "way_id = 10 AND rel_ids = '{30}'")); |
| 120 | + } |
| 121 | +} |
0 commit comments