aboutsummaryrefslogtreecommitdiff
path: root/src/threading/semaphore.cpp
diff options
context:
space:
mode:
authorLoïc Blot <nerzhul@users.noreply.github.com>2017-05-07 12:13:15 +0200
committerGitHub <noreply@github.com>2017-05-07 12:13:15 +0200
commitc1b3ed4180dea16e2fa77663a7d2bf155595dd60 (patch)
tree2cb74486cb3a493716be611ca4cf44d666dec3bf /src/threading/semaphore.cpp
parent0d7c37943bf29b2c4956576c15efa796d5b5f2d4 (diff)
downloadminetest-c1b3ed4180dea16e2fa77663a7d2bf155595dd60.tar.gz
minetest-c1b3ed4180dea16e2fa77663a7d2bf155595dd60.tar.bz2
minetest-c1b3ed4180dea16e2fa77663a7d2bf155595dd60.zip
Player attrs: permits to remove an attribute by setting value to nil (#5716)
* Player attrs: permits to remove an attribute by setting value to nil When doing player:set_attribute("attr", nil) remove attribute Also remove a useless check on C++ API part (already done by checkplayer) Fix #5709
Diffstat (limited to 'src/threading/semaphore.cpp')
0 files changed, 0 insertions, 0 deletions
='n132' href='#n132'>132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
/*
Minetest
Copyright (C) 2015 est31, <MTest31@outlook.com>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#include "test.h"

#include "util/areastore.h"

class TestAreaStore : public TestBase {
public:
	TestAreaStore() { TestManager::registerTestModule(this); }
	const char *getName() { return "TestAreaStore"; }

	void runTests(IGameDef *gamedef);

	void genericStoreTest(AreaStore *store);
	void testVectorStore();
	void testSpatialStore();
	void testSerialization();
};

static TestAreaStore g_test_instance;

void TestAreaStore::runTests(IGameDef *gamedef)
{
	TEST(testVectorStore);
#if USE_SPATIAL
	TEST(testSpatialStore);
#endif
	TEST(testSerialization);
}

////////////////////////////////////////////////////////////////////////////////

void TestAreaStore::testVectorStore()
{
	VectorAreaStore store;
	genericStoreTest(&store);
}

void TestAreaStore::testSpatialStore()
{
#if USE_SPATIAL
	SpatialAreaStore store;
	genericStoreTest(&store);
#endif
}

void TestAreaStore::genericStoreTest(AreaStore *store)
{
	Area a(v3s16(-10, -3, 5), v3s16(0, 29, 7));
	Area b(v3s16(-5, -2, 5), v3s16(0, 28, 6));
	Area c(v3s16(-7, -3, 6), v3s16(-1, 27, 7));
	std::vector<Area *> res;

	UASSERTEQ(size_t, store->size(), 0);
	store->reserve(2); // sic
	store->insertArea(&a);
	store->insertArea(&b);
	store->insertArea(&c);
	UASSERTEQ(size_t, store->size(), 3);

	store->getAreasForPos(&res, v3s16(-1, 0, 6));
	UASSERTEQ(size_t, res.size(), 3);
	res.clear();
	store->getAreasForPos(&res, v3s16(0, 0, 7));
	UASSERTEQ(size_t, res.size(), 1);
	res.clear();

	store->removeArea(a.id);

	store->getAreasForPos(&res, v3s16(0, 0, 7));
	UASSERTEQ(size_t, res.size(), 0);
	res.clear();

	store->insertArea(&a);

	store->getAreasForPos(&res, v3s16(0, 0, 7));
	UASSERTEQ(size_t, res.size(), 1);
	res.clear();

	store->getAreasInArea(&res, v3s16(-10, -3, 5), v3s16(0, 29, 7), false);
	UASSERTEQ(size_t, res.size(), 3);
	res.clear();

	store->getAreasInArea(&res, v3s16(-100, 0, 6), v3s16(200, 0, 6), false);
	UASSERTEQ(size_t, res.size(), 0);
	res.clear();

	store->getAreasInArea(&res, v3s16(-100, 0, 6), v3s16(200, 0, 6), true);
	UASSERTEQ(size_t, res.size(), 3);
	res.clear();