mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Add Google Test value printers.
For easier debugging test failures.
This commit is contained in:
@@ -156,6 +156,7 @@ set (LOOT_API_HEADERS ${LOOT_HEADERS}
|
||||
set (LOOT_TESTS_SRC "${CMAKE_SOURCE_DIR}/src/tests/main.cpp")
|
||||
|
||||
set (LOOT_TESTS_HEADERS "${CMAKE_SOURCE_DIR}/src/tests/fixtures.h"
|
||||
"${CMAKE_SOURCE_DIR}/src/tests/printers.h"
|
||||
"${CMAKE_SOURCE_DIR}/src/tests/api/test_api.h"
|
||||
"${CMAKE_SOURCE_DIR}/src/tests/backend/game/test_game.h"
|
||||
"${CMAKE_SOURCE_DIR}/src/tests/backend/game/test_game_settings.h"
|
||||
|
||||
@@ -26,6 +26,7 @@ along with LOOT. If not, see
|
||||
#define LOOT_TEST_FIXTURES
|
||||
|
||||
#include "backend/helpers/streams.h"
|
||||
#include "printers.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
/* LOOT
|
||||
|
||||
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
|
||||
Fallout: New Vegas.
|
||||
|
||||
Copyright (C) 2013-2015 WrinklyNinja
|
||||
|
||||
This file is part of LOOT.
|
||||
|
||||
LOOT is free software: you can redistribute
|
||||
it and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
LOOT is distributed in the hope that it will
|
||||
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LOOT. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef LOOT_TEST_PRINTERS
|
||||
#define LOOT_TEST_PRINTERS
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "backend/metadata/file.h"
|
||||
#include "backend/metadata/formid.h"
|
||||
#include "backend/metadata/location.h"
|
||||
#include "backend/metadata/message.h"
|
||||
#include "backend/metadata/message_content.h"
|
||||
#include "backend/metadata/plugin_dirty_info.h"
|
||||
#include "backend/metadata/plugin_metadata.h"
|
||||
#include "backend/metadata/tag.h"
|
||||
#include "backend/plugin/plugin.h"
|
||||
|
||||
namespace loot {
|
||||
void PrintTo(const File& value, ::std::ostream* os) {
|
||||
*os << "loot::File(\"" << value.Name() << "\", "
|
||||
<< "\"" << value.DisplayName() << "\", "
|
||||
<< "\"" << value.Condition() << "\""
|
||||
<< ")";
|
||||
}
|
||||
|
||||
void PrintTo(const FormID& value, ::std::ostream* os) {
|
||||
*os << "loot::FormID(\"" << value.Plugin() << "\", 0x"
|
||||
<< std::hex << std::uppercase
|
||||
<< value.Id()
|
||||
<< std::nouppercase << std::dec
|
||||
<< ")";
|
||||
}
|
||||
|
||||
void PrintTo(const Location& value, ::std::ostream* os) {
|
||||
*os << "loot::Location(\"" << value.URL() << "\", "
|
||||
<< ::testing::PrintToString(value.Versions())
|
||||
<< ")";
|
||||
}
|
||||
|
||||
void PrintTo(const Message& value, ::std::ostream* os) {
|
||||
std::string type;
|
||||
if (value.Type() == Message::warn)
|
||||
type = "warn";
|
||||
else if (value.Type() == Message::error)
|
||||
type = "error";
|
||||
else
|
||||
type = "say";
|
||||
|
||||
*os << "loot::Message(\"" << type << "\", "
|
||||
<< ::testing::PrintToString(value.Content()) << ", "
|
||||
<< "\"" << value.Condition() << "\""
|
||||
<< ")";
|
||||
}
|
||||
|
||||
void PrintTo(const MessageContent& value, ::std::ostream* os) {
|
||||
*os << "loot::MessageContent(\"" << value.Str() << "\", "
|
||||
<< "\"" << Language(value.Language()).Name() << "\""
|
||||
<< ")";
|
||||
}
|
||||
|
||||
void PrintTo(const PluginDirtyInfo& value, ::std::ostream* os) {
|
||||
*os << "loot::PluginDirtyInfo(0x"
|
||||
<< std::hex << std::uppercase
|
||||
<< value.CRC()
|
||||
<< std::nouppercase << std::dec << ", "
|
||||
<< value.ITMs() << ", "
|
||||
<< value.DeletedRefs() << ", "
|
||||
<< value.DeletedNavmeshes() << ", "
|
||||
<< "\"" << value.CleaningUtility() << "\""
|
||||
<< ")";
|
||||
}
|
||||
|
||||
void PrintTo(const PluginMetadata& value, ::std::ostream* os) {
|
||||
*os << "loot::PluginMetadata(\"" << value.Name() << "\")";
|
||||
}
|
||||
|
||||
void PrintTo(const Tag& value, ::std::ostream* os) {
|
||||
*os << "loot::Tag(\"" << value.Name() << "\", "
|
||||
<< value.IsAddition() << ", "
|
||||
<< "\"" << value.Condition() << "\""
|
||||
<< ")";
|
||||
}
|
||||
|
||||
void PrintTo(const Plugin& value, ::std::ostream* os) {
|
||||
*os << "loot::Plugin(\"" << value.Name() << "\")";
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user