Skip to content

Commit

Permalink
Add sleep of one clock-resolution to test which should trigger timeout
Browse files Browse the repository at this point in the history
Fixes doctest#711 under HPPA, and
partially under alpha.
  • Loading branch information
matoro committed Apr 15, 2023
1 parent 66ff54a commit a236f4f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions examples/all_features/test_cases_and_suites.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

#include "header.h"

DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN
#include <chrono>
#include <ctime>
#include <thread>
DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END

static int doStuff() {
int a = 5;
a += 2;
Expand Down Expand Up @@ -46,6 +52,11 @@ TEST_CASE_FIXTURE(SomeFixture, "fixtured test - not part of a test suite") {

TEST_CASE("normal test in a test suite from a decorator" * doctest::test_suite("ts1") *
doctest::timeout(0.000001)) {
#ifndef _WIN32
struct timespec res{};
clock_getres(CLOCK_MONOTONIC, &res);
std::this_thread::sleep_for(std::chrono::nanoseconds(res.tv_nsec));
#endif
MESSAGE("failing because of the timeout decorator!");
}

Expand Down

0 comments on commit a236f4f

Please sign in to comment.