Skip to content

Commit

Permalink
[tests] Fixed tests when ENABLE_STDCXX_SYNC=ON
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsharabayko committed May 7, 2020
1 parent 3e0e7df commit 61763fa
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions test/test_sync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ using namespace srt::sync;

TEST(SyncDuration, BasicChecks)
{
const steady_clock::duration d;
const steady_clock::duration d = steady_clock::duration();

EXPECT_EQ(d.count(), 0);
EXPECT_TRUE(d == d); // operator==
Expand Down Expand Up @@ -63,7 +63,7 @@ TEST(SyncDuration, DurationFrom)

TEST(SyncDuration, RelOperators)
{
const steady_clock::duration a;
const steady_clock::duration a = steady_clock::duration();

EXPECT_EQ(a.count(), 0);
EXPECT_TRUE(a == a); // operator==
Expand Down Expand Up @@ -190,10 +190,11 @@ TEST(SyncTimePoint, RelOperators)
EXPECT_FALSE(a < b);
}

#ifndef ENABLE_STDCXX_SYNC
TEST(SyncTimePoint, OperatorMinus)
{
const int64_t delta = 1024;
const steady_clock::time_point a(numeric_limits<uint64_t>::max());
const steady_clock::time_point a(steady_clock::time_point::max());
const steady_clock::time_point b(numeric_limits<uint64_t>::max() - delta);
EXPECT_EQ((a - b).count(), delta);
EXPECT_EQ((b - a).count(), -delta);
Expand Down Expand Up @@ -254,6 +255,7 @@ TEST(SyncTimePoint, OperatorMinusEqDuration)
r -= steady_clock::duration(-delta);
EXPECT_EQ(r, a);
}
#endif

/*****************************************************************************/
/*
Expand Down Expand Up @@ -415,6 +417,28 @@ TEST(SyncEvent, WaitForNotifyAll)
cond.destroy();
}

/*****************************************************************************/
/*
* CThread tests
*/
/*****************************************************************************/

// void* thfunc(void* msduration)
// {
// srt::sync::SleepFor(milliseconds_from(*(int*)msduration));
// return NULL;
// }

// TEST(Sync, ThreadJoin)
// {
// CThread th;
// int mssleep = 500;
// SetThread(th, thfunc, &mssleep);
// EXPECT_TRUE(th.joinable()) << "joinable before join()";
// th.join();
// EXPECT_FALSE(th.joinable()) << "not joinable after join()";
// }

/*****************************************************************************/
/*
* FormatTime
Expand Down

0 comments on commit 61763fa

Please sign in to comment.