aboutsummaryrefslogtreecommitdiff
path: root/src/unittest
diff options
context:
space:
mode:
authorShadowNinja <shadowninja@minetest.net>2015-10-29 23:08:32 -0400
committerShadowNinja <shadowninja@minetest.net>2016-03-07 16:33:20 -0500
commit095db16990eea878ce01b29c1eb85a128f98381a (patch)
tree9845f990ebdb7c78c1ecf487cfa91eb29fd2b7db /src/unittest
parent725cb4eb0743a382851e011fb7de1b7d443ce51f (diff)
downloadminetest-095db16990eea878ce01b29c1eb85a128f98381a.tar.gz
minetest-095db16990eea878ce01b29c1eb85a128f98381a.tar.bz2
minetest-095db16990eea878ce01b29c1eb85a128f98381a.zip
Simplify AreaStore ID management
Diffstat (limited to 'src/unittest')
-rw-r--r--src/unittest/test_areastore.cpp28
1 files changed, 11 insertions, 17 deletions
diff --git a/src/unittest/test_areastore.cpp b/src/unittest/test_areastore.cpp
index a0dcada94..9d70d0b70 100644
--- a/src/unittest/test_areastore.cpp
+++ b/src/unittest/test_areastore.cpp
@@ -62,18 +62,15 @@ void TestAreaStore::testSpatialStore()
void TestAreaStore::genericStoreTest(AreaStore *store)
{
Area a(v3s16(-10, -3, 5), v3s16(0, 29, 7));
- a.id = 1;
Area b(v3s16(-5, -2, 5), v3s16(0, 28, 6));
- b.id = 2;
Area c(v3s16(-7, -3, 6), v3s16(-1, 27, 7));
- c.id = 3;
std::vector<Area *> res;
UASSERTEQ(size_t, store->size(), 0);
store->reserve(2); // sic
- store->insertArea(a);
- store->insertArea(b);
- store->insertArea(c);
+ store->insertArea(&a);
+ store->insertArea(&b);
+ store->insertArea(&c);
UASSERTEQ(size_t, store->size(), 3);
store->getAreasForPos(&res, v3s16(-1, 0, 6));
@@ -81,20 +78,18 @@ void TestAreaStore::genericStoreTest(AreaStore *store)
res.clear();
store->getAreasForPos(&res, v3s16(0, 0, 7));
UASSERTEQ(size_t, res.size(), 1);
- UASSERTEQ(u32, res[0]->id, 1);
res.clear();
- store->removeArea(1);
+ store->removeArea(a.id);
store->getAreasForPos(&res, v3s16(0, 0, 7));
UASSERTEQ(size_t, res.size(), 0);
res.clear();
- store->insertArea(a);
+ store->insertArea(&a);
store->getAreasForPos(&res, v3s16(0, 0, 7));
UASSERTEQ(size_t, res.size(), 1);
- UASSERTEQ(u32, res[0]->id, 1);
res.clear();
store->getAreasInArea(&res, v3s16(-10, -3, 5), v3s16(0, 29, 7), false);
@@ -109,21 +104,20 @@ void TestAreaStore::genericStoreTest(AreaStore *store)
UASSERTEQ(size_t, res.size(), 3);
res.clear();
- store->removeArea(1);
- store->removeArea(2);
- store->removeArea(3);
+ store->removeArea(a.id);
+ store->removeArea(b.id);
+ store->removeArea(c.id);
Area d(v3s16(-100, -300, -200), v3s16(-50, -200, -100));
- d.id = 4;
d.data = "Hi!";
- store->insertArea(d);
+ store->insertArea(&d);
store->getAreasForPos(&res, v3s16(-75, -250, -150));
UASSERTEQ(size_t, res.size(), 1);
- UASSERTEQ(u32, res[0]->id, 4);
UASSERTEQ(u16, res[0]->data.size(), 3);
UASSERT(strncmp(res[0]->data.c_str(), "Hi!", 3) == 0);
res.clear();
- store->removeArea(4);
+ store->removeArea(d.id);
}
+