aboutsummaryrefslogtreecommitdiff
path: root/src/unittest
diff options
context:
space:
mode:
authorkwolekr <kwolekr@minetest.net>2015-05-05 16:52:06 -0400
committerkwolekr <kwolekr@minetest.net>2015-05-05 16:52:06 -0400
commit633af58a05fb9b3ad7a0a178011f4243e5f8be2e (patch)
tree709315cc088d2b3fc2db7c07caf00bd0dd6c053e /src/unittest
parentb785577f03d00c83236782876def4c900edbba4e (diff)
downloadminetest-633af58a05fb9b3ad7a0a178011f4243e5f8be2e.tar.gz
minetest-633af58a05fb9b3ad7a0a178011f4243e5f8be2e.tar.bz2
minetest-633af58a05fb9b3ad7a0a178011f4243e5f8be2e.zip
NodeDefManager: Improve const-correctness of interfaces
- Add ability to explicitly reset NodeResolve state (useful for unittesting) - Remove non-essential NodeResolve methods modifying state from INodeDefManager - Add const qualifier to NodeDefManager and ContentFeatures serialize
Diffstat (limited to 'src/unittest')
-rw-r--r--src/unittest/test_noderesolver.cpp34
1 files changed, 14 insertions, 20 deletions
diff --git a/src/unittest/test_noderesolver.cpp b/src/unittest/test_noderesolver.cpp
index c440b2399..a4ea647bc 100644
--- a/src/unittest/test_noderesolver.cpp
+++ b/src/unittest/test_noderesolver.cpp
@@ -31,36 +31,30 @@ public:
void runTests(IGameDef *gamedef);
- void testNodeResolving(INodeDefManager *ndef);
- void testPendingResolveCancellation(INodeDefManager *ndef);
- void testDirectResolveMethod(INodeDefManager *ndef);
- void testNoneResolveMethod(INodeDefManager *ndef);
+ void testNodeResolving(IWritableNodeDefManager *ndef);
+ void testPendingResolveCancellation(IWritableNodeDefManager *ndef);
+ void testDirectResolveMethod(IWritableNodeDefManager *ndef);
+ void testNoneResolveMethod(IWritableNodeDefManager *ndef);
};
static TestNodeResolver g_test_instance;
void TestNodeResolver::runTests(IGameDef *gamedef)
{
- IWritableNodeDefManager *parent_ndef;
- INodeDefManager *ndef;
+ IWritableNodeDefManager *ndef =
+ (IWritableNodeDefManager *)gamedef->getNodeDefManager();
- parent_ndef = (IWritableNodeDefManager *)gamedef->getNodeDefManager();
-
- ndef = parent_ndef->clone();
+ ndef->resetNodeResolveState();
TEST(testNodeResolving, ndef);
- delete ndef;
- ndef = parent_ndef->clone();
+ ndef->resetNodeResolveState();
TEST(testPendingResolveCancellation, ndef);
- delete ndef;
- ndef = parent_ndef->clone();
+ ndef->resetNodeResolveState();
TEST(testDirectResolveMethod, ndef);
- delete ndef;
- ndef = parent_ndef->clone();
+ ndef->resetNodeResolveState();
TEST(testNoneResolveMethod, ndef);
- delete ndef;
}
class Foobar : public NodeResolver {
@@ -113,7 +107,7 @@ void Foobaz::resolveNodeNames()
}
-void TestNodeResolver::testNodeResolving(INodeDefManager *ndef)
+void TestNodeResolver::testNodeResolving(IWritableNodeDefManager *ndef)
{
Foobar foobar;
size_t i;
@@ -191,7 +185,7 @@ void TestNodeResolver::testNodeResolving(INodeDefManager *ndef)
}
-void TestNodeResolver::testPendingResolveCancellation(INodeDefManager *ndef)
+void TestNodeResolver::testPendingResolveCancellation(IWritableNodeDefManager *ndef)
{
Foobaz foobaz1;
foobaz1.test_content1 = 1234;
@@ -219,7 +213,7 @@ void TestNodeResolver::testPendingResolveCancellation(INodeDefManager *ndef)
}
-void TestNodeResolver::testDirectResolveMethod(INodeDefManager *ndef)
+void TestNodeResolver::testDirectResolveMethod(IWritableNodeDefManager *ndef)
{
Foobaz foobaz;
@@ -240,7 +234,7 @@ void TestNodeResolver::testDirectResolveMethod(INodeDefManager *ndef)
}
-void TestNodeResolver::testNoneResolveMethod(INodeDefManager *ndef)
+void TestNodeResolver::testNoneResolveMethod(IWritableNodeDefManager *ndef)
{
Foobaz foobaz;