Skip to content

Commit

Permalink
Fix test result combiner, fix test endian, enable broadcaster tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
evoskuil committed Feb 17, 2024
1 parent eb77e24 commit b948af3
Show file tree
Hide file tree
Showing 6 changed files with 190 additions and 268 deletions.
76 changes: 38 additions & 38 deletions test/async/desubscriber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,24 @@ BOOST_AUTO_TEST_CASE(desubscriber__subscribe__stopped__subscriber_stopped)
std::pair<code, size_t> retry_result;
boost::asio::post(strand, [&]() NOEXCEPT
{
result |= is_zero(instance.size());
result |= !instance.subscribe([&](code value, size_t size) NOEXCEPT
result &= is_zero(instance.size());
result &= !instance.subscribe([&](code value, size_t size) NOEXCEPT
{
stop_result = { value, size };
return true;
}, 0);

result |= is_one(instance.size());
result &= is_one(instance.size());
instance.stop(ec, expected);

result |= is_zero(instance.size());
result |= (instance.subscribe([&](code value, size_t size) NOEXCEPT
result &= is_zero(instance.size());
result &= (instance.subscribe([&](code value, size_t size) NOEXCEPT
{
retry_result = { value, size };
return true;
}, 0) == error::subscriber_stopped);

result |= is_zero(instance.size());
result &= is_zero(instance.size());
});

pool.stop();
Expand All @@ -77,13 +77,13 @@ BOOST_AUTO_TEST_CASE(desubscriber__subscribe__exists__subscriber_exists)
std::pair<code, size_t> second_result;
boost::asio::post(strand, [&]() NOEXCEPT
{
result |= !instance.subscribe([&](code value, size_t size) NOEXCEPT
result &= !instance.subscribe([&](code value, size_t size) NOEXCEPT
{
first_result = { value, size };
return true;
}, 42);

result |= (instance.subscribe([&](code value, size_t size) NOEXCEPT
result &= (instance.subscribe([&](code value, size_t size) NOEXCEPT
{
second_result = { value, size };
return true;
Expand Down Expand Up @@ -116,24 +116,24 @@ BOOST_AUTO_TEST_CASE(desubscriber__subscribe__removed__expected)
std::pair<code, size_t> second_result;
boost::asio::post(strand, [&]() NOEXCEPT
{
result |= is_zero(instance.size());
result |= !instance.subscribe([&](code value, size_t size) NOEXCEPT
result &= is_zero(instance.size());
result &= !instance.subscribe([&](code value, size_t size) NOEXCEPT
{
first_result = { value, size };
return false;
}, 42);

instance.notify(ec1, expected1);

result |= !instance.subscribe([&](code value, size_t size) NOEXCEPT
result &= !instance.subscribe([&](code value, size_t size) NOEXCEPT
{
second_result = { value, size };
return true;
}, 42);

result |= is_one(instance.size());
result &= is_one(instance.size());
instance.stop(ec2, expected2);
result |= is_zero(instance.size());
result &= is_zero(instance.size());
});

pool.stop();
Expand All @@ -158,22 +158,22 @@ BOOST_AUTO_TEST_CASE(desubscriber__subscribe__unique__expected)
std::pair<code, size_t> second_result;
boost::asio::post(strand, [&]() NOEXCEPT
{
result |= is_zero(instance.size());
result |= !instance.subscribe([&](code value, size_t size) NOEXCEPT
result &= is_zero(instance.size());
result &= !instance.subscribe([&](code value, size_t size) NOEXCEPT
{
first_result = { value, size };
return true;
}, 42);

result |= !instance.subscribe([&](code value, size_t size) NOEXCEPT
result &= !instance.subscribe([&](code value, size_t size) NOEXCEPT
{
second_result = { value, size };
return true;
}, 99);

result |= (instance.size() == two);
result &= (instance.size() == two);
instance.stop(ec, expected);
result |= is_zero(instance.size());
result &= is_zero(instance.size());
});

pool.stop();
Expand All @@ -197,7 +197,7 @@ BOOST_AUTO_TEST_CASE(desubscriber__stop_default__once__expected)
std::pair<code, size_t> stop_result;
boost::asio::post(strand, [&]() NOEXCEPT
{
result |= !instance.subscribe([&](code value, size_t size) NOEXCEPT
result &= !instance.subscribe([&](code value, size_t size) NOEXCEPT
{
stop_result = { value, size };
return true;
Expand Down Expand Up @@ -225,7 +225,7 @@ BOOST_AUTO_TEST_CASE(desubscriber__stop__once__expected)
std::pair<code, size_t> stop_result;
boost::asio::post(strand, [&]() NOEXCEPT
{
result |= !instance.subscribe([&](code value, size_t size) NOEXCEPT
result &= !instance.subscribe([&](code value, size_t size) NOEXCEPT
{
stop_result = { value, size };
return true;
Expand Down Expand Up @@ -253,7 +253,7 @@ BOOST_AUTO_TEST_CASE(desubscriber__stop__twice__second_dropped)
std::pair<code, size_t> stop_result;
boost::asio::post(strand, [&]() NOEXCEPT
{
result |= !instance.subscribe([&](code value, size_t size) NOEXCEPT
result &= !instance.subscribe([&](code value, size_t size) NOEXCEPT
{
stop_result = { value, size };
return true;
Expand Down Expand Up @@ -285,7 +285,7 @@ BOOST_AUTO_TEST_CASE(desubscriber__notify__stopped__dropped)
std::pair<code, size_t> notify_result;
boost::asio::post(strand, [&]() NOEXCEPT
{
result |= !instance.subscribe([&](code value, size_t size) NOEXCEPT
result &= !instance.subscribe([&](code value, size_t size) NOEXCEPT
{
// Allow first and possible second notify, ignore stop.
if (++count != two) notify_result = { value, size };
Expand Down Expand Up @@ -317,7 +317,7 @@ BOOST_AUTO_TEST_CASE(desubscriber__notify__once__expected)
std::pair<code, size_t> notify_result;
boost::asio::post(strand, [&]() NOEXCEPT
{
result |= !instance.subscribe([&](code value, size_t size) NOEXCEPT
result &= !instance.subscribe([&](code value, size_t size) NOEXCEPT
{
if (is_one(++count)) notify_result = { value, size };
return true;
Expand Down Expand Up @@ -349,7 +349,7 @@ BOOST_AUTO_TEST_CASE(desubscriber__notify__twice_true__expected)
std::pair<code, size_t> notify_result;
boost::asio::post(strand, [&]() NOEXCEPT
{
result |= !instance.subscribe([&](code value, size_t size) NOEXCEPT
result &= !instance.subscribe([&](code value, size_t size) NOEXCEPT
{
// Exclude stop_default call.
if (++count <= two) notify_result = { value, size };
Expand Down Expand Up @@ -382,7 +382,7 @@ BOOST_AUTO_TEST_CASE(desubscriber__notify__twice_false__expected)
std::pair<code, size_t> notify_result;
boost::asio::post(strand, [&]() NOEXCEPT
{
result |= !instance.subscribe([&](code value, size_t size) NOEXCEPT
result &= !instance.subscribe([&](code value, size_t size) NOEXCEPT
{
notify_result = { value, size };
return false;
Expand Down Expand Up @@ -416,17 +416,17 @@ BOOST_AUTO_TEST_CASE(desubscriber__notify_one__stopped__dropped)
std::pair<code, size_t> notify_result;
boost::asio::post(strand, [&]() NOEXCEPT
{
result |= !instance.subscribe([&](code value, size_t size) NOEXCEPT
result &= !instance.subscribe([&](code value, size_t size) NOEXCEPT
{
// Allow first and possible second notify, ignore stop.
if (++count != two) notify_result = { value, size };
return true;
}, key);

result |= instance.notify_one(key, ec, expected);
result &= instance.notify_one(key, ec, expected);
instance.stop_default(error::address_blocked);

result |= !instance.notify_one(key, error::address_blocked, {});
result &= !instance.notify_one(key, error::address_blocked, {});
});

pool.stop();
Expand All @@ -449,14 +449,14 @@ BOOST_AUTO_TEST_CASE(desubscriber__notify_one__missing__false)
std::pair<code, size_t> notify_result{};
boost::asio::post(strand, [&]() NOEXCEPT
{
result |= !instance.subscribe([&](code value, size_t size) NOEXCEPT
result &= !instance.subscribe([&](code value, size_t size) NOEXCEPT
{
// Record only first notification.
if (is_one(++count)) notify_result = { value, size };
return true;
}, 99);

result |= !instance.notify_one(100, error::address_blocked, 21);
result &= !instance.notify_one(100, error::address_blocked, 21);

// First notification, and clears map.
instance.stop(ec, expected);
Expand All @@ -483,13 +483,13 @@ BOOST_AUTO_TEST_CASE(desubscriber__notify_one__once__expected)
std::pair<code, size_t> notify_result;
boost::asio::post(strand, [&]() NOEXCEPT
{
result |= !instance.subscribe([&](code value, size_t size) NOEXCEPT
result &= !instance.subscribe([&](code value, size_t size) NOEXCEPT
{
if (is_one(++count)) notify_result = { value, size };
return true;
}, key);

result |= instance.notify_one(key, ec, expected);
result &= instance.notify_one(key, ec, expected);

// Prevents unstopped assertion (uncleared).
instance.stop_default(error::address_blocked);
Expand All @@ -516,15 +516,15 @@ BOOST_AUTO_TEST_CASE(desubscriber__notify_one__twice_true__expected)
std::pair<code, size_t> notify_result;
boost::asio::post(strand, [&]() NOEXCEPT
{
result |= !instance.subscribe([&](code value, size_t size) NOEXCEPT
result &= !instance.subscribe([&](code value, size_t size) NOEXCEPT
{
// Exclude stop_default call.
if (++count <= two) notify_result = { value, size };
return true;
}, key);

result |= instance.notify_one(key, {}, {});
result |= instance.notify_one(key, ec, expected);
result &= instance.notify_one(key, {}, {});
result &= instance.notify_one(key, ec, expected);

// Prevents unstopped assertion (uncleared).
instance.stop_default(error::address_blocked);
Expand All @@ -550,14 +550,14 @@ BOOST_AUTO_TEST_CASE(desubscriber__notify_one__twice_false__expected)
std::pair<code, size_t> notify_result;
boost::asio::post(strand, [&]() NOEXCEPT
{
result |= !instance.subscribe([&](code value, size_t size) NOEXCEPT
result &= !instance.subscribe([&](code value, size_t size) NOEXCEPT
{
notify_result = { value, size };
return false;
}, key);

result |= instance.notify_one(key, ec, expected);
result |= !instance.notify_one(key, {}, {});
result &= instance.notify_one(key, ec, expected);
result &= !instance.notify_one(key, {}, {});

// Cleared by false return.
////instance.stop_default(error::address_blocked);
Expand Down
24 changes: 12 additions & 12 deletions test/async/subscriber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,22 @@ BOOST_AUTO_TEST_CASE(subscriber__subscribe__stopped__subscriber_stopped)
std::pair<code, size_t> retry_result;
boost::asio::post(strand, [&]() NOEXCEPT
{
result |= is_zero(instance.size());
result |= !instance.subscribe([&](code value, size_t size) NOEXCEPT
result &= is_zero(instance.size());
result &= !instance.subscribe([&](code value, size_t size) NOEXCEPT
{
stop_result = { value, size };
});

result |= is_one(instance.size());
result &= is_one(instance.size());
instance.stop(ec, expected);

result |= is_zero(instance.size());
result |= (instance.subscribe([&](code value, size_t size) NOEXCEPT
result &= is_zero(instance.size());
result &= (instance.subscribe([&](code value, size_t size) NOEXCEPT
{
retry_result = { value, size };
}) == error::subscriber_stopped);

result |= is_zero(instance.size());
result &= is_zero(instance.size());
});

pool.stop();
Expand All @@ -75,7 +75,7 @@ BOOST_AUTO_TEST_CASE(subscriber__stop_default__once__expected)
std::pair<code, size_t> stop_result;
boost::asio::post(strand, [&]() NOEXCEPT
{
result |= !instance.subscribe([&](code value, size_t size) NOEXCEPT
result &= !instance.subscribe([&](code value, size_t size) NOEXCEPT
{
stop_result = { value, size };
});
Expand Down Expand Up @@ -103,7 +103,7 @@ BOOST_AUTO_TEST_CASE(subscriber__stop__once__expected)
std::pair<code, size_t> stop_result;
boost::asio::post(strand, [&]() NOEXCEPT
{
result |= !instance.subscribe([&](code value, size_t size) NOEXCEPT
result &= !instance.subscribe([&](code value, size_t size) NOEXCEPT
{
stop_result = { value, size };
});
Expand Down Expand Up @@ -131,7 +131,7 @@ BOOST_AUTO_TEST_CASE(subscriber__stop__twice__second_dropped)
std::pair<code, size_t> stop_result;
boost::asio::post(strand, [&]() NOEXCEPT
{
result |= !instance.subscribe([&](code value, size_t size) NOEXCEPT
result &= !instance.subscribe([&](code value, size_t size) NOEXCEPT
{
stop_result = { value, size };
});
Expand Down Expand Up @@ -162,7 +162,7 @@ BOOST_AUTO_TEST_CASE(subscriber__notify__stopped__dropped)
std::pair<code, size_t> notify_result;
boost::asio::post(strand, [&]() NOEXCEPT
{
result |= !instance.subscribe([&](code value, size_t size) NOEXCEPT
result &= !instance.subscribe([&](code value, size_t size) NOEXCEPT
{
// Allow first and possible second notify, ignore stop.
if (++count != two) notify_result = { value, size };
Expand Down Expand Up @@ -194,7 +194,7 @@ BOOST_AUTO_TEST_CASE(subscriber__notify__once__expected)
std::pair<code, size_t> notify_result;
boost::asio::post(strand, [&]() NOEXCEPT
{
result |= !instance.subscribe([&](code value, size_t size) NOEXCEPT
result &= !instance.subscribe([&](code value, size_t size) NOEXCEPT
{
if (is_one(++count)) notify_result = { value, size };
});
Expand Down Expand Up @@ -226,7 +226,7 @@ BOOST_AUTO_TEST_CASE(subscriber__notify__twice__expected)
std::pair<code, size_t> notify_result;
boost::asio::post(strand, [&]() NOEXCEPT
{
result |= !instance.subscribe([&](code value, size_t size) NOEXCEPT
result &= !instance.subscribe([&](code value, size_t size) NOEXCEPT
{
// Exclude stop_default call.
if (++count <= two) notify_result = { value, size };
Expand Down
4 changes: 2 additions & 2 deletions test/log/tracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ BOOST_AUTO_TEST_CASE(tracker__construct__guarded__safe_expected_messages)
if (is_zero(count++))
{
const auto expected = std::string{ typeid(tracked).name() } + "(1)\n";
result |= (message == expected);
result &= (message == expected);
return true;
}
else
{
const auto expected = std::string{ typeid(tracked).name() } + "(0)~\n";
result |= (message == expected);
result &= (message == expected);
log_stopped.set_value(ec);
return false;
}
Expand Down
Loading

0 comments on commit b948af3

Please sign in to comment.