aboutsummaryrefslogtreecommitdiff
path: root/games/minimal/mods/default/textures/default_mineral_coal.png
blob: 0f52062af1a21000deab8c6f02cde775efd724bd (plain)
ofshex dumpascii
0000 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 00 10 00 00 00 10 02 03 00 00 00 62 9d 17 .PNG........IHDR.............b..
0020 f2 00 00 00 09 50 4c 54 45 00 00 00 24 24 24 2e 2e 2e e1 4d 70 44 00 00 00 01 74 52 4e 53 00 40 .....PLTE...$$$....MpD....tRNS.@
0040 e6 d8 66 00 00 00 33 49 44 41 54 08 5b 63 60 00 83 00 30 29 02 c4 8c 4d 01 0c ac 0e 0c 70 c0 e8 ..f...3IDAT.[c`...0)...M.....p..
0060 c0 c0 1a 9a 35 85 81 61 15 4c 44 d4 41 00 48 b2 66 41 15 41 15 33 42 8c 00 00 db 41 05 6a a7 2b ....5..a.LD.A.H.fA.A.3B....A.j.+
0080 d0 8f 00 00 00 00 49 45 4e 44 ae 42 60 82 ......IEND.B`.
/a> 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
/*
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 "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();
};

static TestAreaStore g_test_instance;

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

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

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));
	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);
	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);
	UASSERTEQ(u32, res[0]->id, 1);
	res.clear();

	store->removeArea(1);

	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);
	UASSERTEQ(u32, res[0]->id, 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();

	store->removeArea(1);
	store->removeArea(2);
	store->removeArea(3);

	Area d(v3s16(-100, -300, -200), v3s16(-50, -200, -100));
	d.id = 4;
	d.data = "Hi!";
	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);
}