TestVolume unit test now tests PagedVolume rather than SimpleVolume and LargeVolume.

This commit is contained in:
David Williams 2014-09-20 14:49:12 +02:00
parent 6f08184fcb
commit 4779f91787
2 changed files with 34 additions and 138 deletions

View File

@ -24,9 +24,8 @@ freely, subject to the following restrictions:
#include "testvolume.h" #include "testvolume.h"
#include "PolyVoxCore/FilePager.h" #include "PolyVoxCore/FilePager.h"
#include "PolyVoxCore/LargeVolume.h" #include "PolyVoxCore/PagedVolume.h"
#include "PolyVoxCore/RawVolume.h" #include "PolyVoxCore/RawVolume.h"
#include "PolyVoxCore/SimpleVolume.h"
#include <QtGlobal> #include <QtGlobal>
#include <QtTest> #include <QtTest>
@ -274,10 +273,9 @@ TestVolume::TestVolume()
//Create the volumes //Create the volumes
m_pRawVolume = new RawVolume<int32_t>(region); m_pRawVolume = new RawVolume<int32_t>(region);
m_pSimpleVolume = new SimpleVolume<int32_t>(region); m_pPagedVolume = new LargeVolume<int32_t>(region, m_pFilePager, 32);
m_pLargeVolume = new LargeVolume<int32_t>(region, m_pFilePager, 32);
m_pLargeVolume->setMemoryUsageLimit(1 * 1024 * 1024); m_pPagedVolume->setMemoryUsageLimit(1 * 1024 * 1024);
//Fill the volume with some data //Fill the volume with some data
for(int z = region.getLowerZ(); z <= region.getUpperZ(); z++) for(int z = region.getLowerZ(); z <= region.getUpperZ(); z++)
@ -288,8 +286,7 @@ TestVolume::TestVolume()
{ {
int32_t value = x + y + z; int32_t value = x + y + z;
m_pRawVolume->setVoxelAt(x, y, z, value); m_pRawVolume->setVoxelAt(x, y, z, value);
m_pSimpleVolume->setVoxelAt(x, y, z, value); m_pPagedVolume->setVoxelAt(x, y, z, value);
m_pLargeVolume->setVoxelAt(x, y, z, value);
} }
} }
} }
@ -298,18 +295,16 @@ TestVolume::TestVolume()
TestVolume::~TestVolume() TestVolume::~TestVolume()
{ {
delete m_pRawVolume; delete m_pRawVolume;
delete m_pSimpleVolume; delete m_pPagedVolume;
delete m_pLargeVolume;
delete m_pFilePager; delete m_pFilePager;
delete m_pBlockCompressor;
} }
/* /*
* RawVolume Tests * RawVolume Tests
*/ */
/*void TestVolume::testRawVolumeDirectAccessAllInternalForwards() void TestVolume::testRawVolumeDirectAccessAllInternalForwards()
{ {
int32_t result = 0; int32_t result = 0;
@ -395,176 +390,88 @@ void TestVolume::testRawVolumeSamplersWithExternalBackwards()
result = testSamplersWithWrappingBackwards(m_pRawVolume, -1, -3, -2, 2, 5, 4); result = testSamplersWithWrappingBackwards(m_pRawVolume, -1, -3, -2, 2, 5, 4);
} }
QCOMPARE(result, static_cast<int32_t>(-769775893)); QCOMPARE(result, static_cast<int32_t>(-769775893));
}*/ }
/* /*
* SimpleVolume Tests * PagedVolume Tests
*/ */
/*void TestVolume::testSimpleVolumeDirectAccessAllInternalForwards() void TestVolume::testPagedVolumeDirectAccessAllInternalForwards()
{ {
int32_t result = 0; int32_t result = 0;
QBENCHMARK QBENCHMARK
{ {
result = testDirectAccessWithWrappingForwards(m_pSimpleVolume, 4, 2, 2, -3, -1, -2); result = testDirectAccessWithWrappingForwards(m_pPagedVolume, 4, 2, 2, -3, -1, -2);
} }
QCOMPARE(result, static_cast<int32_t>(1004598054)); QCOMPARE(result, static_cast<int32_t>(1004598054));
} }
void TestVolume::testSimpleVolumeSamplersAllInternalForwards() void TestVolume::testPagedVolumeSamplersAllInternalForwards()
{ {
int32_t result = 0; int32_t result = 0;
QBENCHMARK QBENCHMARK
{ {
result = testSamplersWithWrappingForwards(m_pSimpleVolume, 4, 2, 2, -3, -1, -2); result = testSamplersWithWrappingForwards(m_pPagedVolume, 4, 2, 2, -3, -1, -2);
} }
QCOMPARE(result, static_cast<int32_t>(1004598054)); QCOMPARE(result, static_cast<int32_t>(1004598054));
} }
void TestVolume::testSimpleVolumeDirectAccessWithExternalForwards() void TestVolume::testPagedVolumeDirectAccessWithExternalForwards()
{ {
int32_t result = 0; int32_t result = 0;
QBENCHMARK QBENCHMARK
{ {
result = testDirectAccessWithWrappingForwards(m_pSimpleVolume, -1, -3, -2, 2, 5, 4); result = testDirectAccessWithWrappingForwards(m_pPagedVolume, -1, -3, -2, 2, 5, 4);
} }
QCOMPARE(result, static_cast<int32_t>(-928601007)); QCOMPARE(result, static_cast<int32_t>(-928601007));
} }
void TestVolume::testSimpleVolumeSamplersWithExternalForwards() void TestVolume::testPagedVolumeSamplersWithExternalForwards()
{ {
int32_t result = 0; int32_t result = 0;
QBENCHMARK QBENCHMARK
{ {
result = testSamplersWithWrappingForwards(m_pSimpleVolume, -1, -3, -2, 2, 5, 4); result = testSamplersWithWrappingForwards(m_pPagedVolume, -1, -3, -2, 2, 5, 4);
} }
QCOMPARE(result, static_cast<int32_t>(-928601007)); QCOMPARE(result, static_cast<int32_t>(-928601007));
} }
void TestVolume::testSimpleVolumeDirectAccessAllInternalBackwards() void TestVolume::testPagedVolumeDirectAccessAllInternalBackwards()
{ {
int32_t result = 0; int32_t result = 0;
QBENCHMARK QBENCHMARK
{ {
result = testDirectAccessWithWrappingBackwards(m_pSimpleVolume, 4, 2, 2, -3, -1, -2); result = testDirectAccessWithWrappingBackwards(m_pPagedVolume, 4, 2, 2, -3, -1, -2);
} }
QCOMPARE(result, static_cast<int32_t>(-269366578)); QCOMPARE(result, static_cast<int32_t>(-269366578));
} }
void TestVolume::testSimpleVolumeSamplersAllInternalBackwards() void TestVolume::testPagedVolumeSamplersAllInternalBackwards()
{ {
int32_t result = 0; int32_t result = 0;
QBENCHMARK QBENCHMARK
{ {
result = testSamplersWithWrappingBackwards(m_pSimpleVolume, 4, 2, 2, -3, -1, -2); result = testSamplersWithWrappingBackwards(m_pPagedVolume, 4, 2, 2, -3, -1, -2);
} }
QCOMPARE(result, static_cast<int32_t>(-269366578)); QCOMPARE(result, static_cast<int32_t>(-269366578));
} }
void TestVolume::testSimpleVolumeDirectAccessWithExternalBackwards() void TestVolume::testPagedVolumeDirectAccessWithExternalBackwards()
{ {
int32_t result = 0; int32_t result = 0;
QBENCHMARK QBENCHMARK
{ {
result = testDirectAccessWithWrappingBackwards(m_pSimpleVolume, -1, -3, -2, 2, 5, 4); result = testDirectAccessWithWrappingBackwards(m_pPagedVolume, -1, -3, -2, 2, 5, 4);
} }
QCOMPARE(result, static_cast<int32_t>(-769775893)); QCOMPARE(result, static_cast<int32_t>(-769775893));
} }
void TestVolume::testSimpleVolumeSamplersWithExternalBackwards() void TestVolume::testPagedVolumeSamplersWithExternalBackwards()
{ {
int32_t result = 0; int32_t result = 0;
QBENCHMARK QBENCHMARK
{ {
result = testSamplersWithWrappingBackwards(m_pSimpleVolume, -1, -3, -2, 2, 5, 4); result = testSamplersWithWrappingBackwards(m_pPagedVolume, -1, -3, -2, 2, 5, 4);
}
QCOMPARE(result, static_cast<int32_t>(-769775893));
}*/
/*
* LargeVolume Tests
*/
void TestVolume::testLargeVolumeDirectAccessAllInternalForwards()
{
int32_t result = 0;
QBENCHMARK
{
result = testDirectAccessWithWrappingForwards(m_pLargeVolume, 4, 2, 2, -3, -1, -2);
}
QCOMPARE(result, static_cast<int32_t>(1004598054));
}
void TestVolume::testLargeVolumeSamplersAllInternalForwards()
{
int32_t result = 0;
QBENCHMARK
{
result = testSamplersWithWrappingForwards(m_pLargeVolume, 4, 2, 2, -3, -1, -2);
}
QCOMPARE(result, static_cast<int32_t>(1004598054));
}
void TestVolume::testLargeVolumeDirectAccessWithExternalForwards()
{
int32_t result = 0;
QBENCHMARK
{
result = testDirectAccessWithWrappingForwards(m_pLargeVolume, -1, -3, -2, 2, 5, 4);
}
QCOMPARE(result, static_cast<int32_t>(-928601007));
}
void TestVolume::testLargeVolumeSamplersWithExternalForwards()
{
int32_t result = 0;
QBENCHMARK
{
result = testSamplersWithWrappingForwards(m_pLargeVolume, -1, -3, -2, 2, 5, 4);
}
QCOMPARE(result, static_cast<int32_t>(-928601007));
}
void TestVolume::testLargeVolumeDirectAccessAllInternalBackwards()
{
int32_t result = 0;
QBENCHMARK
{
result = testDirectAccessWithWrappingBackwards(m_pLargeVolume, 4, 2, 2, -3, -1, -2);
}
QCOMPARE(result, static_cast<int32_t>(-269366578));
}
void TestVolume::testLargeVolumeSamplersAllInternalBackwards()
{
int32_t result = 0;
QBENCHMARK
{
result = testSamplersWithWrappingBackwards(m_pLargeVolume, 4, 2, 2, -3, -1, -2);
}
QCOMPARE(result, static_cast<int32_t>(-269366578));
}
void TestVolume::testLargeVolumeDirectAccessWithExternalBackwards()
{
int32_t result = 0;
QBENCHMARK
{
result = testDirectAccessWithWrappingBackwards(m_pLargeVolume, -1, -3, -2, 2, 5, 4);
}
QCOMPARE(result, static_cast<int32_t>(-769775893));
}
void TestVolume::testLargeVolumeSamplersWithExternalBackwards()
{
int32_t result = 0;
QBENCHMARK
{
result = testSamplersWithWrappingBackwards(m_pLargeVolume, -1, -3, -2, 2, 5, 4);
} }
QCOMPARE(result, static_cast<int32_t>(-769775893)); QCOMPARE(result, static_cast<int32_t>(-769775893));
} }

