mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Merge pull request #7520 from hyperlogic/tony/octree-tests
OctreeTests: added unit tests for EntityTreeElement child accessors
This commit is contained in:
commit
89d41c55ea
2 changed files with 34 additions and 0 deletions
|
@ -795,3 +795,35 @@ void OctreeTests::modelItemTests() {
|
|||
#endif
|
||||
}
|
||||
|
||||
void OctreeTests::elementAddChildTests() {
|
||||
EntityTreePointer tree = std::make_shared<EntityTree>();
|
||||
auto elem = tree->createNewElement();
|
||||
QCOMPARE((bool)elem->getChildAtIndex(0), false);
|
||||
elem->addChildAtIndex(0);
|
||||
QCOMPARE((bool)elem->getChildAtIndex(0), true);
|
||||
|
||||
const int MAX_CHILD_INDEX = 8;
|
||||
for (int i = 0; i < MAX_CHILD_INDEX; i++) {
|
||||
for (int j = 0; j < MAX_CHILD_INDEX; j++) {
|
||||
auto e = tree->createNewElement();
|
||||
|
||||
// add a single child.
|
||||
auto firstChild = e->addChildAtIndex(i);
|
||||
QCOMPARE(e->getChildAtIndex(i), firstChild);
|
||||
|
||||
if (i != j) {
|
||||
// add a second child.
|
||||
auto secondChild = e->addChildAtIndex(j);
|
||||
QCOMPARE(e->getChildAtIndex(i), firstChild);
|
||||
QCOMPARE(e->getChildAtIndex(j), secondChild);
|
||||
|
||||
// remove scecond child.
|
||||
e->removeChildAtIndex(j);
|
||||
|
||||
QCOMPARE((bool)e->getChildAtIndex(j), false);
|
||||
}
|
||||
|
||||
QCOMPARE(e->getChildAtIndex(i), firstChild);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ private slots:
|
|||
// This test is fine
|
||||
void modelItemTests();
|
||||
|
||||
void elementAddChildTests();
|
||||
|
||||
// TODO: Break these into separate test functions
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue