From 4779f917871562f585085a5a2dd30015d235775b Mon Sep 17 00:00:00 2001 From: David Williams Date: Sat, 20 Sep 2014 14:49:12 +0200 Subject: [PATCH] TestVolume unit test now tests PagedVolume rather than SimpleVolume and LargeVolume. --- tests/testvolume.cpp | 141 ++++++++----------------------------------- tests/testvolume.h | 31 +++------- 2 files changed, 34 insertions(+), 138 deletions(-) diff --git a/tests/testvolume.cpp b/tests/testvolume.cpp index 28703eb3..4007c6ed 100644 --- a/tests/testvolume.cpp +++ b/tests/testvolume.cpp @@ -24,9 +24,8 @@ freely, subject to the following restrictions: #include "testvolume.h" #include "PolyVoxCore/FilePager.h" -#include "PolyVoxCore/LargeVolume.h" +#include "PolyVoxCore/PagedVolume.h" #include "PolyVoxCore/RawVolume.h" -#include "PolyVoxCore/SimpleVolume.h" #include #include @@ -274,10 +273,9 @@ TestVolume::TestVolume() //Create the volumes m_pRawVolume = new RawVolume(region); - m_pSimpleVolume = new SimpleVolume(region); - m_pLargeVolume = new LargeVolume(region, m_pFilePager, 32); + m_pPagedVolume = new LargeVolume(region, m_pFilePager, 32); - m_pLargeVolume->setMemoryUsageLimit(1 * 1024 * 1024); + m_pPagedVolume->setMemoryUsageLimit(1 * 1024 * 1024); //Fill the volume with some data for(int z = region.getLowerZ(); z <= region.getUpperZ(); z++) @@ -288,8 +286,7 @@ TestVolume::TestVolume() { int32_t value = x + y + z; m_pRawVolume->setVoxelAt(x, y, z, value); - m_pSimpleVolume->setVoxelAt(x, y, z, value); - m_pLargeVolume->setVoxelAt(x, y, z, value); + m_pPagedVolume->setVoxelAt(x, y, z, value); } } } @@ -298,18 +295,16 @@ TestVolume::TestVolume() TestVolume::~TestVolume() { delete m_pRawVolume; - delete m_pSimpleVolume; - delete m_pLargeVolume; + delete m_pPagedVolume; delete m_pFilePager; - delete m_pBlockCompressor; } /* * RawVolume Tests */ -/*void TestVolume::testRawVolumeDirectAccessAllInternalForwards() +void TestVolume::testRawVolumeDirectAccessAllInternalForwards() { int32_t result = 0; @@ -395,176 +390,88 @@ void TestVolume::testRawVolumeSamplersWithExternalBackwards() result = testSamplersWithWrappingBackwards(m_pRawVolume, -1, -3, -2, 2, 5, 4); } QCOMPARE(result, static_cast(-769775893)); -}*/ +} /* - * SimpleVolume Tests + * PagedVolume Tests */ -/*void TestVolume::testSimpleVolumeDirectAccessAllInternalForwards() +void TestVolume::testPagedVolumeDirectAccessAllInternalForwards() { int32_t result = 0; 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(1004598054)); } -void TestVolume::testSimpleVolumeSamplersAllInternalForwards() +void TestVolume::testPagedVolumeSamplersAllInternalForwards() { int32_t result = 0; 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(1004598054)); } -void TestVolume::testSimpleVolumeDirectAccessWithExternalForwards() +void TestVolume::testPagedVolumeDirectAccessWithExternalForwards() { int32_t result = 0; 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(-928601007)); } -void TestVolume::testSimpleVolumeSamplersWithExternalForwards() +void TestVolume::testPagedVolumeSamplersWithExternalForwards() { int32_t result = 0; 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(-928601007)); } -void TestVolume::testSimpleVolumeDirectAccessAllInternalBackwards() +void TestVolume::testPagedVolumeDirectAccessAllInternalBackwards() { int32_t result = 0; 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(-269366578)); } -void TestVolume::testSimpleVolumeSamplersAllInternalBackwards() +void TestVolume::testPagedVolumeSamplersAllInternalBackwards() { int32_t result = 0; 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(-269366578)); } -void TestVolume::testSimpleVolumeDirectAccessWithExternalBackwards() +void TestVolume::testPagedVolumeDirectAccessWithExternalBackwards() { int32_t result = 0; 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(-769775893)); } -void TestVolume::testSimpleVolumeSamplersWithExternalBackwards() +void TestVolume::testPagedVolumeSamplersWithExternalBackwards() { int32_t result = 0; QBENCHMARK { - result = testSamplersWithWrappingBackwards(m_pSimpleVolume, -1, -3, -2, 2, 5, 4); - } - QCOMPARE(result, static_cast(-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(1004598054)); -} - -void TestVolume::testLargeVolumeSamplersAllInternalForwards() -{ - int32_t result = 0; - - QBENCHMARK - { - result = testSamplersWithWrappingForwards(m_pLargeVolume, 4, 2, 2, -3, -1, -2); - } - QCOMPARE(result, static_cast(1004598054)); -} - -void TestVolume::testLargeVolumeDirectAccessWithExternalForwards() -{ - int32_t result = 0; - QBENCHMARK - { - result = testDirectAccessWithWrappingForwards(m_pLargeVolume, -1, -3, -2, 2, 5, 4); - } - QCOMPARE(result, static_cast(-928601007)); -} - -void TestVolume::testLargeVolumeSamplersWithExternalForwards() -{ - int32_t result = 0; - - QBENCHMARK - { - result = testSamplersWithWrappingForwards(m_pLargeVolume, -1, -3, -2, 2, 5, 4); - } - QCOMPARE(result, static_cast(-928601007)); -} - -void TestVolume::testLargeVolumeDirectAccessAllInternalBackwards() -{ - int32_t result = 0; - QBENCHMARK - { - result = testDirectAccessWithWrappingBackwards(m_pLargeVolume, 4, 2, 2, -3, -1, -2); - } - QCOMPARE(result, static_cast(-269366578)); -} - -void TestVolume::testLargeVolumeSamplersAllInternalBackwards() -{ - int32_t result = 0; - - QBENCHMARK - { - result = testSamplersWithWrappingBackwards(m_pLargeVolume, 4, 2, 2, -3, -1, -2); - } - QCOMPARE(result, static_cast(-269366578)); -} - -void TestVolume::testLargeVolumeDirectAccessWithExternalBackwards() -{ - int32_t result = 0; - QBENCHMARK - { - result = testDirectAccessWithWrappingBackwards(m_pLargeVolume, -1, -3, -2, 2, 5, 4); - } - QCOMPARE(result, static_cast(-769775893)); -} - -void TestVolume::testLargeVolumeSamplersWithExternalBackwards() -{ - int32_t result = 0; - - QBENCHMARK - { - result = testSamplersWithWrappingBackwards(m_pLargeVolume, -1, -3, -2, 2, 5, 4); + result = testSamplersWithWrappingBackwards(m_pPagedVolume, -1, -3, -2, 2, 5, 4); } QCOMPARE(result, static_cast(-769775893)); } diff --git a/tests/testvolume.h b/tests/testvolume.h index 57390641..ea1a1d0b 100644 --- a/tests/testvolume.h +++ b/tests/testvolume.h @@ -37,7 +37,7 @@ public: ~TestVolume(); private slots: - /*void testRawVolumeDirectAccessAllInternalForwards(); + void testRawVolumeDirectAccessAllInternalForwards(); void testRawVolumeSamplersAllInternalForwards(); void testRawVolumeDirectAccessWithExternalForwards(); void testRawVolumeSamplersWithExternalForwards(); @@ -46,31 +46,20 @@ private slots: void testRawVolumeDirectAccessWithExternalBackwards(); void testRawVolumeSamplersWithExternalBackwards(); - void testSimpleVolumeDirectAccessAllInternalForwards(); - void testSimpleVolumeSamplersAllInternalForwards(); - void testSimpleVolumeDirectAccessWithExternalForwards(); - void testSimpleVolumeSamplersWithExternalForwards(); - void testSimpleVolumeDirectAccessAllInternalBackwards(); - void testSimpleVolumeSamplersAllInternalBackwards(); - void testSimpleVolumeDirectAccessWithExternalBackwards(); - void testSimpleVolumeSamplersWithExternalBackwards();*/ - - void testLargeVolumeDirectAccessAllInternalForwards(); - void testLargeVolumeSamplersAllInternalForwards(); - void testLargeVolumeDirectAccessWithExternalForwards(); - void testLargeVolumeSamplersWithExternalForwards(); - void testLargeVolumeDirectAccessAllInternalBackwards(); - void testLargeVolumeSamplersAllInternalBackwards(); - void testLargeVolumeDirectAccessWithExternalBackwards(); - void testLargeVolumeSamplersWithExternalBackwards(); + void testPagedVolumeDirectAccessAllInternalForwards(); + void testPagedVolumeSamplersAllInternalForwards(); + void testPagedVolumeDirectAccessWithExternalForwards(); + void testPagedVolumeSamplersWithExternalForwards(); + void testPagedVolumeDirectAccessAllInternalBackwards(); + void testPagedVolumeSamplersAllInternalBackwards(); + void testPagedVolumeDirectAccessWithExternalBackwards(); + void testPagedVolumeSamplersWithExternalBackwards(); private: - PolyVox::BlockCompressor* m_pBlockCompressor; PolyVox::FilePager* m_pFilePager; PolyVox::RawVolume* m_pRawVolume; - PolyVox::SimpleVolume* m_pSimpleVolume; - PolyVox::LargeVolume* m_pLargeVolume; + PolyVox::PagedVolume* m_pPagedVolume; }; #endif