Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oir committed Nov 26, 2023
1 parent 6e4568b commit afd037b
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,30 @@ TEMPLATE_LIST_TEST_CASE("Counter", "[counter]", ProgressTypeList) {
CHECK(counts.back() == expected);
}

TEST_CASE("Decreasing counter", "[counter]") {
std::stringstream out;
int amount = 101;

auto ctr = Counter(&amount, out).message("Doing things").interval(0.01);
ctr.show();

for (size_t i = 0; i < 101; i++) {
std::this_thread::sleep_for(1.3ms);
amount--;
}
ctr.done();

auto parts = check_and_get_parts(out.str());
auto counts = extract_counts<int>("Doing things ", parts);

for (size_t i = 1; i < counts.size(); i++) {
CHECK(counts[i] <= counts[i - 1]);
}

// Final result should always be displayed
CHECK(counts.back() == 0);
}

template <typename Display>
Display factory_helper();

Expand Down

0 comments on commit afd037b

Please sign in to comment.