From 2abc107b24f73b8c4664189c34196d9a27a3e339 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 16 Jun 2018 18:05:00 +0200 Subject: Port the rest of the unittests to DGUnit and remove the CppUnit dependency. --- test/semaphoretest.cc | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'test/semaphoretest.cc') diff --git a/test/semaphoretest.cc b/test/semaphoretest.cc index 1c137c4..c99e9a6 100644 --- a/test/semaphoretest.cc +++ b/test/semaphoretest.cc @@ -24,7 +24,7 @@ * along with DrumGizmo; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#include +#include "dgunit.h" #include @@ -45,16 +45,15 @@ std::chrono::nanoseconds dist(const std::chrono::duration& a, } class SemaphoreTest - : public CppUnit::TestFixture + : public DGUnit { - CPPUNIT_TEST_SUITE(SemaphoreTest); - CPPUNIT_TEST(timeoutTest); - CPPUNIT_TEST_SUITE_END(); - public: - void setUp() {} - void tearDown() {} + SemaphoreTest() + { + DGUNIT_TEST(SemaphoreTest::timeoutTest); + } +public: void timeoutTest() { Semaphore sem(0); @@ -62,26 +61,26 @@ public: { // 1000ms timeout auto start = std::chrono::steady_clock::now(); bool res = sem.wait(std::chrono::milliseconds(1000)); - CPPUNIT_ASSERT(!res); // false means timeout + DGUNIT_ASSERT(!res); // false means timeout auto stop = std::chrono::steady_clock::now(); // Allow +/-1ms skew - CPPUNIT_ASSERT(dist((stop - start), std::chrono::milliseconds(1000)) + DGUNIT_ASSERT(dist((stop - start), std::chrono::milliseconds(1000)) < std::chrono::milliseconds(60)); } { // 100ms timeout auto start = std::chrono::steady_clock::now(); bool res = sem.wait(std::chrono::milliseconds(100)); - CPPUNIT_ASSERT(!res); // false means timeout + DGUNIT_ASSERT(!res); // false means timeout auto stop = std::chrono::steady_clock::now(); // Allow +/-1ms skew - CPPUNIT_ASSERT(dist((stop - start), std::chrono::milliseconds(100)) + DGUNIT_ASSERT(dist((stop - start), std::chrono::milliseconds(100)) < std::chrono::milliseconds(60)); } } }; // Registers the fixture into the 'registry' -CPPUNIT_TEST_SUITE_REGISTRATION(SemaphoreTest); +static SemaphoreTest test; -- cgit v1.2.3