Commit 97fea3fd authored by Dominik Charousset's avatar Dominik Charousset

Fix handling of multimap and of local bindings

parent e3e459fa
......@@ -26,15 +26,11 @@
#ifdef __has_include
# if __has_include(<optional>)
# include <optional>
# if __cpp_lib_optional >= 201606
# define CAF_HAS_STD_OPTIONAL
# endif
# define CAF_HAS_STD_OPTIONAL
# endif
# if __has_include(<variant>)
# include <variant>
# if __cpp_lib_variant >= 201606
# define CAF_HAS_STD_VARIANT
# endif
# define CAF_HAS_STD_VARIANT
# endif
#endif
......@@ -167,9 +163,13 @@ bool load_value(Inspector& f, T& x, inspector_access_type::map) {
&& load_value(f, val) //
&& f.end_key_value_pair()))
return false;
if (!x.emplace(std::move(key), std::move(val)).second) {
f.emplace_error(sec::runtime_error, "multiple key definitions");
return false;
// A multimap returns an iterator, a regular map returns a pair.
auto emplace_result = x.emplace(std::move(key), std::move(val));
if constexpr (is_pair<decltype(emplace_result)>::value) {
if (!emplace_result.second) {
f.emplace_error(sec::runtime_error, "multiple key definitions");
return false;
}
}
}
return f.end_associative_array();
......
......@@ -546,29 +546,28 @@ using caf_test_case_auto_fixture = caf::test::dummy_fixture;
} while (false)
#define CAF_CHECK(...) \
([&] { \
([](bool expr_result) { \
auto caf_check_res \
= ::caf::test::detail::check(::caf::test::engine::current_test(), \
__FILE__, __LINE__, #__VA_ARGS__, false, \
static_cast<bool>(__VA_ARGS__)); \
expr_result); \
::caf::test::engine::last_check_file(__FILE__); \
::caf::test::engine::last_check_line(__LINE__); \
return caf_check_res; \
})()
})(static_cast<bool>(__VA_ARGS__))
#define CAF_CHECK_FUNC(func, x_expr, y_expr) \
([&] { \
([](auto&& x_val, auto&& y_val) { \
func comparator; \
auto&& x_val___ = x_expr; \
auto&& y_val___ = y_expr; \
auto caf_check_res = ::caf::test::detail::check( \
::caf::test::engine::current_test(), __FILE__, __LINE__, \
CAF_FUNC_EXPR(func, x_expr, y_expr), false, \
comparator(x_val___, y_val___), x_val___, y_val___); \
auto caf_check_res \
= ::caf::test::detail::check(::caf::test::engine::current_test(), \
__FILE__, __LINE__, \
CAF_FUNC_EXPR(func, x_expr, y_expr), false, \
comparator(x_val, y_val), x_val, y_val); \
::caf::test::engine::last_check_file(__FILE__); \
::caf::test::engine::last_check_line(__LINE__); \
return caf_check_res; \
})()
})(x_expr, y_expr)
#define CAF_CHECK_FAIL(...) \
do { \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment