74 lines
2.1 KiB
C++
74 lines
2.1 KiB
C++
/*********************************************************************
|
|
* \file Version.cpp
|
|
*
|
|
* \author Romain BOULLARD
|
|
* \date October 2025
|
|
*********************************************************************/
|
|
#include <Utils/Version.hpp>
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
namespace Bigfoot
|
|
{
|
|
class VersionFixture: public ::testing::Test
|
|
{
|
|
protected:
|
|
const Version m_detailed {1, 2, 3};
|
|
const Version m_combined {(1 << 16) | (2 << 8) | 3};
|
|
};
|
|
|
|
/****************************************************************************************/
|
|
|
|
TEST_F(VersionFixture, string)
|
|
{
|
|
EXPECT_STREQ(static_cast<std::string>(m_detailed).data(), "1.2.3");
|
|
EXPECT_STREQ(static_cast<std::string>(m_combined).data(), "1.2.3");
|
|
}
|
|
|
|
/****************************************************************************************/
|
|
|
|
TEST_F(VersionFixture, uint32_t)
|
|
{
|
|
EXPECT_EQ(static_cast<std::uint32_t>(m_detailed), (1 << 16) | (2 << 8) | 3);
|
|
EXPECT_EQ(static_cast<std::uint32_t>(m_combined), (1 << 16) | (2 << 8) | 3);
|
|
}
|
|
|
|
/****************************************************************************************/
|
|
|
|
TEST_F(VersionFixture, Major_ShouldBeEqualToTheMajorPartOfTheVersion)
|
|
{
|
|
EXPECT_EQ(m_detailed.Major(), 1);
|
|
EXPECT_EQ(m_combined.Major(), 1);
|
|
}
|
|
|
|
/****************************************************************************************/
|
|
|
|
TEST_F(VersionFixture, Minor_ShouldBeEqualToTheMinorPartOfTheVersion)
|
|
{
|
|
EXPECT_EQ(m_detailed.Minor(), 2);
|
|
EXPECT_EQ(m_combined.Minor(), 2);
|
|
}
|
|
|
|
/****************************************************************************************/
|
|
|
|
TEST_F(VersionFixture, Patch_ShouldBeEqualToThePatchPartOfTheVersion)
|
|
{
|
|
EXPECT_EQ(m_detailed.Patch(), 3);
|
|
EXPECT_EQ(m_combined.Patch(), 3);
|
|
}
|
|
|
|
/****************************************************************************************/
|
|
|
|
TEST_F(VersionFixture, Comparisons)
|
|
{
|
|
constexpr Version other {2, 6, 4};
|
|
|
|
EXPECT_GT(other, m_detailed);
|
|
EXPECT_GE(other, other);
|
|
EXPECT_LT(m_detailed, other);
|
|
EXPECT_LE(other, other);
|
|
EXPECT_EQ(other, other);
|
|
EXPECT_NE(other, m_detailed);
|
|
}
|
|
} // namespace Bigfoot
|