datasource tests: also check value types in REQUIRE_ATTRIBUTES

This commit is contained in:
Mickey Rose 2018-06-30 15:04:35 +02:00
parent bf1c55b627
commit fa0d4c923f

View file

@ -107,13 +107,20 @@ inline std::size_t count_features(mapnik::featureset_ptr features) {
using attr = std::tuple<std::string, mapnik::value>; using attr = std::tuple<std::string, mapnik::value>;
#define REQUIRE_ATTRIBUTES(feature, attrs) \ #define REQUIRE_ATTRIBUTES(feature, ...) \
REQUIRE(bool(feature)); \ do { \
for (auto const &kv : attrs) { \ auto const& _feat = (feature); /* evaluate feature only once */ \
REQUIRE(feature->has_key(std::get<0>(kv))); \ REQUIRE(_feat != nullptr); \
CHECK(feature->get(std::get<0>(kv)) == std::get<1>(kv)); \ for (auto const& kv : __VA_ARGS__) { \
} \ auto& key = std::get<0>(kv); \
auto& val = std::get<1>(kv); \
CAPTURE(key); \
CHECKED_IF(_feat->has_key(key)) { \
CHECK(_feat->get(key) == val); \
CHECK(_feat->get(key).which() == val.which()); \
} \
} \
} while (0)
inline void require_attributes(mapnik::feature_ptr feature, inline void require_attributes(mapnik::feature_ptr feature,
std::initializer_list<attr> const &attrs) { std::initializer_list<attr> const &attrs) {