69 lines
2.0 KiB
C++
69 lines
2.0 KiB
C++
/*********************************************************************
|
|
* \file VulkanFormatters.cpp
|
|
*
|
|
* \author Romain BOULLARD
|
|
* \date September 2026
|
|
*********************************************************************/
|
|
#include <GraphicsVulkan/VulkanFormatters.hpp>
|
|
|
|
#include <Utils/Log/LogMacros.hpp>
|
|
#include <Utils/Singleton.hpp>
|
|
|
|
#include <GraphicsVulkan/GraphicsVulkanLogger_generated.hpp>
|
|
|
|
#include <fmt/format.h>
|
|
#include <gmock/gmock.h>
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <fstream>
|
|
#include <sstream>
|
|
#include <string>
|
|
|
|
namespace Bigfoot::Vulkan
|
|
{
|
|
class VulkanFormattersFixture: public ::testing::Test
|
|
{
|
|
protected:
|
|
};
|
|
|
|
/****************************************************************************************/
|
|
|
|
TEST_F(VulkanFormattersFixture, FormatsASuccessResultAsItsToString)
|
|
{
|
|
EXPECT_EQ(fmt::format("{}", vk::Result::eSuccess), vk::to_string(vk::Result::eSuccess));
|
|
}
|
|
|
|
/****************************************************************************************/
|
|
|
|
TEST_F(VulkanFormattersFixture, FormatsAnErrorResultAsItsToString)
|
|
{
|
|
EXPECT_EQ(fmt::format("{}", vk::Result::eErrorDeviceLost), vk::to_string(vk::Result::eErrorDeviceLost));
|
|
}
|
|
|
|
/****************************************************************************************/
|
|
|
|
#ifdef BIGFOOT_NOT_OPTIMIZED
|
|
class VulkanFormattersLogFixture: public ::testing::Test
|
|
{
|
|
protected:
|
|
static std::string ReadFileSinkContent()
|
|
{
|
|
Singleton<Log>::GetInstance().Flush();
|
|
|
|
std::ifstream file {std::string {Log::FILE_SINK_PATH.data()}};
|
|
std::stringstream buffer;
|
|
buffer << file.rdbuf();
|
|
return buffer.str();
|
|
}
|
|
};
|
|
|
|
/****************************************************************************************/
|
|
|
|
TEST_F(VulkanFormattersLogFixture, LogsAResultArgumentAsItsToString)
|
|
{
|
|
BIGFOOT_LOG_INFO(GRAPHICSVULKAN_LOGGER, "{}", vk::Result::eErrorOutOfHostMemory);
|
|
EXPECT_THAT(ReadFileSinkContent(), ::testing::HasSubstr(vk::to_string(vk::Result::eErrorOutOfHostMemory)));
|
|
}
|
|
#endif
|
|
} // namespace Bigfoot::Vulkan
|