Skip to content

Commit

Permalink
pqu: add DEBUG tests, empty()
Browse files Browse the repository at this point in the history
c++ has no clear nor equal ops.
fix DEBUG compilation.
  • Loading branch information
rurban committed Feb 16, 2024
1 parent 8c24174 commit ce678b3
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion tests/func/test_priority_queue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,29 @@ OLD_MAIN
TEST(EMPLACE) \
TEST(SWAP)

#define FOREACH_DEBUG(TEST) \
TEST(EMPTY)

#define GENERATE_ENUM(x) TEST_##x,
#define GENERATE_NAME(x) #x,

// clang-format off
enum
{
FOREACH_METH(GENERATE_ENUM)
#ifdef DEBUG
FOREACH_DEBUG(GENERATE_ENUM)
#endif
TEST_TOTAL
};
static const int number_ok = (int)TEST_TOTAL;
#ifdef DEBUG
static const char *test_names[] = {FOREACH_METH(GENERATE_NAME) FOREACH_DEBUG(GENERATE_NAME) ""};
static const char *test_names[] = {
FOREACH_METH(GENERATE_NAME)
FOREACH_DEBUG(GENERATE_NAME)
""
};
// clang-format on

#define TEST_MAX_VALUE 100
#else
Expand Down Expand Up @@ -122,6 +134,24 @@ int main(void)
pqu_digi_emplace(&a, &v1);
break;
}
#ifdef DEBUG
case TEST_EMPTY: {
aa = pqu_digi_copy(&a);
while (aa.size > 0)
{
pqu_digi_pop(&aa);
}
bb = b;
while (bb.size() > 0)
{
bb.pop();
}
assert(!pqu_digi_empty(&a));
assert(pqu_digi_empty(&aa));
assert(b.empty());
pqu_digi_free(&aa);
}
#endif
}
CHECK(a, b);
pqu_digi_free(&a);
Expand Down

0 comments on commit ce678b3

Please sign in to comment.