Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for the Time class in Fw #1736

Merged
merged 2 commits into from
Oct 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 24 additions & 7 deletions Fw/Time/test/ut/TimeTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,41 @@ TEST(TimeTestNominal,MathTest) {
Fw::Time time1;
Fw::Time time2;

// Try various operations

// Comparison
time1.set(1000,1000);
time2.set(4000,2000);
time2.set(1000,1000);
ASSERT_TRUE(time1 == time2);
ASSERT_TRUE(time1 >= time2);
ASSERT_TRUE(time1 <= time2);

// test add
time1.set(1000,1000);
time2.set(2000,1000);
ASSERT_TRUE(time1 != time2);
ASSERT_TRUE(time1 < time2);
ASSERT_TRUE(time1 <= time2);

time1.set(2000,1000);
time2.set(1000,1000);
ASSERT_TRUE(time1 > time2);
ASSERT_TRUE(time1 >= time2);

// test subtract
// Addition
time1.set(1000,1000);
time2.set(4000,2000);
Fw::Time time_sum = Fw::Time::add(time1,time2);
ASSERT_EQ(time_sum.m_seconds,5000);
ASSERT_EQ(time_sum.m_useconds,3000);

// normal subtract
// Normal subtraction
time1.set(1000,1000);
time2.set(4000,2000);
Fw::Time time3 = Fw::Time::sub(time2,time1);
ASSERT_EQ(time3.m_timeBase,TB_NONE);
ASSERT_EQ(time3.m_timeContext,0);
ASSERT_EQ(time3.m_seconds,3000);
ASSERT_EQ(time3.m_useconds,1000);

// rollover subtract
// Rollover subtraction
time1.set(1,999999);
time2.set(2,000001);
time3 = Fw::Time::sub(time2,time1);
Expand Down