From 025bedecfb2c264b1f3d6a04de72160001173cc1 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Tue, 19 Mar 2013 23:07:39 +0100 Subject: Refactored platform-specific code Moved functions from .h to .cpp files --- test/unit/app/system_linux_test.cpp | 51 +++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 test/unit/app/system_linux_test.cpp (limited to 'test/unit/app/system_linux_test.cpp') diff --git a/test/unit/app/system_linux_test.cpp b/test/unit/app/system_linux_test.cpp new file mode 100644 index 0000000..fe89399 --- /dev/null +++ b/test/unit/app/system_linux_test.cpp @@ -0,0 +1,51 @@ +#include "app/system.h" +#include "app/system_linux.h" + +#include + +TEST(SystemLinuxTest, TimeStampDiff) +{ + const long long SEC = 1000000000; + + SystemTimeStamp before, after; + + before.clockTime.tv_sec = 1; + before.clockTime.tv_nsec = 100; + + after.clockTime.tv_sec = 1; + after.clockTime.tv_nsec = 900; + + long long tDiff = TimeStampExactDiff_Linux(&before, &after); + EXPECT_EQ( 800, tDiff); + + tDiff = TimeStampExactDiff_Linux(&after, &before); + EXPECT_EQ(-800, tDiff); + + // ------- + + before.clockTime.tv_sec = 2; + before.clockTime.tv_nsec = 200; + + after.clockTime.tv_sec = 3; + after.clockTime.tv_nsec = 500; + + tDiff = TimeStampExactDiff_Linux(&before, &after); + EXPECT_EQ( SEC + 300, tDiff); + + tDiff = TimeStampExactDiff_Linux(&after, &before); + EXPECT_EQ(-SEC - 300, tDiff); + + // ------- + + before.clockTime.tv_sec = 3; + before.clockTime.tv_nsec = 200; + + after.clockTime.tv_sec = 4; + after.clockTime.tv_nsec = 100; + + tDiff = TimeStampExactDiff_Linux(&before, &after); + EXPECT_EQ( SEC - 100, tDiff); + + tDiff = TimeStampExactDiff_Linux(&after, &before); + EXPECT_EQ(-SEC + 100, tDiff); +} -- cgit v1.2.3-1-g7c22