Files
Bigfoot/Bigfoot/Tests/System/Time/Time.cpp
T
rboullard 33a79ed12f
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: game) (push) Successful in 46s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: ON, Variant: game) (push) Successful in 29s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: game) (push) Successful in 1m23s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: game) (push) Successful in 49s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: game) (push) Successful in 1m8s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: ON, Variant: toolmode) (push) Successful in 45s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: toolmode) (push) Successful in 1m8s
Bigfoot / Clang Format Checks (push) Successful in 13s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: toolmode) (push) Successful in 49s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: ON, Variant: toolmode) (push) Successful in 31s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: toolmode) (push) Successful in 1m30s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: game) (push) Successful in 1m3s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: toolmode) (push) Successful in 1m10s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: toolmode) (push) Successful in 56s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: ON, Variant: game) (push) Successful in 34s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: ON, Variant: toolmode) (push) Successful in 41s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: game) (push) Successful in 1m27s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: toolmode) (push) Successful in 1m35s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: toolmode) (push) Successful in 1m16s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: game) (push) Successful in 37s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: toolmode) (push) Successful in 56s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: ON, Variant: game) (push) Successful in 29s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: game) (push) Successful in 1m2s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: game) (push) Successful in 53s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: toolmode) (push) Successful in 1m3s
Bigfoot / Sonarqube (game) (push) Successful in 5m17s
Bigfoot / Sonarqube (toolmode) (push) Successful in 5m39s
Game analysis for SonarQube (#5)
Reviewed-on: #5
Co-authored-by: Romain BOULLARD <romain.boullard@protonmail.com>
2026-09-02 13:55:27 +00:00

97 lines
2.6 KiB
C++

/*********************************************************************
* \file Time.cpp
*
* \author Romain BOULLARD
* \date December 2025
*********************************************************************/
#include <System/Time/Time.hpp>
#include <System/Time/Time_generated.hpp>
#include <gtest/gtest.h>
namespace Bigfoot
{
class TimeFixture: public ::testing::Test
{
public:
Time m_time {1'767'643'746'680'609};
Time m_earlierTime {1'767'643'746'680'608};
};
/****************************************************************************************/
TEST_F(TimeFixture, ComparisonOperators_ShouldOrderTimesByEpoch)
{
EXPECT_LT(m_earlierTime, m_time);
EXPECT_LE(m_earlierTime, m_time);
EXPECT_GT(m_time, m_earlierTime);
EXPECT_GE(m_time, m_earlierTime);
}
/****************************************************************************************/
TEST_F(TimeFixture, GetYear_ShouldReturnTheYear)
{
EXPECT_EQ(m_time.GetYear(), 2026);
}
/****************************************************************************************/
TEST_F(TimeFixture, GetMonth_ShouldReturnTheMonth)
{
EXPECT_EQ(m_time.GetMonth(), 1);
}
/****************************************************************************************/
TEST_F(TimeFixture, GetDay_ShouldReturnTheDay)
{
EXPECT_EQ(m_time.GetDay(), 5);
}
/****************************************************************************************/
TEST_F(TimeFixture, GetHour_ShouldReturnTheHour)
{
EXPECT_EQ(m_time.GetHour(), 20);
}
/****************************************************************************************/
TEST_F(TimeFixture, GetMinute_ShouldReturnTheMinute)
{
EXPECT_EQ(m_time.GetMinute(), 9);
}
/****************************************************************************************/
TEST_F(TimeFixture, GetSecond_ShouldReturnTheSecond)
{
EXPECT_EQ(m_time.GetSecond(), 6);
}
/****************************************************************************************/
TEST_F(TimeFixture, GetMicrosecond_ShouldReturnTheMicrosecond)
{
EXPECT_EQ(m_time.GetMicrosecond(), 680'609);
}
/****************************************************************************************/
TEST_F(TimeFixture, Pack_ShouldGiveAFlatTimeWithTheSameEpoch)
{
const ::Flat::Bigfoot::Time flatTime = flatbuffers::Pack(m_time);
EXPECT_EQ(flatTime.epoch(), m_time.GetEpoch());
}
/****************************************************************************************/
TEST_F(TimeFixture, UnPack_ShouldGiveBackTheOriginalTime)
{
const ::Flat::Bigfoot::Time flatTime = flatbuffers::Pack(m_time);
EXPECT_EQ(flatbuffers::UnPack(flatTime), m_time);
}
} // namespace Bigfoot