View File

@ -37,7 +37,7 @@ public:
~TestVolume(); ~TestVolume();
private slots: private slots:
/*void testRawVolumeDirectAccessAllInternalForwards(); void testRawVolumeDirectAccessAllInternalForwards();
void testRawVolumeSamplersAllInternalForwards(); void testRawVolumeSamplersAllInternalForwards();
void testRawVolumeDirectAccessWithExternalForwards(); void testRawVolumeDirectAccessWithExternalForwards();
void testRawVolumeSamplersWithExternalForwards(); void testRawVolumeSamplersWithExternalForwards();
@ -46,31 +46,20 @@ private slots:
void testRawVolumeDirectAccessWithExternalBackwards(); void testRawVolumeDirectAccessWithExternalBackwards();
void testRawVolumeSamplersWithExternalBackwards(); void testRawVolumeSamplersWithExternalBackwards();
void testSimpleVolumeDirectAccessAllInternalForwards(); void testPagedVolumeDirectAccessAllInternalForwards();
void testSimpleVolumeSamplersAllInternalForwards(); void testPagedVolumeSamplersAllInternalForwards();
void testSimpleVolumeDirectAccessWithExternalForwards(); void testPagedVolumeDirectAccessWithExternalForwards();
void testSimpleVolumeSamplersWithExternalForwards(); void testPagedVolumeSamplersWithExternalForwards();
void testSimpleVolumeDirectAccessAllInternalBackwards(); void testPagedVolumeDirectAccessAllInternalBackwards();
void testSimpleVolumeSamplersAllInternalBackwards(); void testPagedVolumeSamplersAllInternalBackwards();
void testSimpleVolumeDirectAccessWithExternalBackwards(); void testPagedVolumeDirectAccessWithExternalBackwards();
void testSimpleVolumeSamplersWithExternalBackwards();*/ void testPagedVolumeSamplersWithExternalBackwards();
void testLargeVolumeDirectAccessAllInternalForwards();
void testLargeVolumeSamplersAllInternalForwards();
void testLargeVolumeDirectAccessWithExternalForwards();
void testLargeVolumeSamplersWithExternalForwards();
void testLargeVolumeDirectAccessAllInternalBackwards();
void testLargeVolumeSamplersAllInternalBackwards();
void testLargeVolumeDirectAccessWithExternalBackwards();
void testLargeVolumeSamplersWithExternalBackwards();
private: private:
PolyVox::BlockCompressor<int32_t>* m_pBlockCompressor;
PolyVox::FilePager<int32_t>* m_pFilePager; PolyVox::FilePager<int32_t>* m_pFilePager;
PolyVox::RawVolume<int32_t>* m_pRawVolume; PolyVox::RawVolume<int32_t>* m_pRawVolume;
PolyVox::SimpleVolume<int32_t>* m_pSimpleVolume; PolyVox::PagedVolume<int32_t>* m_pPagedVolume;
PolyVox::LargeVolume<int32_t>* m_pLargeVolume;
}; };
#endif #endif