stdex
Additional custom or not Standard C++ covered algorithms
Loading...
Searching...
No Matches
watchdog.cpp
1/*
2 SPDX-License-Identifier: MIT
3 Copyright © 2023-2024 Amebis
4*/
5
6#include "pch.hpp"
7
8using namespace std;
9#ifdef _WIN32
10using namespace Microsoft::VisualStudio::CppUnitTestFramework;
11#endif
12
13namespace UnitTests
14{
15 TEST_CLASS(watchdog)
16 {
17 public:
18 TEST_METHOD(test)
19 {
20 volatile bool wd_called = false;
22 std::chrono::milliseconds(100), [&] { wd_called = true; });
23 for (int i = 0; i < 100; ++i) {
24 std::this_thread::sleep_for(std::chrono::milliseconds(10));
25 Assert::IsFalse(wd_called);
26 wd.reset();
27 }
28 std::this_thread::sleep_for(std::chrono::milliseconds(300));
29 Assert::IsTrue(wd_called);
30 }
31 };
32}
Triggers callback if not reset frequently enough.
Definition watchdog.hpp:22