From f780e6f59a28b632edff7904a099b5e8ccafdf86 Mon Sep 17 00:00:00 2001 From: Romain BOULLARD Date: Fri, 20 Feb 2026 21:01:49 +0100 Subject: [PATCH] Sanitizers --- Bin2CPP/Tests/Bin2CPPLib/Log.cpp | 56 +++++++++++++++++++++----- Bin2CPP/Tests/Bin2CPPLib/Singleton.cpp | 42 +++++++++++++++++-- ConanProfiles/clangd | 6 ++- 3 files changed, 88 insertions(+), 16 deletions(-) diff --git a/Bin2CPP/Tests/Bin2CPPLib/Log.cpp b/Bin2CPP/Tests/Bin2CPPLib/Log.cpp index 47dabe7..5cf401c 100644 --- a/Bin2CPP/Tests/Bin2CPPLib/Log.cpp +++ b/Bin2CPP/Tests/Bin2CPPLib/Log.cpp @@ -1,39 +1,73 @@ /********************************************************************* - * \file Singleton.cpp +* \file Log.cpp * * \author Romain BOULLARD * \date February 2026 *********************************************************************/ -#include +#include #include namespace Bin2CPP { -class SingletonFixture: public ::testing::Test +class LogFixture: public ::testing::Test { - protected: - Singleton::Lifetime m_lifetime{8}; +protected: + Log m_log; }; /****************************************************************************************/ -TEST_F(SingletonFixture, HasInstance_ShouldReturnTrueIfSingletonIsInitialized) +TEST_F(LogFixture, GetLogger_ShouldReturnTheLogger) { - EXPECT_TRUE(Singleton::HasInstance()); + EXPECT_TRUE(m_log.GetLogger()); } /****************************************************************************************/ -TEST_F(SingletonFixture, HasInstance_ShouldReturnFaleIfSingletonIsNotInitialized) +TEST_F(LogFixture, LogDebug) { - EXPECT_FALSE(Singleton::HasInstance()); + Singleton::Lifetime singletonLifetime; + BIN2CPP_LOG_DEBUG("Hello"); } /****************************************************************************************/ -TEST_F(SingletonFixture, Instance_ShouldReturnTheInstance) +TEST_F(LogFixture, LogTrace) { - EXPECT_EQ(Singleton::Instance(), 8); + Singleton::Lifetime singletonLifetime; + BIN2CPP_LOG_TRACE("Hello"); +} + +/****************************************************************************************/ + +TEST_F(LogFixture, LogInfo) +{ + Singleton::Lifetime singletonLifetime; + BIN2CPP_LOG_INFO("Hello"); +} + +/****************************************************************************************/ + +TEST_F(LogFixture, LogWarn) +{ + Singleton::Lifetime singletonLifetime; + BIN2CPP_LOG_WARN("Hello"); +} + +/****************************************************************************************/ + +TEST_F(LogFixture, LogError) +{ + Singleton::Lifetime singletonLifetime; + BIN2CPP_LOG_ERROR("Hello"); +} + +/****************************************************************************************/ + +TEST_F(LogFixture, LogFatal) +{ + Singleton::Lifetime singletonLifetime; + BIN2CPP_LOG_FATAL("Hello"); } } // namespace Bin2CPP diff --git a/Bin2CPP/Tests/Bin2CPPLib/Singleton.cpp b/Bin2CPP/Tests/Bin2CPPLib/Singleton.cpp index 32421e9..47dabe7 100644 --- a/Bin2CPP/Tests/Bin2CPPLib/Singleton.cpp +++ b/Bin2CPP/Tests/Bin2CPPLib/Singleton.cpp @@ -1,3 +1,39 @@ -// -// Created by romain on 16/02/2026. -// +/********************************************************************* + * \file Singleton.cpp + * + * \author Romain BOULLARD + * \date February 2026 + *********************************************************************/ +#include + +#include + +namespace Bin2CPP +{ +class SingletonFixture: public ::testing::Test +{ + protected: + Singleton::Lifetime m_lifetime{8}; +}; + +/****************************************************************************************/ + +TEST_F(SingletonFixture, HasInstance_ShouldReturnTrueIfSingletonIsInitialized) +{ + EXPECT_TRUE(Singleton::HasInstance()); +} + +/****************************************************************************************/ + +TEST_F(SingletonFixture, HasInstance_ShouldReturnFaleIfSingletonIsNotInitialized) +{ + EXPECT_FALSE(Singleton::HasInstance()); +} + +/****************************************************************************************/ + +TEST_F(SingletonFixture, Instance_ShouldReturnTheInstance) +{ + EXPECT_EQ(Singleton::Instance(), 8); +} +} // namespace Bin2CPP diff --git a/ConanProfiles/clangd b/ConanProfiles/clangd index d3bc840..cec5523 100644 --- a/ConanProfiles/clangd +++ b/ConanProfiles/clangd @@ -9,8 +9,10 @@ compiler.cstd=17 build_type=Debug [conf] tools.cmake.cmaketoolchain:extra_variables={'CMAKE_CXX_COMPILER_LAUNCHER': 'ccache', 'CMAKE_C_COMPILER_LAUNCHER': 'ccache'} -tools.cmake.cmaketoolchain:extra_variables*={'BIN2CPP_CXX_FLAGS': {'value': '-Wall;-Wextra;-Wpedantic;-Werror;-fsanitize=address,undefined', 'cache': True, 'type': 'STRING', 'docstring': 'CXX flags for Bigfoot', 'force': True}} -tools.cmake.cmaketoolchain:extra_variables*={'BIN2CPP_C_FLAGS': {'value': '-Wall;-Wextra;-Wpedantic;-Werror;-fsanitize=address,undefined', 'cache': True, 'type': 'STRING', 'docstring': 'C flags for Bigfoot', 'force': True}} +tools.cmake.cmaketoolchain:extra_variables*={'BIN2CPP_CXX_FLAGS': {'value': '-Wall;-Wextra;-Wpedantic;-Werror;-fsanitize=address,undefined;-fno-sanitize-recover=all', 'cache': True, 'type': 'STRING', 'docstring': 'CXX flags for Bigfoot', 'force': True}} +tools.cmake.cmaketoolchain:extra_variables*={'BIN2CPP_C_FLAGS': {'value': '-Wall;-Wextra;-Wpedantic;-Werror;-fsanitize=address,undefined;-fno-sanitize-recover=all', 'cache': True, 'type': 'STRING', 'docstring': 'C flags for Bigfoot', 'force': True}} +tools.cmake.cmaketoolchain:extra_variables*={'BIN2CPP_SHARED_LINK_FLAGS': {'value': '-fsanitize=address,undefined', 'cache': True, 'type': 'STRING', 'docstring': 'SHARED link flags for Bigfoot', 'force': True}} +tools.cmake.cmaketoolchain:extra_variables*={'BIN2CPP_EXE_LINK_FLAGS': {'value': '-fsanitize=address,undefined', 'cache': True, 'type': 'STRING', 'docstring': 'EXE link flags for Bigfoot', 'force': True}} tools.cmake.cmaketoolchain:generator=Ninja tools.system.package_manager:mode=install tools.system.package_manager:sudo=True