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>;
#define REQUIRE_ATTRIBUTES(feature, attrs) \
REQUIRE(bool(feature)); \
for (auto const &kv : attrs) { \
REQUIRE(feature->has_key(std::get<0>(kv))); \
CHECK(feature->get(std::get<0>(kv)) == std::get<1>(kv)); \
#define REQUIRE_ATTRIBUTES(feature, ...) \
do { \
auto const& _feat = (feature); /* evaluate feature only once */ \
REQUIRE(_feat != nullptr); \
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,
std::initializer_list<attr> const &attrs) {