-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
#include <format> | ||
#include <HyperSonicDrivers/utils/ILogger.hpp> | ||
|
||
namespace std | ||
{ | ||
template<> | ||
struct formatter<HyperSonicDrivers::utils::ILogger::eLevel> : formatter<string_view> | ||
{ | ||
template<typename FormatContext> | ||
auto format(HyperSonicDrivers::utils::ILogger::eLevel level, FormatContext& fc) const | ||
{ | ||
string str; | ||
|
||
switch (level) | ||
{ | ||
using enum HyperSonicDrivers::utils::ILogger::eLevel; | ||
|
||
case Trace: | ||
str = "Trace"; | ||
break; | ||
case Debug: | ||
str = "Debug"; | ||
break; | ||
case Info: | ||
str = "Info"; | ||
break; | ||
case Warning: | ||
str = "Warning"; | ||
break; | ||
case Error: | ||
str = "Error"; | ||
break; | ||
case Critical: | ||
str = "Critical"; | ||
break; | ||
case Off: | ||
str = "Off"; | ||
break; | ||
} | ||
|
||
return formatter<std::string_view>::format(str, fc); | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
sdl2-hyper-sonic-drivers/test/std/ILoggerFormatterTest.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include <gtest/gtest.h> | ||
#include <gmock/gmock.h> | ||
#include <std/ILoggerFormatter.hpp> | ||
|
||
namespace std | ||
{ | ||
TEST(ILoggerFormatter, Music) | ||
{ | ||
ASSERT_STRCASEEQ(std::format("{}", HyperSonicDrivers::utils::ILogger::eLevel::Critical).c_str(), "Critical"); | ||
} | ||
} | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
::testing::InitGoogleTest(&argc, argv); | ||
return RUN_ALL_TESTS(); | ||
} |