summaryrefslogtreecommitdiff
path: root/src/unittest
diff options
context:
space:
mode:
Diffstat (limited to 'src/unittest')
-rw-r--r--src/unittest/test_noderesolver.cpp2
-rw-r--r--src/unittest/test_schematic.cpp40
2 files changed, 25 insertions, 17 deletions
diff --git a/src/unittest/test_noderesolver.cpp b/src/unittest/test_noderesolver.cpp
index 28da43620..ed66093a9 100644
--- a/src/unittest/test_noderesolver.cpp
+++ b/src/unittest/test_noderesolver.cpp
@@ -56,6 +56,8 @@ void TestNodeResolver::runTests(IGameDef *gamedef)
class Foobar : public NodeResolver {
public:
+ friend class TestNodeResolver; // m_ndef
+
void resolveNodeNames();
content_t test_nr_node1;
diff --git a/src/unittest/test_schematic.cpp b/src/unittest/test_schematic.cpp
index da4ce50d2..d2f027eb4 100644
--- a/src/unittest/test_schematic.cpp
+++ b/src/unittest/test_schematic.cpp
@@ -66,13 +66,14 @@ void TestSchematic::testMtsSerializeDeserialize(const NodeDefManager *ndef)
std::stringstream ss(std::ios_base::binary |
std::ios_base::in | std::ios_base::out);
- std::vector<std::string> names;
- names.emplace_back("foo");
- names.emplace_back("bar");
- names.emplace_back("baz");
- names.emplace_back("qux");
-
- Schematic schem, schem2;
+ Schematic schem;
+ {
+ std::vector<std::string> &names = schem.m_nodenames;
+ names.emplace_back("foo");
+ names.emplace_back("bar");
+ names.emplace_back("baz");
+ names.emplace_back("qux");
+ }
schem.flags = 0;
schem.size = size;
@@ -83,18 +84,21 @@ void TestSchematic::testMtsSerializeDeserialize(const NodeDefManager *ndef)
for (s16 y = 0; y != size.Y; y++)
schem.slice_probs[y] = MTSCHEM_PROB_ALWAYS;
- UASSERT(schem.serializeToMts(&ss, names));
+ UASSERT(schem.serializeToMts(&ss));
ss.seekg(0);
- names.clear();
- UASSERT(schem2.deserializeFromMts(&ss, &names));
+ Schematic schem2;
+ UASSERT(schem2.deserializeFromMts(&ss));
- UASSERTEQ(size_t, names.size(), 4);
- UASSERTEQ(std::string, names[0], "foo");
- UASSERTEQ(std::string, names[1], "bar");
- UASSERTEQ(std::string, names[2], "baz");
- UASSERTEQ(std::string, names[3], "qux");
+ {
+ std::vector<std::string> &names = schem2.m_nodenames;
+ UASSERTEQ(size_t, names.size(), 4);
+ UASSERTEQ(std::string, names[0], "foo");
+ UASSERTEQ(std::string, names[1], "bar");
+ UASSERTEQ(std::string, names[2], "baz");
+ UASSERTEQ(std::string, names[3], "qux");
+ }
UASSERT(schem2.size == size);
for (size_t i = 0; i != volume; i++)
@@ -120,14 +124,14 @@ void TestSchematic::testLuaTableSerialize(const NodeDefManager *ndef)
for (s16 y = 0; y != size.Y; y++)
schem.slice_probs[y] = MTSCHEM_PROB_ALWAYS;
- std::vector<std::string> names;
+ std::vector<std::string> &names = schem.m_nodenames;
names.emplace_back("air");
names.emplace_back("default:lava_source");
names.emplace_back("default:glass");
std::ostringstream ss(std::ios_base::binary);
- UASSERT(schem.serializeToLua(&ss, names, false, 0));
+ UASSERT(schem.serializeToLua(&ss, false, 0));
UASSERTEQ(std::string, ss.str(), expected_lua_output);
}
@@ -159,6 +163,8 @@ void TestSchematic::testFileSerializeDeserialize(const NodeDefManager *ndef)
schem1.slice_probs[0] = 80;
schem1.slice_probs[1] = 160;
schem1.slice_probs[2] = 240;
+ // Node resolving happened manually.
+ schem1.m_resolve_done = true;
for (size_t i = 0; i != volume; i++) {
content_t c = content_map[test_schem2_data[i]];