mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-28 17:19:34 +08:00
clang format
This commit is contained in:
@@ -3,12 +3,10 @@
|
||||
using std::chrono::milliseconds;
|
||||
using test_clock = std::chrono::high_resolution_clock;
|
||||
|
||||
static milliseconds millis_from(const test_clock::time_point &tp0)
|
||||
{
|
||||
static milliseconds millis_from(const test_clock::time_point &tp0) {
|
||||
return std::chrono::duration_cast<milliseconds>(test_clock::now() - tp0);
|
||||
}
|
||||
TEST_CASE("dequeue-empty-nowait", "[mpmc_blocking_q]")
|
||||
{
|
||||
TEST_CASE("dequeue-empty-nowait", "[mpmc_blocking_q]") {
|
||||
size_t q_size = 100;
|
||||
milliseconds tolerance_wait(20);
|
||||
spdlog::details::mpmc_blocking_queue<int> q(q_size);
|
||||
@@ -23,8 +21,7 @@ TEST_CASE("dequeue-empty-nowait", "[mpmc_blocking_q]")
|
||||
REQUIRE(delta_ms <= tolerance_wait);
|
||||
}
|
||||
|
||||
TEST_CASE("dequeue-empty-wait", "[mpmc_blocking_q]")
|
||||
{
|
||||
TEST_CASE("dequeue-empty-wait", "[mpmc_blocking_q]") {
|
||||
|
||||
size_t q_size = 100;
|
||||
milliseconds wait_ms(250);
|
||||
@@ -43,8 +40,7 @@ TEST_CASE("dequeue-empty-wait", "[mpmc_blocking_q]")
|
||||
REQUIRE(delta_ms <= wait_ms + tolerance_wait);
|
||||
}
|
||||
|
||||
TEST_CASE("dequeue-full-nowait", "[mpmc_blocking_q]")
|
||||
{
|
||||
TEST_CASE("dequeue-full-nowait", "[mpmc_blocking_q]") {
|
||||
spdlog::details::mpmc_blocking_queue<int> q(1);
|
||||
q.enqueue(42);
|
||||
|
||||
@@ -53,8 +49,7 @@ TEST_CASE("dequeue-full-nowait", "[mpmc_blocking_q]")
|
||||
REQUIRE(item == 42);
|
||||
}
|
||||
|
||||
TEST_CASE("dequeue-full-wait", "[mpmc_blocking_q]")
|
||||
{
|
||||
TEST_CASE("dequeue-full-wait", "[mpmc_blocking_q]") {
|
||||
spdlog::details::mpmc_blocking_queue<int> q(1);
|
||||
q.enqueue(42);
|
||||
|
||||
@@ -63,8 +58,7 @@ TEST_CASE("dequeue-full-wait", "[mpmc_blocking_q]")
|
||||
REQUIRE(item == 42);
|
||||
}
|
||||
|
||||
TEST_CASE("enqueue_nowait", "[mpmc_blocking_q]")
|
||||
{
|
||||
TEST_CASE("enqueue_nowait", "[mpmc_blocking_q]") {
|
||||
|
||||
size_t q_size = 1;
|
||||
spdlog::details::mpmc_blocking_queue<int> q(q_size);
|
||||
@@ -82,8 +76,7 @@ TEST_CASE("enqueue_nowait", "[mpmc_blocking_q]")
|
||||
REQUIRE(q.overrun_counter() == 1);
|
||||
}
|
||||
|
||||
TEST_CASE("bad_queue", "[mpmc_blocking_q]")
|
||||
{
|
||||
TEST_CASE("bad_queue", "[mpmc_blocking_q]") {
|
||||
size_t q_size = 0;
|
||||
spdlog::details::mpmc_blocking_queue<int> q(q_size);
|
||||
q.enqueue_nowait(1);
|
||||
@@ -92,28 +85,25 @@ TEST_CASE("bad_queue", "[mpmc_blocking_q]")
|
||||
REQUIRE(q.dequeue_for(i, milliseconds(0)) == false);
|
||||
}
|
||||
|
||||
TEST_CASE("empty_queue", "[mpmc_blocking_q]")
|
||||
{
|
||||
TEST_CASE("empty_queue", "[mpmc_blocking_q]") {
|
||||
size_t q_size = 10;
|
||||
spdlog::details::mpmc_blocking_queue<int> q(q_size);
|
||||
int i = 0;
|
||||
REQUIRE(q.dequeue_for(i, milliseconds(10)) == false);
|
||||
}
|
||||
|
||||
TEST_CASE("full_queue", "[mpmc_blocking_q]")
|
||||
{
|
||||
TEST_CASE("full_queue", "[mpmc_blocking_q]") {
|
||||
size_t q_size = 100;
|
||||
spdlog::details::mpmc_blocking_queue<int> q(q_size);
|
||||
for (int i = 0; i < static_cast<int>(q_size); i++)
|
||||
{
|
||||
q.enqueue(i + 0); // i+0 to force rvalue and avoid tidy warnings on the same time if we std::move(i) instead
|
||||
for (int i = 0; i < static_cast<int>(q_size); i++) {
|
||||
q.enqueue(i + 0); // i+0 to force rvalue and avoid tidy warnings on the same time if we
|
||||
// std::move(i) instead
|
||||
}
|
||||
|
||||
q.enqueue_nowait(123456);
|
||||
REQUIRE(q.overrun_counter() == 1);
|
||||
|
||||
for (int i = 1; i < static_cast<int>(q_size); i++)
|
||||
{
|
||||
for (int i = 1; i < static_cast<int>(q_size); i++) {
|
||||
int item = -1;
|
||||
q.dequeue(item);
|
||||
REQUIRE(item == i);
|
||||
|
Reference in New Issue
Block a user