From 391b9ad7c91809ffa84e8270ad66afec9ec9fe23 Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Wed, 22 Apr 2026 18:05:27 +0100 Subject: [PATCH] Fix C++ test printers It turns out that they were never used, I noticed this while debugging some LOOT tests, which have a copy of the same printers.h file. --- cpp/src/tests/api/interface/main.cpp | 1 + cpp/src/tests/printers.h | 40 +++++++++++++++++----------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/cpp/src/tests/api/interface/main.cpp b/cpp/src/tests/api/interface/main.cpp index d9607e27..7b326f65 100644 --- a/cpp/src/tests/api/interface/main.cpp +++ b/cpp/src/tests/api/interface/main.cpp @@ -40,6 +40,7 @@ #include "tests/api/interface/metadata/plugin_metadata_test.h" #include "tests/api/interface/metadata/tag_test.h" #include "tests/api/interface/plugin_interface_test.h" +#include "tests/printers.h" int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); diff --git a/cpp/src/tests/printers.h b/cpp/src/tests/printers.h index 228bcc64..528a819c 100644 --- a/cpp/src/tests/printers.h +++ b/cpp/src/tests/printers.h @@ -29,21 +29,30 @@ along with LOOT. If not, see #include -#include "api/metadata/message_content.h" -#include "api/plugin.h" #include "loot/metadata/file.h" +#include "loot/metadata/group.h" #include "loot/metadata/location.h" #include "loot/metadata/message.h" #include "loot/metadata/plugin_cleaning_data.h" #include "loot/metadata/plugin_metadata.h" #include "loot/metadata/tag.h" +#include "loot/plugin_interface.h" namespace loot { -namespace test { + void PrintTo(const File& value, ::std::ostream* os) { *os << "File(\"" << std::string(value.GetName()) << "\", " << "\"" << value.GetDisplayName() << "\", " - << "\"" << value.GetCondition() << "\"" + << "\"" << value.GetCondition() << "\", " + << ::testing::PrintToString(value.GetDetail()) << ", " + << "\"" << value.GetConstraint() << "\"" + << ")"; +} + +void PrintTo(const Group& value, ::std::ostream* os) { + *os << "Group(\"" << value.GetName() << "\", " + << ::testing::PrintToString(value.GetAfterGroups()) << ", " + << "\"" << value.GetDescription() << "\"" << ")"; } @@ -56,13 +65,13 @@ void PrintTo(const Location& value, ::std::ostream* os) { void PrintTo(const Message& value, ::std::ostream* os) { std::string type; if (value.GetType() == MessageType::warn) - type = "warn"; + type = "MessageType::warn"; else if (value.GetType() == MessageType::error) - type = "error"; + type = "MessageType::error"; else - type = "say"; + type = "MessageType::say"; - *os << "Message(\"" << type << "\", " + *os << "Message(" << type << ", " << ::testing::PrintToString(value.GetContent()) << ", " << "\"" << value.GetCondition() << "\"" << ")"; @@ -70,16 +79,18 @@ void PrintTo(const Message& value, ::std::ostream* os) { void PrintTo(const MessageContent& value, ::std::ostream* os) { *os << "MessageContent(\"" << value.GetText() << "\", " - << "\"" << Language(value.GetLanguage()).GetName() << "\"" + << "\"" << value.GetLanguage() << "\"" << ")"; } void PrintTo(const PluginCleaningData& value, ::std::ostream* os) { *os << "PluginCleaningData(0x" << std::hex << std::uppercase << value.GetCRC() - << std::nouppercase << std::dec << ", " << value.GetITMCount() << ", " - << value.GetDeletedReferenceCount() << ", " + << std::nouppercase << std::dec << ", " + << "\"" << value.GetCleaningUtility() << "\", " + << ::testing::PrintToString(value.GetDetail()) << ", " + << value.GetITMCount() << ", " << value.GetDeletedReferenceCount() << ", " << value.GetDeletedNavmeshCount() << ", " - << "\"" << value.GetCleaningUtility() << "\"" + << "\"" << value.GetCondition() << "\"" << ")"; } @@ -93,9 +104,8 @@ void PrintTo(const Tag& value, ::std::ostream* os) { << ")"; } -void PrintTo(const Plugin& value, ::std::ostream* os) { - *os << "Plugin(\"" << value.GetName() << "\")"; -} +void PrintTo(const PluginInterface& value, ::std::ostream* os) { + *os << "PluginInterface(\"" << value.GetName() << "\")"; } }