aboutsummaryrefslogtreecommitdiff
path: root/src/script/cpp_api/s_mainmenu.h
diff options
context:
space:
mode:
authorsapier <Sapier at GMX dot net>2014-05-15 22:16:38 +0200
committersapier <Sapier at GMX dot net>2014-08-16 13:00:37 +0200
commitccf3985b7a1f538d9011c34551a2e887cae8a7a3 (patch)
tree68e1af06e12b7631acdceb5b7ac5561cdff930d0 /src/script/cpp_api/s_mainmenu.h
parent5f1f1151d3a9c113902630adc16cc3f4845da7ba (diff)
downloadminetest-ccf3985b7a1f538d9011c34551a2e887cae8a7a3.tar.gz
minetest-ccf3985b7a1f538d9011c34551a2e887cae8a7a3.tar.bz2
minetest-ccf3985b7a1f538d9011c34551a2e887cae8a7a3.zip
Fix inventory items blinking on item preloading
Diffstat (limited to 'src/script/cpp_api/s_mainmenu.h')
0 files changed, 0 insertions, 0 deletions
id='n122' href='#n122'>122 123 124 125 126 127 128 129 130 131 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
/*
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);