Commit 04f76fbb authored by Dominik Charousset's avatar Dominik Charousset

Fix shadowing warnings and use shutdown in tests

parent 19abf110
...@@ -146,6 +146,10 @@ oss_wr operator<<(oss_wr&& lhs, T rhs) { ...@@ -146,6 +146,10 @@ oss_wr operator<<(oss_wr&& lhs, T rhs) {
#define CAF_LVL_NAME3() "DEBUG" #define CAF_LVL_NAME3() "DEBUG"
#define CAF_LVL_NAME4() "TRACE" #define CAF_LVL_NAME4() "TRACE"
#define CAF_CONCAT_(LHS, RHS) LHS ## RHS
#define CAF_CONCAT(LHS, RHS) CAF_CONCAT_(LHS, RHS)
#define CAF_UNIFYN(NAME) CAF_CONCAT(NAME, __LINE__)
#define CAF_PRINT_ERROR_IMPL(lvlname, classname, funname, message) \ #define CAF_PRINT_ERROR_IMPL(lvlname, classname, funname, message) \
{ \ { \
std::cerr << "[" << lvlname << "] " << classname << "::" << funname \ std::cerr << "[" << lvlname << "] " << classname << "::" << funname \
...@@ -171,14 +175,14 @@ inline caf::actor_id caf_set_aid_dummy() { return 0; } ...@@ -171,14 +175,14 @@ inline caf::actor_id caf_set_aid_dummy() { return 0; }
<< std::boolalpha \ << std::boolalpha \
<< message).str()) << message).str())
#define CAF_PUSH_AID(aid_arg) \ #define CAF_PUSH_AID(aid_arg) \
auto prev_aid_in_scope \ auto CAF_UNIFYN(caf_aid_tmp) \
= caf::detail::singletons::get_logger()->set_aid(aid_arg); \ = caf::detail::singletons::get_logger()->set_aid(aid_arg); \
auto aid_pop_sg = caf::detail::make_scope_guard([=] { \ auto CAF_UNIFYN(aid_aid_tmp_guard) = caf::detail::make_scope_guard([=] { \
caf::detail::singletons::get_logger()->set_aid(prev_aid_in_scope); \ caf::detail::singletons::get_logger()->set_aid(CAF_UNIFYN(caf_aid_tmp)); \
}) })
#define CAF_PUSH_AID_FROM_PTR(some_ptr) \ #define CAF_PUSH_AID_FROM_PTR(some_ptr) \
auto aid_ptr_argument = some_ptr; \ auto CAF_UNIFYN(caf_aid_ptr) = some_ptr; \
CAF_PUSH_AID(aid_ptr_argument ? aid_ptr_argument->id() : 0) CAF_PUSH_AID(CAF_UNIFYN(caf_aid_ptr) ? CAF_UNIFYN(caf_aid_ptr)->id() : 0)
#define CAF_SET_AID(aid_arg) \ #define CAF_SET_AID(aid_arg) \
caf::detail::singletons::get_logger()->set_aid(aid_arg) caf::detail::singletons::get_logger()->set_aid(aid_arg)
#endif #endif
...@@ -204,7 +208,7 @@ inline caf::actor_id caf_set_aid_dummy() { return 0; } ...@@ -204,7 +208,7 @@ inline caf::actor_id caf_set_aid_dummy() { return 0; }
#define CAF_PRINT4(arg0, arg1, arg2, arg3) #define CAF_PRINT4(arg0, arg1, arg2, arg3)
#else #else
#define CAF_PRINT4(lvlname, classname, funname, msg) \ #define CAF_PRINT4(lvlname, classname, funname, msg) \
caf::detail::logging::trace_helper caf_log_trace_temporary_object { \ caf::detail::logging::trace_helper CAF_UNIFYN(caf_log_trace_) { \
classname, funname, __FILE__, __LINE__, \ classname, funname, __FILE__, __LINE__, \
(caf::detail::oss_wr{} << msg).str() \ (caf::detail::oss_wr{} << msg).str() \
} }
......
...@@ -299,7 +299,7 @@ class middleman_actor_impl : public middleman_actor_base::base { ...@@ -299,7 +299,7 @@ class middleman_actor_impl : public middleman_actor_base::base {
} }
template <class F> template <class F>
bool finalize_request(map_type& storage, uint64_t req_id, F fun) { bool finalize_request(map_type& storage, int64_t req_id, F fun) {
auto i = storage.find(req_id); auto i = storage.find(req_id);
if (i == storage.end()) { if (i == storage.end()) {
return false; return false;
......
...@@ -109,5 +109,6 @@ void test_actor_lifetime() { ...@@ -109,5 +109,6 @@ void test_actor_lifetime() {
int main() { int main() {
CAF_TEST(test_actor_lifetime); CAF_TEST(test_actor_lifetime);
test_actor_lifetime(); test_actor_lifetime();
shutdown();
return CAF_TEST_RESULT(); return CAF_TEST_RESULT();
} }
...@@ -115,5 +115,6 @@ int main() { ...@@ -115,5 +115,6 @@ int main() {
others >> CAF_UNEXPECTED_MSG_CB_REF(self) others >> CAF_UNEXPECTED_MSG_CB_REF(self)
); );
test_typed_atom_interface(); test_typed_atom_interface();
shutdown();
return CAF_TEST_RESULT(); return CAF_TEST_RESULT();
} }
...@@ -56,5 +56,6 @@ void test_constructor_attach() { ...@@ -56,5 +56,6 @@ void test_constructor_attach() {
int main() { int main() {
CAF_TEST(test_constructor_attach); CAF_TEST(test_constructor_attach);
test_constructor_attach(); test_constructor_attach();
shutdown();
return CAF_TEST_RESULT(); return CAF_TEST_RESULT();
} }
...@@ -73,5 +73,6 @@ void test_custom_exception_handler() { ...@@ -73,5 +73,6 @@ void test_custom_exception_handler() {
int main() { int main() {
CAF_TEST(test_custom_exception_handler); CAF_TEST(test_custom_exception_handler);
test_custom_exception_handler(); test_custom_exception_handler();
shutdown();
return CAF_TEST_RESULT(); return CAF_TEST_RESULT();
} }
...@@ -59,5 +59,6 @@ void test_either() { ...@@ -59,5 +59,6 @@ void test_either() {
int main() { int main() {
CAF_TEST(test_either); CAF_TEST(test_either);
test_either(); test_either();
shutdown();
return CAF_TEST_RESULT(); return CAF_TEST_RESULT();
} }
...@@ -104,5 +104,6 @@ void test_fixed_stack_actor() { ...@@ -104,5 +104,6 @@ void test_fixed_stack_actor() {
int main() { int main() {
CAF_TEST(test_fixed_stack_actor); CAF_TEST(test_fixed_stack_actor);
test_fixed_stack_actor(); test_fixed_stack_actor();
shutdown();
return CAF_TEST_RESULT(); return CAF_TEST_RESULT();
} }
...@@ -57,5 +57,6 @@ int main() { ...@@ -57,5 +57,6 @@ int main() {
CAF_CHECK_EQUAL(vec7.size(), 5); CAF_CHECK_EQUAL(vec7.size(), 5);
CAF_CHECK((std::all_of(vec7.begin(), vec7.end(), CAF_CHECK((std::all_of(vec7.begin(), vec7.end(),
[](int i) { return i == 0; }))); [](int i) { return i == 0; })));
caf::shutdown();
return CAF_TEST_RESULT(); return CAF_TEST_RESULT();
} }
...@@ -206,5 +206,6 @@ int main() { ...@@ -206,5 +206,6 @@ int main() {
test_recursive_invoke_from_cache<policy::prioritizing>(); test_recursive_invoke_from_cache<policy::prioritizing>();
CAF_PRINT("test_recursive_invoke_from_cache<policy::not_prioritizing>"); CAF_PRINT("test_recursive_invoke_from_cache<policy::not_prioritizing>");
test_recursive_invoke_from_cache<policy::not_prioritizing>(); test_recursive_invoke_from_cache<policy::not_prioritizing>();
shutdown();
return CAF_TEST_RESULT(); return CAF_TEST_RESULT();
} }
...@@ -123,5 +123,6 @@ int main() { ...@@ -123,5 +123,6 @@ int main() {
} }
CAF_CHECK_EQUAL(class0_instances, 0); CAF_CHECK_EQUAL(class0_instances, 0);
CAF_CHECK_EQUAL(class1_instances, 0); CAF_CHECK_EQUAL(class1_instances, 0);
shutdown();
return CAF_TEST_RESULT(); return CAF_TEST_RESULT();
} }
...@@ -179,5 +179,6 @@ int main() { ...@@ -179,5 +179,6 @@ int main() {
test_atoms(); test_atoms();
test_custom_projections(); test_custom_projections();
test_arg_match(); test_arg_match();
shutdown();
return CAF_TEST_RESULT(); return CAF_TEST_RESULT();
} }
...@@ -116,5 +116,6 @@ int main() { ...@@ -116,5 +116,6 @@ int main() {
test_extract3(); test_extract3();
test_extract_opts(); test_extract_opts();
test_type_token(); test_type_token();
shutdown();
return CAF_TEST_RESULT(); return CAF_TEST_RESULT();
} }
...@@ -75,6 +75,6 @@ int main() { ...@@ -75,6 +75,6 @@ int main() {
CAF_CHECK((tl_is_strict_subset<list_a, list_a>::value)); CAF_CHECK((tl_is_strict_subset<list_a, list_a>::value));
CAF_CHECK((tl_is_strict_subset<list_b, list_b>::value)); CAF_CHECK((tl_is_strict_subset<list_b, list_b>::value));
} }
shutdown();
return CAF_TEST_RESULT(); return CAF_TEST_RESULT();
} }
...@@ -49,6 +49,7 @@ int main() { ...@@ -49,6 +49,7 @@ int main() {
CAF_CHECK(!j.empty()); CAF_CHECK(!j.empty());
} }
} }
shutdown();
return CAF_TEST_RESULT(); return CAF_TEST_RESULT();
} }
...@@ -53,5 +53,6 @@ void test_or_else() { ...@@ -53,5 +53,6 @@ void test_or_else() {
int main() { int main() {
CAF_TEST(test_or_else); CAF_TEST(test_or_else);
test_or_else(); test_or_else();
shutdown();
return CAF_TEST_RESULT(); return CAF_TEST_RESULT();
} }
...@@ -13,11 +13,9 @@ std::string str_hash(const std::string& what) { ...@@ -13,11 +13,9 @@ std::string str_hash(const std::string& what) {
std::array<uint8_t, 20> hash; std::array<uint8_t, 20> hash;
ripemd_160(hash, what); ripemd_160(hash, what);
std::ostringstream oss; std::ostringstream oss;
oss << std::hex; oss << std::setfill('0') << std::hex;
for (auto i : hash) { for (auto i : hash) {
oss.width(2); oss << std::setw(2) << static_cast<int>(i);
oss.fill('0');
oss << static_cast<uint32_t>(i);
} }
return oss.str(); return oss.str();
} }
...@@ -28,34 +26,22 @@ std::string str_hash(const std::string& what) { ...@@ -28,34 +26,22 @@ std::string str_hash(const std::string& what) {
// http://homes.esat.kuleuven.be/~bosselae/ripemd160.html // http://homes.esat.kuleuven.be/~bosselae/ripemd160.html
int main() { int main() {
CAF_TEST(test_ripemd_160); CAF_TEST(test_ripemd_160);
CAF_CHECK_EQUAL("9c1185a5c5e9fc54612808977ee8f548b2258d31", str_hash("")); CAF_CHECK_EQUAL("9c1185a5c5e9fc54612808977ee8f548b2258d31", str_hash(""));
CAF_CHECK_EQUAL("0bdc9d2d256b3ee9daae347be6f4dc835a467ffe", str_hash("a")); CAF_CHECK_EQUAL("0bdc9d2d256b3ee9daae347be6f4dc835a467ffe", str_hash("a"));
CAF_CHECK_EQUAL("8eb208f7e05d987a9b044a8e98c6b087f15a0bfc", str_hash("abc"));
CAF_CHECK_EQUAL("8eb208f7e05d987a9b044a8e98c6b087f15a0bfc",
str_hash("abc"));
CAF_CHECK_EQUAL("5d0689ef49d2fae572b881b123a85ffa21595f36", CAF_CHECK_EQUAL("5d0689ef49d2fae572b881b123a85ffa21595f36",
str_hash("message digest")); str_hash("message digest"));
CAF_CHECK_EQUAL("f71c27109c692c1b56bbdceb5b9d2865b3708dbc", CAF_CHECK_EQUAL("f71c27109c692c1b56bbdceb5b9d2865b3708dbc",
str_hash("abcdefghijklmnopqrstuvwxyz")); str_hash("abcdefghijklmnopqrstuvwxyz"));
CAF_CHECK_EQUAL("12a053384a9c0c88e405a06c27dcf49ada62eb2b", CAF_CHECK_EQUAL("12a053384a9c0c88e405a06c27dcf49ada62eb2b",
str_hash( str_hash("abcdbcdecdefdefgefghfghighij"
"abcdbcdecdefdefgefghfghighij"
"hijkijkljklmklmnlmnomnopnopq")); "hijkijkljklmklmnlmnomnopnopq"));
CAF_CHECK_EQUAL("b0e20b6e3116640286ed3a87a5713079b21f5189", CAF_CHECK_EQUAL("b0e20b6e3116640286ed3a87a5713079b21f5189",
str_hash( str_hash("ABCDEFGHIJKLMNOPQRSTUVWXYZabcde"
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcde"
"fghijklmnopqrstuvwxyz0123456789")); "fghijklmnopqrstuvwxyz0123456789"));
CAF_CHECK_EQUAL("9b752e45573d4b39f4dbd3323cab82bf63326bfb", CAF_CHECK_EQUAL("9b752e45573d4b39f4dbd3323cab82bf63326bfb",
str_hash( str_hash("1234567890123456789012345678901234567890"
"1234567890123456789012345678901234567890"
"1234567890123456789012345678901234567890")); "1234567890123456789012345678901234567890"));
caf::shutdown();
return CAF_TEST_RESULT(); return CAF_TEST_RESULT();
} }
...@@ -73,5 +73,6 @@ void test_serial_reply() { ...@@ -73,5 +73,6 @@ void test_serial_reply() {
int main() { int main() {
CAF_TEST(test_serial_reply); CAF_TEST(test_serial_reply);
test_serial_reply(); test_serial_reply();
shutdown();
return CAF_TEST_RESULT(); return CAF_TEST_RESULT();
} }
...@@ -307,5 +307,6 @@ int main() { ...@@ -307,5 +307,6 @@ int main() {
} }
catch (std::exception& e) { CAF_FAILURE(to_verbose_string(e)); } catch (std::exception& e) { CAF_FAILURE(to_verbose_string(e)); }
*/ */
shutdown();
return CAF_TEST_RESULT(); return CAF_TEST_RESULT();
} }
...@@ -27,5 +27,6 @@ void test_simple_reply_response() { ...@@ -27,5 +27,6 @@ void test_simple_reply_response() {
int main() { int main() {
CAF_TEST(test_simple_reply_response); CAF_TEST(test_simple_reply_response);
test_simple_reply_response(); test_simple_reply_response();
shutdown();
return CAF_TEST_RESULT(); return CAF_TEST_RESULT();
} }
...@@ -406,5 +406,6 @@ int main() { ...@@ -406,5 +406,6 @@ int main() {
test_sync_send(); test_sync_send();
await_all_actors_done(); await_all_actors_done();
CAF_CHECKPOINT(); CAF_CHECKPOINT();
shutdown();
return CAF_TEST_RESULT(); return CAF_TEST_RESULT();
} }
...@@ -345,6 +345,6 @@ int main() { ...@@ -345,6 +345,6 @@ int main() {
test_sending_typed_actors_and_down_msg(); test_sending_typed_actors_and_down_msg();
await_all_actors_done(); await_all_actors_done();
CAF_CHECKPOINT(); CAF_CHECKPOINT();
// call it a day shutdown();
return CAF_TEST_RESULT(); return CAF_TEST_RESULT();
} }
...@@ -25,5 +25,6 @@ int main() { ...@@ -25,5 +25,6 @@ int main() {
CAF_CHECK_EQUAL(apply_visitor(tv, v2), "42"); CAF_CHECK_EQUAL(apply_visitor(tv, v2), "42");
v2 = 0.2f; v2 = 0.2f;
CAF_CHECK_EQUAL(apply_visitor(tv, v2), std::to_string(0.2f)); CAF_CHECK_EQUAL(apply_visitor(tv, v2), std::to_string(0.2f));
shutdown();
return CAF_TEST_RESULT(); return CAF_TEST_RESULT();
} }
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