diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9b5d1811..a06a26d6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -158,6 +158,7 @@ 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/api/test_api.h"
"${CMAKE_SOURCE_DIR}/src/tests/backend/helpers/test_language.h"
+ "${CMAKE_SOURCE_DIR}/src/tests/backend/helpers/test_yaml_set_helpers.h"
"${CMAKE_SOURCE_DIR}/src/tests/backend/metadata/test_file.h"
"${CMAKE_SOURCE_DIR}/src/tests/backend/metadata/test_formid.h"
"${CMAKE_SOURCE_DIR}/src/tests/backend/metadata/test_location.h"
diff --git a/src/tests/backend/helpers/test_yaml_set_helpers.h b/src/tests/backend/helpers/test_yaml_set_helpers.h
new file mode 100644
index 00000000..b006b6a3
--- /dev/null
+++ b/src/tests/backend/helpers/test_yaml_set_helpers.h
@@ -0,0 +1,113 @@
+/* LOOT
+
+A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
+Fallout: New Vegas.
+
+Copyright (C) 2014-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
+.
+*/
+
+#ifndef LOOT_TEST_BACKEND_HELPERS_YAML_SET_HELPERS
+#define LOOT_TEST_BACKEND_HELPERS_YAML_SET_HELPERS
+
+#include "backend/helpers/yaml_set_helpers.h"
+#include "tests/fixtures.h"
+
+TEST(set, YamlEncode) {
+ YAML::Node node;
+ std::set stringSet({"a", "b", "c"});
+ node = stringSet;
+ EXPECT_EQ("a", node[0].as());
+ EXPECT_EQ("b", node[1].as());
+ EXPECT_EQ("c", node[2].as());
+}
+
+TEST(set, YamlDecode) {
+ YAML::Node node;
+ std::set stringSet;
+
+ node = YAML::Load("[a, b, c]");
+ stringSet = node.as>();
+ EXPECT_EQ(stringSet.begin(), stringSet.find("a"));
+ EXPECT_EQ(++stringSet.begin(), stringSet.find("b"));
+ EXPECT_EQ(--stringSet.end(), stringSet.find("c"));
+}
+
+TEST(set, YamlEmitter) {
+ std::set stringSet({"a", "b", "c"});
+ YAML::Emitter e1;
+ e1 << stringSet;
+ EXPECT_STREQ("- a\n- b\n- c", e1.c_str());
+}
+
+bool nodeContains(const std::string& value, const YAML::Node& node) {
+ for (const auto& element : node) {
+ if (element.as() == value)
+ return true;
+ }
+ return false;
+}
+
+TEST(unordered_set, YamlEncode) {
+ YAML::Node node;
+ std::unordered_set stringSet({"a", "b", "c"});
+ node = stringSet;
+ // Check that the values are all present in the node.
+ EXPECT_PRED2(nodeContains, "a", node);
+ EXPECT_PRED2(nodeContains, "b", node);
+ EXPECT_PRED2(nodeContains, "c", node);
+}
+
+TEST(unordered_set, YAMLDecode) {
+ YAML::Node node;
+ std::unordered_set stringSet;
+
+ node = YAML::Load("[a, b, c]");
+ stringSet = node.as>();
+ EXPECT_EQ(1, stringSet.count("a"));
+ EXPECT_EQ(1, stringSet.count("b"));
+ EXPECT_EQ(1, stringSet.count("c"));
+}
+
+bool sequenceOf(const char val1,
+ const char val2,
+ const char val3,
+ const std::string& seq) {
+ if (seq.substr(0, 2) != "- "
+ || seq.substr(3, 3) != "\n- "
+ || seq.substr(7, 3) != "\n- ")
+ return false;
+
+ std::list values({val1, val2, val3});
+ std::list found({seq[2], seq[6], seq[10]});
+
+ values.sort();
+ found.sort();
+
+ return values == found;
+}
+
+TEST(unordered_set, YamlEmitter) {
+ std::unordered_set stringSet({"a", "b", "c"});
+ YAML::Emitter e1;
+ e1 << stringSet;
+ ASSERT_EQ(11, e1.size());
+ EXPECT_PRED4(sequenceOf, 'a', 'b', 'c', e1.c_str());
+}
+
+#endif
diff --git a/src/tests/main.cpp b/src/tests/main.cpp
index 2e647a89..c8f9e39c 100644
--- a/src/tests/main.cpp
+++ b/src/tests/main.cpp
@@ -29,6 +29,7 @@
#include "backend/metadata/test_message_content.h"
#include "backend/metadata/test_tag.h"
#include "backend/helpers/test_language.h"
+#include "backend/helpers/test_yaml_set_helpers.h"
int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);