aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Rusak <lorusak@gmail.com>2021-12-31 15:29:39 -0800
committerLukas Rusak <lorusak@gmail.com>2022-01-16 18:27:13 -0800
commit8a5174a9fd6391935e718e939d2731ee6f6c1fcc (patch)
treed7bb1ea0c915b65752874243864300d33a6d5107
parented51cd2245a87236ec603a2faf0530d34ebddedd (diff)
TestEndTime: add new test and template CommonTests
-rw-r--r--xbmc/threads/test/TestEndTime.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/xbmc/threads/test/TestEndTime.cpp b/xbmc/threads/test/TestEndTime.cpp
index 9351b9964e..c564b03b89 100644
--- a/xbmc/threads/test/TestEndTime.cpp
+++ b/xbmc/threads/test/TestEndTime.cpp
@@ -15,23 +15,24 @@ using namespace std::chrono_literals;
namespace
{
-void CommonTests(XbmcThreads::EndTime<>& endTime)
+template<typename T = std::chrono::milliseconds>
+void CommonTests(XbmcThreads::EndTime<T>& endTime)
{
EXPECT_EQ(100ms, endTime.GetInitialTimeoutValue());
- EXPECT_LT(0ms, endTime.GetStartTime().time_since_epoch());
+ EXPECT_LT(T::zero(), endTime.GetStartTime().time_since_epoch());
EXPECT_FALSE(endTime.IsTimePast());
- EXPECT_LT(0ms, endTime.GetTimeLeft());
+ EXPECT_LT(T::zero(), endTime.GetTimeLeft());
std::this_thread::sleep_for(100ms);
EXPECT_TRUE(endTime.IsTimePast());
- EXPECT_EQ(0ms, endTime.GetTimeLeft());
+ EXPECT_EQ(T::zero(), endTime.GetTimeLeft());
endTime.SetInfinite();
- EXPECT_EQ(std::chrono::milliseconds::max(), endTime.GetInitialTimeoutValue());
+ EXPECT_EQ(T::max(), endTime.GetInitialTimeoutValue());
endTime.SetExpired();
- EXPECT_EQ(0ms, endTime.GetInitialTimeoutValue());
+ EXPECT_EQ(T::zero(), endTime.GetInitialTimeoutValue());
}
} // namespace
@@ -50,3 +51,10 @@ TEST(TestEndTime, ExplicitConstructor)
CommonTests(endTime);
}
+
+TEST(TestEndTime, DoubleMicroSeconds)
+{
+ XbmcThreads::EndTime<std::chrono::duration<double, std::micro>> endTime(100ms);
+
+ CommonTests(endTime);
+}