From d62e215ff951d574eb9638eb44b38024196fe2b6 Mon Sep 17 00:00:00 2001 From: Mickey Rose Date: Sat, 30 Jun 2018 15:04:35 +0200 Subject: [PATCH] datasource tests: also check value types in REQUIRE_ATTRIBUTES --- test/unit/datasource/ds_test_util.hpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/test/unit/datasource/ds_test_util.hpp b/test/unit/datasource/ds_test_util.hpp index 381d70c6e..c39334747 100644 --- a/test/unit/datasource/ds_test_util.hpp +++ b/test/unit/datasource/ds_test_util.hpp @@ -107,13 +107,20 @@ inline std::size_t count_features(mapnik::featureset_ptr features) { using attr = std::tuple; -#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 const &attrs) {