SonarQube Pass #3

Merged
rboullard merged 4 commits from SonarQube-pass into Development 2026-09-02 00:01:33 +00:00
5 changed files with 87 additions and 3 deletions
Showing only changes of commit e5da2a3000 - Show all commits
@@ -168,6 +168,20 @@ TEST_F(AssetContainerFixture, Insert_ShouldReturnAHandleWithTheInsertedAsset)
/****************************************************************************************/
TEST_F(AssetContainerFixture, Insert_ShouldReuseTheExistingHandleWhenInsertingAnAssetWithAnAlreadyExistingUUID)
{
ContainerHandle* const firstHandle = m_containerA.Insert();
const AssetBase* const firstAsset = firstHandle->GetAsset();
const eastl::vector<std::byte> packed = firstAsset->Pack();
ContainerHandle* const secondHandle = m_containerA.Insert(packed);
EXPECT_EQ(secondHandle, firstHandle);
EXPECT_EQ(secondHandle->GetAsset(), firstAsset);
}
/****************************************************************************************/
TEST_F(AssetContainerFixture, Remove_ShouldRemoveTheAsset)
{
const ContainerHandle* handle = m_containerA.Insert();
@@ -91,7 +91,13 @@ class SerializationManagerFixture: public ::testing::Test
multiRootB.GetAsset().ref_a = HardReference<AssetA> {m_sharedChildUUID};
m_multiRootBUUID = multiRootB.GetHeader().uuid;
Populate({&leaf, &middle, &root, &cycleX, &cycleY, &sharedChild, &multiRootA, &multiRootB});
// missingRef --> unsavedUUID (never persisted to the data accessor)
AssetB missingRef;
missingRef.SetName("missingRef");
missingRef.GetAsset().ref_a = HardReference<AssetA> {m_unsavedUUID};
m_missingRefUUID = missingRef.GetHeader().uuid;
Populate({&leaf, &middle, &root, &cycleX, &cycleY, &sharedChild, &multiRootA, &multiRootB, &missingRef});
m_leafFlatbuffer = leaf.Pack();
m_middleFlatbuffer = middle.Pack();
@@ -99,6 +105,7 @@ class SerializationManagerFixture: public ::testing::Test
m_sharedChildFlatbuffer = sharedChild.Pack();
m_multiRootAFlatbuffer = multiRootA.Pack();
m_multiRootBFlatbuffer = multiRootB.Pack();
m_missingRefFlatbuffer = missingRef.Pack();
}
void TearDown() override
@@ -200,6 +207,11 @@ class SerializationManagerFixture: public ::testing::Test
UUID m_multiRootBUUID;
eastl::vector<std::byte> m_multiRootBFlatbuffer;
// HardReferences an asset that is never saved to the data accessor
const UUID m_unsavedUUID;
UUID m_missingRefUUID;
eastl::vector<std::byte> m_missingRefFlatbuffer;
#ifdef BIGFOOT_TOOLMODE
eastl::optional<BigFile> m_bigFile;
#elif defined BIGFOOT_GAME
@@ -278,6 +290,37 @@ TEST_F(SerializationManagerFixture, LoadAsset_ShouldNotReloadAnAssetThatIsAlread
/****************************************************************************************/
TEST_F(SerializationManagerFixture, LoadAssets_ShouldNotFailWhenTheSameRootIsPassedTwice)
{
const HardReference<AssetA> leafRef {m_leafUUID};
ASSERT_EQ(leafRef.Get(), nullptr);
const eastl::array<UUID, 2> roots {m_leafUUID, m_leafUUID};
SerializationManager::LoadAssets(roots);
ASSERT_NE(leafRef.Get(), nullptr);
EXPECT_EQ(leafRef.Get()->Pack(), m_leafFlatbuffer);
}
/****************************************************************************************/
TEST_F(SerializationManagerFixture, LoadAsset_ShouldSkipHardReferencesThatCouldNotBeFound)
{
const HardReference<AssetB> missingRefRef {m_missingRefUUID};
const HardReference<AssetA> unsavedRef {m_unsavedUUID};
ASSERT_EQ(missingRefRef.Get(), nullptr);
ASSERT_EQ(unsavedRef.Get(), nullptr);
SerializationManager::LoadAsset(m_missingRefUUID);
ASSERT_NE(missingRefRef.Get(), nullptr);
EXPECT_EQ(missingRefRef.Get()->Pack(), m_missingRefFlatbuffer);
EXPECT_EQ(unsavedRef.Get(), nullptr);
}
/****************************************************************************************/
TEST_F(SerializationManagerFixture, LoadAssets_ShouldLoadEveryRootAndMergeSharedHardReferences)
{
const HardReference<AssetA> sharedChildRef {m_sharedChildUUID};
+11
View File
@@ -16,10 +16,21 @@ 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);
+7
View File
@@ -173,6 +173,13 @@ TEST_F(UUIDFixture, GeneratingFiveMillionUniqueID)
/****************************************************************************************/
TEST_F(UUIDFixture, LessThanOperator_ShouldOrderTwoDifferentIDsConsistently)
{
EXPECT_LT(UUID::NULL_UUID, m_b);
}
/****************************************************************************************/
TEST_F(UUIDFixture, ToBytes_ShouldGiveBackTheRawDataOfTheID)
{
std::span<const std::byte, UUID::UUID_BYTE_SIZE> idBytes = m_d.ToBytes();
+11 -2
View File
@@ -88,8 +88,17 @@ TEST_F(LogFixture, ChangeLoggerLogLevel_ShouldChangeTheLoggerLogLevel)
const quill::Logger* logger = Singleton<Log>::GetInstance().RegisterLogger(UTILSTESTS_LOGGER);
Singleton<Log>::GetInstance().ChangeLoggerLogLevel(UTILSTESTS_LOGGER, Flat::LogLevel::Critical);
EXPECT_EQ(QuillLogLevelToLogLevel(logger->get_log_level()), Flat::LogLevel::Critical);
for (const Flat::LogLevel level: {Flat::LogLevel::Debug,
Flat::LogLevel::Trace,
Flat::LogLevel::Info,
Flat::LogLevel::Warn,
Flat::LogLevel::Error,
Flat::LogLevel::Critical})
{
Singleton<Log>::GetInstance().ChangeLoggerLogLevel(UTILSTESTS_LOGGER, level);
EXPECT_EQ(QuillLogLevelToLogLevel(logger->get_log_level()), level);
}
Singleton<Log>::GetInstance().ChangeLoggerLogLevel(UTILSTESTS_LOGGER, previous);
EXPECT_EQ(QuillLogLevelToLogLevel(logger->get_log_level()), previous);
}