EASTLFormatters testing
Bigfoot / Sonarqube (push) Skipped
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: toolmode) (push) Successful in 39s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: ON, Variant: toolmode) (push) Successful in 25s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: game) (push) Successful in 59s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: game) (push) Successful in 47s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: game) (push) Successful in 49s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: toolmode) (push) Successful in 1m7s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: toolmode) (push) Successful in 52s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: game) (push) Successful in 29s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: ON, Variant: game) (push) Successful in 24s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: toolmode) (push) Successful in 48s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: ON, Variant: toolmode) (push) Successful in 40s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: game) (push) Successful in 36s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: ON, Variant: game) (push) Successful in 25s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: toolmode) (push) Successful in 1m3s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: toolmode) (push) Successful in 50s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: game) (push) Successful in 35s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: ON, Variant: game) (push) Successful in 26s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: toolmode) (push) Successful in 42s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: ON, Variant: toolmode) (push) Successful in 28s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: game) (push) Successful in 59s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: game) (push) Successful in 43s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: game) (push) Successful in 38s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: toolmode) (push) Successful in 49s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: toolmode) (push) Successful in 43s
Bigfoot / Clang Format Checks (push) Successful in 10s

This commit is contained in:
2026-08-30 13:29:54 +02:00
parent 47d58a0e4c
commit b2a9a9209e
+128
View File
@@ -0,0 +1,128 @@
/*********************************************************************
* \file EASTLFormatters.cpp
*
* \author Romain BOULLARD
* \date August 2026
*********************************************************************/
#include <Utils/Log/EASTLFormatters.hpp>
#include <Utils/Log/LogMacros.hpp>
#include <Utils/Singleton.hpp>
#include <UtilsTests/UtilsTestsLogger_generated.hpp>
#include <EASTL/string.h>
#include <EASTL/string_view.h>
#include <EASTL/vector.h>
#include <fmt/format.h>
#include <gtest/gtest.h>
#include <fstream>
#include <sstream>
namespace Bigfoot
{
class EASTLFormattersFixture: public ::testing::Test
{
};
/****************************************************************************************/
TEST_F(EASTLFormattersFixture, FormatsEastlString)
{
const eastl::string value = "Hello";
EXPECT_EQ(fmt::format("{}", value), "Hello");
}
/****************************************************************************************/
TEST_F(EASTLFormattersFixture, FormatsEastlStringView)
{
const eastl::string_view value = "Hello";
EXPECT_EQ(fmt::format("{}", value), "Hello");
}
/****************************************************************************************/
TEST_F(EASTLFormattersFixture, FormatsEmptyVectorAsEmptyBrackets)
{
const eastl::vector<int> value;
EXPECT_EQ(fmt::format("{}", value), "[]");
}
/****************************************************************************************/
TEST_F(EASTLFormattersFixture, FormatsSingleElementVectorWithoutASeparator)
{
const eastl::vector<int> value {42};
EXPECT_EQ(fmt::format("{}", value), "[42]");
}
/****************************************************************************************/
TEST_F(EASTLFormattersFixture, FormatsVectorOfIntsCommaSeparated)
{
const eastl::vector<int> value {1, 2, 3};
EXPECT_EQ(fmt::format("{}", value), "[1, 2, 3]");
}
/****************************************************************************************/
TEST_F(EASTLFormattersFixture, FormatsVectorOfEastlStrings)
{
const eastl::vector<eastl::string> value {"a", "b"};
EXPECT_EQ(fmt::format("{}", value), "[a, b]");
}
/****************************************************************************************/
TEST_F(EASTLFormattersFixture, FormatsNestedVectors)
{
const eastl::vector<eastl::vector<int>> value {{1, 2}, {3}};
EXPECT_EQ(fmt::format("{}", value), "[[1, 2], [3]]");
}
/****************************************************************************************/
#if defined BIGFOOT_NOT_OPTIMIZED
class EASTLFormattersLogFixture: public ::testing::Test
{
protected:
eastl::string ReadFileSinkContent()
{
Singleton<Log>::GetInstance().Flush();
std::ifstream file {std::string {Log::FILE_SINK_PATH.data()}};
std::stringstream buffer;
buffer << file.rdbuf();
return eastl::string {buffer.str().c_str()};
}
};
/****************************************************************************************/
TEST_F(EASTLFormattersLogFixture, LogsEastlStringArgument)
{
const eastl::string value = "Hello EASTL string";
BIGFOOT_LOG_INFO(UTILSTESTS_LOGGER, "{}", value);
EXPECT_NE(ReadFileSinkContent().find("Hello EASTL string"), eastl::string::npos);
}
/****************************************************************************************/
TEST_F(EASTLFormattersLogFixture, LogsEmptyVectorArgument)
{
const eastl::vector<int> value;
BIGFOOT_LOG_INFO(UTILSTESTS_LOGGER, "{}", value);
EXPECT_NE(ReadFileSinkContent().find("[]"), eastl::string::npos);
}
/****************************************************************************************/
TEST_F(EASTLFormattersLogFixture, LogsVectorArgumentWithCommaSeparators)
{
const eastl::vector<eastl::string> value {"a", "b", "c"};
BIGFOOT_LOG_INFO(UTILSTESTS_LOGGER, "{}", value);
EXPECT_NE(ReadFileSinkContent().find("[a, b, c]"), eastl::string::npos);
}
#endif
} // namespace Bigfoot