Commit 848e5527 authored by Dominik Charousset's avatar Dominik Charousset

Move unbox() DSL utility to global namespace

parent 8c2fcff6
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
******************************************************************************/ ******************************************************************************/
#define CAF_SUITE config_option #define CAF_SUITE config_option
#include "caf/test/unit_test.hpp" #include "caf/test/dsl.hpp"
#include "caf/config_option.hpp" #include "caf/config_option.hpp"
#include "caf/make_config_option.hpp" #include "caf/make_config_option.hpp"
...@@ -87,13 +87,6 @@ void check_integer_options() { ...@@ -87,13 +87,6 @@ void check_integer_options() {
check_integer_options<T>(tk); check_integer_options<T>(tk);
} }
template <class T>
T unbox(optional<T> x) {
if (!x)
CAF_FAIL("no value to unbox");
return std::move(*x);
}
} // namespace <anonymous> } // namespace <anonymous>
CAF_TEST(type_bool) { CAF_TEST(type_bool) {
......
...@@ -581,6 +581,7 @@ struct test_coordinator_fixture { ...@@ -581,6 +581,7 @@ struct test_coordinator_fixture {
: cfg(std::forward<Ts>(xs)...), : cfg(std::forward<Ts>(xs)...),
sys(cfg.parse(caf::test::engine::argc(), caf::test::engine::argv()) sys(cfg.parse(caf::test::engine::argc(), caf::test::engine::argv())
.set("scheduler.policy", caf::atom("testing")) .set("scheduler.policy", caf::atom("testing"))
.set("logger.inline-output", true)
.set("middleman.network-backend", caf::atom("testing"))), .set("middleman.network-backend", caf::atom("testing"))),
self(sys, true), self(sys, true),
sched(dynamic_cast<scheduler_type&>(sys.scheduler())), sched(dynamic_cast<scheduler_type&>(sys.scheduler())),
...@@ -623,14 +624,6 @@ struct test_coordinator_fixture { ...@@ -623,14 +624,6 @@ struct test_coordinator_fixture {
return f(res_hdl); return f(res_hdl);
} }
/// Unboxes an expected value or fails the test if it doesn't exist.
template <class T>
T unbox(caf::expected<T> x) {
if (!x)
FAIL(sys.render(x.error()));
return std::move(*x);
}
template <class T> template <class T>
const T& peek() { const T& peek() {
return sched.template peek<T>(); return sched.template peek<T>();
...@@ -644,6 +637,22 @@ struct test_coordinator_fixture { ...@@ -644,6 +637,22 @@ struct test_coordinator_fixture {
} }
}; };
/// Unboxes an expected value or fails the test if it doesn't exist.
template <class T>
T unbox(caf::expected<T> x) {
if (!x)
CAF_FAIL(to_string(x.error()));
return std::move(*x);
}
/// Unboxes an optional value or fails the test if it doesn't exist.
template <class T>
T unbox(caf::optional<T> x) {
if (!x)
CAF_FAIL("x == none");
return std::move(*x);
}
} // namespace <anonymous> } // namespace <anonymous>
/// Expands to its argument. /// Expands to its argument.
......
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