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

lestarch: fixing Fw::Time to allow comparisons across different time … #803

Merged
merged 2 commits into from
Jul 7, 2021
Merged
Show file tree
Hide file tree
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
8 changes: 6 additions & 2 deletions Fw/Time/Time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,14 @@ namespace Fw {
)
{
#if FW_USE_TIME_BASE
FW_ASSERT(time1.getTimeBase() == time2.getTimeBase(), time1.getTimeBase(), time2.getTimeBase() );
if (time1.getTimeBase() != time2.getTimeBase()) {
return INCOMPARABLE;
}
#endif
#if FW_USE_TIME_CONTEXT
FW_ASSERT(time1.getContext() == time2.getContext(), time1.getContext(), time2.getContext() );
if (time1.getContext() != time2.getContext()) {
return INCOMPARABLE;
}
#endif
const U32 s1 = time1.getSeconds();
const U32 s2 = time2.getSeconds();
Expand Down
3 changes: 2 additions & 1 deletion Fw/Time/Time.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ namespace Fw {
typedef enum {
LT = -1,
EQ = 0,
GT = 1
GT = 1,
INCOMPARABLE = 2
} Comparison;

//! \return time zero
Expand Down
7 changes: 7 additions & 0 deletions Fw/Time/test/ut/TimeTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ TEST(TimeTestNominal,CopyTest) {

}

TEST(TimeTestNominal,ZeroTimeEquality) {
Fw::Time time(TB_PROC_TIME,1,2);
ASSERT_NE(time, Fw::ZERO_TIME);
Fw::Time time2;
ASSERT_EQ(time2, Fw::ZERO_TIME);
}

int main(int argc, char* argv[]) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
Expand Down