mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Remove YAML set helpers tests
The code they're testing no longer exists in this repo.
This commit is contained in:
@@ -43,7 +43,6 @@ set(LIBLOOT_SRC_TESTS_INTERNALS_H_FILES
|
||||
"${CMAKE_SOURCE_DIR}/src/tests/api/internals/game/load_order_handler_test.h"
|
||||
"${CMAKE_SOURCE_DIR}/src/tests/api/internals/helpers/crc_test.h"
|
||||
"${CMAKE_SOURCE_DIR}/src/tests/api/internals/helpers/text_test.h"
|
||||
"${CMAKE_SOURCE_DIR}/src/tests/api/internals/helpers/yaml_set_helpers_test.h"
|
||||
"${CMAKE_SOURCE_DIR}/src/tests/api/internals/metadata/condition_evaluator_test.h"
|
||||
"${CMAKE_SOURCE_DIR}/src/tests/api/internals/metadata/conditional_metadata_test.h"
|
||||
"${CMAKE_SOURCE_DIR}/src/tests/api/internals/metadata/file_test.h"
|
||||
|
||||
@@ -1,142 +0,0 @@
|
||||
/* LOOT
|
||||
|
||||
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
|
||||
Fallout: New Vegas.
|
||||
|
||||
Copyright (C) 2014-2016 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
|
||||
<https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef LOOT_TESTS_API_INTERNALS_HELPERS_YAML_SET_HELPERS_TEST
|
||||
#define LOOT_TESTS_API_INTERNALS_HELPERS_YAML_SET_HELPERS_TEST
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "api/metadata/yaml/set.h"
|
||||
|
||||
namespace loot {
|
||||
namespace test {
|
||||
TEST(set, encodingAsYamlShouldStoreAllValuesInSetOrder) {
|
||||
std::set<std::string> stringSet({"a", "b", "c"});
|
||||
YAML::Node node;
|
||||
node = stringSet;
|
||||
|
||||
EXPECT_TRUE(node.IsSequence());
|
||||
ASSERT_EQ(3, node.size());
|
||||
EXPECT_EQ("a", node[0].as<std::string>());
|
||||
EXPECT_EQ("b", node[1].as<std::string>());
|
||||
EXPECT_EQ("c", node[2].as<std::string>());
|
||||
}
|
||||
|
||||
TEST(set, decodingFromAYamlListShouldStoreValuesCorrectly) {
|
||||
YAML::Node node = YAML::Load("[a, b, c]");
|
||||
std::set<std::string> stringSet = node.as<std::set<std::string>>();
|
||||
std::set<std::string> expectedStringSet({"a", "b", "c"});
|
||||
|
||||
EXPECT_EQ(expectedStringSet, stringSet);
|
||||
}
|
||||
|
||||
TEST(set, decodingFromAYamlListThatContainsDuplicateElementsShouldThrow) {
|
||||
YAML::Node node = YAML::Load("[a, b, c, c]");
|
||||
EXPECT_THROW(node.as<std::set<std::string>>(), YAML::RepresentationException);
|
||||
}
|
||||
|
||||
TEST(set, emittingAsYamlShouldOutputAYamlListContainingAllValues) {
|
||||
std::set<std::string> stringSet({"a", "b", "c"});
|
||||
YAML::Emitter e1;
|
||||
e1 << stringSet;
|
||||
|
||||
YAML::Node node = YAML::Load(e1.c_str());
|
||||
EXPECT_TRUE(node.IsSequence());
|
||||
ASSERT_EQ(3, node.size());
|
||||
EXPECT_EQ("a", node[0].as<std::string>());
|
||||
EXPECT_EQ("b", node[1].as<std::string>());
|
||||
EXPECT_EQ("c", node[2].as<std::string>());
|
||||
}
|
||||
|
||||
class unordered_set : public ::testing::Test {
|
||||
protected:
|
||||
static bool nodeContains(const YAML::Node& node, const std::string& value) {
|
||||
for (const auto& element : node) {
|
||||
if (element.as<std::string>() == value)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool isSequenceOf(const std::string& sequence,
|
||||
const std::vector<std::string>& values) {
|
||||
std::set<std::string> sortedValues(std::begin(values), std::end(values));
|
||||
|
||||
std::set<std::string> found;
|
||||
size_t i = 2;
|
||||
while (i < sequence.length()) {
|
||||
size_t separatorPos = sequence.find("\n- ", i);
|
||||
found.insert(sequence.substr(i, separatorPos));
|
||||
}
|
||||
|
||||
return sortedValues == found;
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(unordered_set, encodingAsYamlShouldStoreAllValuesInUndefinedOrder) {
|
||||
std::unordered_set<std::string> stringSet({"a", "b", "c"});
|
||||
YAML::Node node;
|
||||
node = stringSet;
|
||||
|
||||
EXPECT_TRUE(node.IsSequence());
|
||||
ASSERT_EQ(3, node.size());
|
||||
EXPECT_PRED2(&nodeContains, node, "a");
|
||||
EXPECT_PRED2(&nodeContains, node, "b");
|
||||
EXPECT_PRED2(&nodeContains, node, "c");
|
||||
}
|
||||
|
||||
TEST_F(unordered_set, decodingFromAYamlListShouldStoreValuesCorrectly) {
|
||||
YAML::Node node = YAML::Load("[a, b, c]");
|
||||
std::unordered_set<std::string> stringSet =
|
||||
node.as<std::unordered_set<std::string>>();
|
||||
|
||||
EXPECT_EQ(1, stringSet.count("a"));
|
||||
EXPECT_EQ(1, stringSet.count("b"));
|
||||
EXPECT_EQ(1, stringSet.count("c"));
|
||||
}
|
||||
|
||||
TEST_F(unordered_set,
|
||||
decodingFromAYamlListThatContainsDuplicateElementsShouldThrow) {
|
||||
YAML::Node node = YAML::Load("[a, b, c, c]");
|
||||
|
||||
EXPECT_THROW(node.as<std::unordered_set<std::string>>(),
|
||||
YAML::RepresentationException);
|
||||
}
|
||||
|
||||
TEST_F(unordered_set, emittingAsYamlShouldOutputAYamlListContainingAllValues) {
|
||||
std::unordered_set<std::string> stringSet({"a", "b", "c"});
|
||||
YAML::Emitter e1;
|
||||
e1 << stringSet;
|
||||
|
||||
YAML::Node node = YAML::Load(e1.c_str());
|
||||
EXPECT_TRUE(node.IsSequence());
|
||||
ASSERT_EQ(3, node.size());
|
||||
EXPECT_PRED2(&nodeContains, node, "a");
|
||||
EXPECT_PRED2(&nodeContains, node, "b");
|
||||
EXPECT_PRED2(&nodeContains, node, "c");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -28,7 +28,6 @@
|
||||
#include "tests/api/internals/game/load_order_handler_test.h"
|
||||
#include "tests/api/internals/helpers/crc_test.h"
|
||||
#include "tests/api/internals/helpers/text_test.h"
|
||||
#include "tests/api/internals/helpers/yaml_set_helpers_test.h"
|
||||
#include "tests/api/internals/metadata/condition_evaluator_test.h"
|
||||
#include "tests/api/internals/metadata/conditional_metadata_test.h"
|
||||
#include "tests/api/internals/metadata/file_test.h"
|
||||
|
||||
Reference in New Issue
Block a user