1f3b31017b3c5068126a67451d89bc9f581ac9f4
[oweals/minetest.git] / src / unittest / test.cpp
1 /*
2 Minetest
3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #include "test.h"
21
22 #include "log.h"
23 #include "nodedef.h"
24 #include "itemdef.h"
25 #include "gamedef.h"
26
27 content_t t_CONTENT_STONE;
28 content_t t_CONTENT_GRASS;
29 content_t t_CONTENT_TORCH;
30 content_t t_CONTENT_WATER;
31 content_t t_CONTENT_LAVA;
32 content_t t_CONTENT_BRICK;
33
34 ////////////////////////////////////////////////////////////////////////////////
35
36 ////
37 //// TestGameDef
38 ////
39
40 class TestGameDef : public IGameDef {
41 public:
42         TestGameDef();
43         ~TestGameDef();
44
45         IItemDefManager *getItemDefManager() { return m_itemdef; }
46         INodeDefManager *getNodeDefManager() { return m_nodedef; }
47         ICraftDefManager *getCraftDefManager() { return m_craftdef; }
48         ITextureSource *getTextureSource() { return m_texturesrc; }
49         IShaderSource *getShaderSource() { return m_shadersrc; }
50         ISoundManager *getSoundManager() { return m_soundmgr; }
51         MtEventManager *getEventManager() { return m_eventmgr; }
52         scene::ISceneManager *getSceneManager() { return m_scenemgr; }
53         IRollbackManager *getRollbackManager() { return m_rollbackmgr; }
54         EmergeManager *getEmergeManager() { return m_emergemgr; }
55
56         scene::IAnimatedMesh *getMesh(const std::string &filename) { return NULL; }
57         bool checkLocalPrivilege(const std::string &priv) { return false; }
58         u16 allocateUnknownNodeId(const std::string &name) { return 0; }
59
60         void defineSomeNodes();
61
62 private:
63         IItemDefManager *m_itemdef;
64         INodeDefManager *m_nodedef;
65         ICraftDefManager *m_craftdef;
66         ITextureSource *m_texturesrc;
67         IShaderSource *m_shadersrc;
68         ISoundManager *m_soundmgr;
69         MtEventManager *m_eventmgr;
70         scene::ISceneManager *m_scenemgr;
71         IRollbackManager *m_rollbackmgr;
72         EmergeManager *m_emergemgr;
73 };
74
75
76 TestGameDef::TestGameDef()
77 {
78         m_itemdef = createItemDefManager();
79         m_nodedef = createNodeDefManager();
80
81         defineSomeNodes();
82 }
83
84
85 TestGameDef::~TestGameDef()
86 {
87         delete m_itemdef;
88         delete m_nodedef;
89 }
90
91
92 void TestGameDef::defineSomeNodes()
93 {
94         IWritableItemDefManager *idef = (IWritableItemDefManager *)m_itemdef;
95         IWritableNodeDefManager *ndef = (IWritableNodeDefManager *)m_nodedef;
96
97         ItemDefinition itemdef;
98         ContentFeatures f;
99
100         //// Stone
101         itemdef = ItemDefinition();
102         itemdef.type = ITEM_NODE;
103         itemdef.name = "default:stone";
104         itemdef.description = "Stone";
105         itemdef.groups["cracky"] = 3;
106         itemdef.inventory_image = "[inventorycube"
107                 "{default_stone.png"
108                 "{default_stone.png"
109                 "{default_stone.png";
110         f = ContentFeatures();
111         f.name = itemdef.name;
112         for(int i = 0; i < 6; i++)
113                 f.tiledef[i].name = "default_stone.png";
114         f.is_ground_content = true;
115         idef->registerItem(itemdef);
116         t_CONTENT_STONE = ndef->set(f.name, f);
117
118         //// Grass
119         itemdef = ItemDefinition();
120         itemdef.type = ITEM_NODE;
121         itemdef.name = "default:dirt_with_grass";
122         itemdef.description = "Dirt with grass";
123         itemdef.groups["crumbly"] = 3;
124         itemdef.inventory_image = "[inventorycube"
125                 "{default_grass.png"
126                 "{default_dirt.png&default_grass_side.png"
127                 "{default_dirt.png&default_grass_side.png";
128         f = ContentFeatures();
129         f.name = itemdef.name;
130         f.tiledef[0].name = "default_grass.png";
131         f.tiledef[1].name = "default_dirt.png";
132         for(int i = 2; i < 6; i++)
133                 f.tiledef[i].name = "default_dirt.png^default_grass_side.png";
134         f.is_ground_content = true;
135         idef->registerItem(itemdef);
136         t_CONTENT_GRASS = ndef->set(f.name, f);
137
138         //// Torch (minimal definition for lighting tests)
139         itemdef = ItemDefinition();
140         itemdef.type = ITEM_NODE;
141         itemdef.name = "default:torch";
142         f = ContentFeatures();
143         f.name = itemdef.name;
144         f.param_type = CPT_LIGHT;
145         f.light_propagates = true;
146         f.sunlight_propagates = true;
147         f.light_source = LIGHT_MAX-1;
148         idef->registerItem(itemdef);
149         t_CONTENT_TORCH = ndef->set(f.name, f);
150
151         //// Water
152         itemdef = ItemDefinition();
153         itemdef.type = ITEM_NODE;
154         itemdef.name = "default:water";
155         itemdef.description = "Water";
156         itemdef.inventory_image = "[inventorycube"
157                 "{default_water.png"
158                 "{default_water.png"
159                 "{default_water.png";
160         f = ContentFeatures();
161         f.name = itemdef.name;
162         f.alpha = 128;
163         f.liquid_type = LIQUID_SOURCE;
164         f.liquid_viscosity = 4;
165         f.is_ground_content = true;
166         f.groups["liquids"] = 3;
167         for(int i = 0; i < 6; i++)
168                 f.tiledef[i].name = "default_water.png";
169         idef->registerItem(itemdef);
170         t_CONTENT_WATER = ndef->set(f.name, f);
171
172         //// Lava
173         itemdef = ItemDefinition();
174         itemdef.type = ITEM_NODE;
175         itemdef.name = "default:lava";
176         itemdef.description = "Lava";
177         itemdef.inventory_image = "[inventorycube"
178                 "{default_lava.png"
179                 "{default_lava.png"
180                 "{default_lava.png";
181         f = ContentFeatures();
182         f.name = itemdef.name;
183         f.alpha = 128;
184         f.liquid_type = LIQUID_SOURCE;
185         f.liquid_viscosity = 7;
186         f.light_source = LIGHT_MAX-1;
187         f.is_ground_content = true;
188         f.groups["liquids"] = 3;
189         for(int i = 0; i < 6; i++)
190                 f.tiledef[i].name = "default_lava.png";
191         idef->registerItem(itemdef);
192         t_CONTENT_LAVA = ndef->set(f.name, f);
193
194
195         //// Brick
196         itemdef = ItemDefinition();
197         itemdef.type = ITEM_NODE;
198         itemdef.name = "default:brick";
199         itemdef.description = "Brick";
200         itemdef.groups["cracky"] = 3;
201         itemdef.inventory_image = "[inventorycube"
202                 "{default_brick.png"
203                 "{default_brick.png"
204                 "{default_brick.png";
205         f = ContentFeatures();
206         f.name = itemdef.name;
207         for(int i = 0; i < 6; i++)
208                 f.tiledef[i].name = "default_brick.png";
209         f.is_ground_content = true;
210         idef->registerItem(itemdef);
211         t_CONTENT_BRICK = ndef->set(f.name, f);
212 }
213
214 ////
215 //// run_tests
216 ////
217
218 void run_tests()
219 {
220         DSTACK(FUNCTION_NAME);
221
222         u32 t1 = porting::getTime(PRECISION_MILLI);
223         TestGameDef gamedef;
224
225         g_logger.setLevelSilenced(LL_ERROR, true);
226
227         u32 num_modules_failed     = 0;
228         u32 num_total_tests_failed = 0;
229         u32 num_total_tests_run    = 0;
230         std::vector<TestBase *> &testmods = TestManager::getTestModules();
231         for (size_t i = 0; i != testmods.size(); i++) {
232                 if (!testmods[i]->testModule(&gamedef))
233                         num_modules_failed++;
234
235                 num_total_tests_failed += testmods[i]->num_tests_failed;
236                 num_total_tests_run += testmods[i]->num_tests_run;
237         }
238
239         u32 tdiff = porting::getTime(PRECISION_MILLI) - t1;
240
241         g_logger.setLevelSilenced(LL_ERROR, false);
242
243         const char *overall_status = (num_modules_failed == 0) ? "PASSED" : "FAILED";
244
245         rawstream
246                 << "++++++++++++++++++++++++++++++++++++++++"
247                 << "++++++++++++++++++++++++++++++++++++++++" << std::endl
248                 << "Unit Test Results: " << overall_status << std::endl
249                 << "    " << num_modules_failed << " / " << testmods.size()
250                 << " failed modules (" << num_total_tests_failed << " / "
251                 << num_total_tests_run << " failed individual tests)." << std::endl
252                 << "    Testing took " << tdiff << "ms total." << std::endl
253                 << "++++++++++++++++++++++++++++++++++++++++"
254                 << "++++++++++++++++++++++++++++++++++++++++" << std::endl;
255
256         if (num_modules_failed)
257                 abort();
258 }
259
260 ////
261 //// TestBase
262 ////
263
264 bool TestBase::testModule(IGameDef *gamedef)
265 {
266         rawstream << "======== Testing module " << getName() << std::endl;
267         u32 t1 = porting::getTime(PRECISION_MILLI);
268
269
270         runTests(gamedef);
271
272         u32 tdiff = porting::getTime(PRECISION_MILLI) - t1;
273         rawstream << "======== Module " << getName() << " "
274                 << (num_tests_failed ? "failed" : "passed") << " (" << num_tests_failed
275                 << " failures / " << num_tests_run << " tests) - " << tdiff
276                 << "ms" << std::endl;
277
278         if (!m_test_dir.empty())
279                 fs::RecursiveDelete(m_test_dir);
280
281         return num_tests_failed == 0;
282 }
283
284 std::string TestBase::getTestTempDirectory()
285 {
286         if (!m_test_dir.empty())
287                 return m_test_dir;
288
289         char buf[32];
290         snprintf(buf, sizeof(buf), "%08X", myrand());
291
292         m_test_dir = fs::TempPath() + DIR_DELIM "mttest_" + buf;
293         if (!fs::CreateDir(m_test_dir))
294                 throw TestFailedException();
295
296         return m_test_dir;
297 }
298
299 std::string TestBase::getTestTempFile()
300 {
301         char buf[32];
302         snprintf(buf, sizeof(buf), "%08X", myrand());
303
304         return getTestTempDirectory() + DIR_DELIM + buf + ".tmp";
305 }
306
307
308 /*
309         NOTE: These tests became non-working then NodeContainer was removed.
310               These should be redone, utilizing some kind of a virtual
311                   interface for Map (IMap would be fine).
312 */
313 #if 0
314 struct TestMapBlock: public TestBase
315 {
316         class TC : public NodeContainer
317         {
318         public:
319
320                 MapNode node;
321                 bool position_valid;
322                 core::list<v3s16> validity_exceptions;
323
324                 TC()
325                 {
326                         position_valid = true;
327                 }
328
329                 virtual bool isValidPosition(v3s16 p)
330                 {
331                         //return position_valid ^ (p==position_valid_exception);
332                         bool exception = false;
333                         for(core::list<v3s16>::Iterator i=validity_exceptions.begin();
334                                         i != validity_exceptions.end(); i++)
335                         {
336                                 if(p == *i)
337                                 {
338                                         exception = true;
339                                         break;
340                                 }
341                         }
342                         return exception ? !position_valid : position_valid;
343                 }
344
345                 virtual MapNode getNode(v3s16 p)
346                 {
347                         if(isValidPosition(p) == false)
348                                 throw InvalidPositionException();
349                         return node;
350                 }
351
352                 virtual void setNode(v3s16 p, MapNode & n)
353                 {
354                         if(isValidPosition(p) == false)
355                                 throw InvalidPositionException();
356                 };
357
358                 virtual u16 nodeContainerId() const
359                 {
360                         return 666;
361                 }
362         };
363
364         void Run()
365         {
366                 TC parent;
367
368                 MapBlock b(&parent, v3s16(1,1,1));
369                 v3s16 relpos(MAP_BLOCKSIZE, MAP_BLOCKSIZE, MAP_BLOCKSIZE);
370
371                 UASSERT(b.getPosRelative() == relpos);
372
373                 UASSERT(b.getBox().MinEdge.X == MAP_BLOCKSIZE);
374                 UASSERT(b.getBox().MaxEdge.X == MAP_BLOCKSIZE*2-1);
375                 UASSERT(b.getBox().MinEdge.Y == MAP_BLOCKSIZE);
376                 UASSERT(b.getBox().MaxEdge.Y == MAP_BLOCKSIZE*2-1);
377                 UASSERT(b.getBox().MinEdge.Z == MAP_BLOCKSIZE);
378                 UASSERT(b.getBox().MaxEdge.Z == MAP_BLOCKSIZE*2-1);
379
380                 UASSERT(b.isValidPosition(v3s16(0,0,0)) == true);
381                 UASSERT(b.isValidPosition(v3s16(-1,0,0)) == false);
382                 UASSERT(b.isValidPosition(v3s16(-1,-142,-2341)) == false);
383                 UASSERT(b.isValidPosition(v3s16(-124,142,2341)) == false);
384                 UASSERT(b.isValidPosition(v3s16(MAP_BLOCKSIZE-1,MAP_BLOCKSIZE-1,MAP_BLOCKSIZE-1)) == true);
385                 UASSERT(b.isValidPosition(v3s16(MAP_BLOCKSIZE-1,MAP_BLOCKSIZE,MAP_BLOCKSIZE-1)) == false);
386
387                 /*
388                         TODO: this method should probably be removed
389                         if the block size isn't going to be set variable
390                 */
391                 /*UASSERT(b.getSizeNodes() == v3s16(MAP_BLOCKSIZE,
392                                 MAP_BLOCKSIZE, MAP_BLOCKSIZE));*/
393
394                 // Changed flag should be initially set
395                 UASSERT(b.getModified() == MOD_STATE_WRITE_NEEDED);
396                 b.resetModified();
397                 UASSERT(b.getModified() == MOD_STATE_CLEAN);
398
399                 // All nodes should have been set to
400                 // .d=CONTENT_IGNORE and .getLight() = 0
401                 for(u16 z=0; z<MAP_BLOCKSIZE; z++)
402                 for(u16 y=0; y<MAP_BLOCKSIZE; y++)
403                 for(u16 x=0; x<MAP_BLOCKSIZE; x++)
404                 {
405                         //UASSERT(b.getNode(v3s16(x,y,z)).getContent() == CONTENT_AIR);
406                         UASSERT(b.getNode(v3s16(x,y,z)).getContent() == CONTENT_IGNORE);
407                         UASSERT(b.getNode(v3s16(x,y,z)).getLight(LIGHTBANK_DAY) == 0);
408                         UASSERT(b.getNode(v3s16(x,y,z)).getLight(LIGHTBANK_NIGHT) == 0);
409                 }
410
411                 {
412                         MapNode n(CONTENT_AIR);
413                         for(u16 z=0; z<MAP_BLOCKSIZE; z++)
414                         for(u16 y=0; y<MAP_BLOCKSIZE; y++)
415                         for(u16 x=0; x<MAP_BLOCKSIZE; x++)
416                         {
417                                 b.setNode(v3s16(x,y,z), n);
418                         }
419                 }
420
421                 /*
422                         Parent fetch functions
423                 */
424                 parent.position_valid = false;
425                 parent.node.setContent(5);
426
427                 MapNode n;
428
429                 // Positions in the block should still be valid
430                 UASSERT(b.isValidPositionParent(v3s16(0,0,0)) == true);
431                 UASSERT(b.isValidPositionParent(v3s16(MAP_BLOCKSIZE-1,MAP_BLOCKSIZE-1,MAP_BLOCKSIZE-1)) == true);
432                 n = b.getNodeParent(v3s16(0,MAP_BLOCKSIZE-1,0));
433                 UASSERT(n.getContent() == CONTENT_AIR);
434
435                 // ...but outside the block they should be invalid
436                 UASSERT(b.isValidPositionParent(v3s16(-121,2341,0)) == false);
437                 UASSERT(b.isValidPositionParent(v3s16(-1,0,0)) == false);
438                 UASSERT(b.isValidPositionParent(v3s16(MAP_BLOCKSIZE-1,MAP_BLOCKSIZE-1,MAP_BLOCKSIZE)) == false);
439
440                 {
441                         bool exception_thrown = false;
442                         try{
443                                 // This should throw an exception
444                                 MapNode n = b.getNodeParent(v3s16(0,0,-1));
445                         }
446                         catch(InvalidPositionException &e)
447                         {
448                                 exception_thrown = true;
449                         }
450                         UASSERT(exception_thrown);
451                 }
452
453                 parent.position_valid = true;
454                 // Now the positions outside should be valid
455                 UASSERT(b.isValidPositionParent(v3s16(-121,2341,0)) == true);
456                 UASSERT(b.isValidPositionParent(v3s16(-1,0,0)) == true);
457                 UASSERT(b.isValidPositionParent(v3s16(MAP_BLOCKSIZE-1,MAP_BLOCKSIZE-1,MAP_BLOCKSIZE)) == true);
458                 n = b.getNodeParent(v3s16(0,0,MAP_BLOCKSIZE));
459                 UASSERT(n.getContent() == 5);
460
461                 /*
462                         Set a node
463                 */
464                 v3s16 p(1,2,0);
465                 n.setContent(4);
466                 b.setNode(p, n);
467                 UASSERT(b.getNode(p).getContent() == 4);
468                 //TODO: Update to new system
469                 /*UASSERT(b.getNodeTile(p) == 4);
470                 UASSERT(b.getNodeTile(v3s16(-1,-1,0)) == 5);*/
471
472                 /*
473                         propagateSunlight()
474                 */
475                 // Set lighting of all nodes to 0
476                 for(u16 z=0; z<MAP_BLOCKSIZE; z++){
477                         for(u16 y=0; y<MAP_BLOCKSIZE; y++){
478                                 for(u16 x=0; x<MAP_BLOCKSIZE; x++){
479                                         MapNode n = b.getNode(v3s16(x,y,z));
480                                         n.setLight(LIGHTBANK_DAY, 0);
481                                         n.setLight(LIGHTBANK_NIGHT, 0);
482                                         b.setNode(v3s16(x,y,z), n);
483                                 }
484                         }
485                 }
486                 {
487                         /*
488                                 Check how the block handles being a lonely sky block
489                         */
490                         parent.position_valid = true;
491                         b.setIsUnderground(false);
492                         parent.node.setContent(CONTENT_AIR);
493                         parent.node.setLight(LIGHTBANK_DAY, LIGHT_SUN);
494                         parent.node.setLight(LIGHTBANK_NIGHT, 0);
495                         core::map<v3s16, bool> light_sources;
496                         // The bottom block is invalid, because we have a shadowing node
497                         UASSERT(b.propagateSunlight(light_sources) == false);
498                         UASSERT(b.getNode(v3s16(1,4,0)).getLight(LIGHTBANK_DAY) == LIGHT_SUN);
499                         UASSERT(b.getNode(v3s16(1,3,0)).getLight(LIGHTBANK_DAY) == LIGHT_SUN);
500                         UASSERT(b.getNode(v3s16(1,2,0)).getLight(LIGHTBANK_DAY) == 0);
501                         UASSERT(b.getNode(v3s16(1,1,0)).getLight(LIGHTBANK_DAY) == 0);
502                         UASSERT(b.getNode(v3s16(1,0,0)).getLight(LIGHTBANK_DAY) == 0);
503                         UASSERT(b.getNode(v3s16(1,2,3)).getLight(LIGHTBANK_DAY) == LIGHT_SUN);
504                         UASSERT(b.getFaceLight2(1000, p, v3s16(0,1,0)) == LIGHT_SUN);
505                         UASSERT(b.getFaceLight2(1000, p, v3s16(0,-1,0)) == 0);
506                         UASSERT(b.getFaceLight2(0, p, v3s16(0,-1,0)) == 0);
507                         // According to MapBlock::getFaceLight,
508                         // The face on the z+ side should have double-diminished light
509                         //UASSERT(b.getFaceLight(p, v3s16(0,0,1)) == diminish_light(diminish_light(LIGHT_MAX)));
510                         // The face on the z+ side should have diminished light
511                         UASSERT(b.getFaceLight2(1000, p, v3s16(0,0,1)) == diminish_light(LIGHT_MAX));
512                 }
513                 /*
514                         Check how the block handles being in between blocks with some non-sunlight
515                         while being underground
516                 */
517                 {
518                         // Make neighbours to exist and set some non-sunlight to them
519                         parent.position_valid = true;
520                         b.setIsUnderground(true);
521                         parent.node.setLight(LIGHTBANK_DAY, LIGHT_MAX/2);
522                         core::map<v3s16, bool> light_sources;
523                         // The block below should be valid because there shouldn't be
524                         // sunlight in there either
525                         UASSERT(b.propagateSunlight(light_sources, true) == true);
526                         // Should not touch nodes that are not affected (that is, all of them)
527                         //UASSERT(b.getNode(v3s16(1,2,3)).getLight() == LIGHT_SUN);
528                         // Should set light of non-sunlighted blocks to 0.
529                         UASSERT(b.getNode(v3s16(1,2,3)).getLight(LIGHTBANK_DAY) == 0);
530                 }
531                 /*
532                         Set up a situation where:
533                         - There is only air in this block
534                         - There is a valid non-sunlighted block at the bottom, and
535                         - Invalid blocks elsewhere.
536                         - the block is not underground.
537
538                         This should result in bottom block invalidity
539                 */
540                 {
541                         b.setIsUnderground(false);
542                         // Clear block
543                         for(u16 z=0; z<MAP_BLOCKSIZE; z++){
544                                 for(u16 y=0; y<MAP_BLOCKSIZE; y++){
545                                         for(u16 x=0; x<MAP_BLOCKSIZE; x++){
546                                                 MapNode n;
547                                                 n.setContent(CONTENT_AIR);
548                                                 n.setLight(LIGHTBANK_DAY, 0);
549                                                 b.setNode(v3s16(x,y,z), n);
550                                         }
551                                 }
552                         }
553                         // Make neighbours invalid
554                         parent.position_valid = false;
555                         // Add exceptions to the top of the bottom block
556                         for(u16 x=0; x<MAP_BLOCKSIZE; x++)
557                         for(u16 z=0; z<MAP_BLOCKSIZE; z++)
558                         {
559                                 parent.validity_exceptions.push_back(v3s16(MAP_BLOCKSIZE+x, MAP_BLOCKSIZE-1, MAP_BLOCKSIZE+z));
560                         }
561                         // Lighting value for the valid nodes
562                         parent.node.setLight(LIGHTBANK_DAY, LIGHT_MAX/2);
563                         core::map<v3s16, bool> light_sources;
564                         // Bottom block is not valid
565                         UASSERT(b.propagateSunlight(light_sources) == false);
566                 }
567         }
568 };
569
570 struct TestMapSector: public TestBase
571 {
572         class TC : public NodeContainer
573         {
574         public:
575
576                 MapNode node;
577                 bool position_valid;
578
579                 TC()
580                 {
581                         position_valid = true;
582                 }
583
584                 virtual bool isValidPosition(v3s16 p)
585                 {
586                         return position_valid;
587                 }
588
589                 virtual MapNode getNode(v3s16 p)
590                 {
591                         if(position_valid == false)
592                                 throw InvalidPositionException();
593                         return node;
594                 }
595
596                 virtual void setNode(v3s16 p, MapNode & n)
597                 {
598                         if(position_valid == false)
599                                 throw InvalidPositionException();
600                 };
601
602                 virtual u16 nodeContainerId() const
603                 {
604                         return 666;
605                 }
606         };
607
608         void Run()
609         {
610                 TC parent;
611                 parent.position_valid = false;
612
613                 // Create one with no heightmaps
614                 ServerMapSector sector(&parent, v2s16(1,1));
615
616                 UASSERT(sector.getBlockNoCreateNoEx(0) == 0);
617                 UASSERT(sector.getBlockNoCreateNoEx(1) == 0);
618
619                 MapBlock * bref = sector.createBlankBlock(-2);
620
621                 UASSERT(sector.getBlockNoCreateNoEx(0) == 0);
622                 UASSERT(sector.getBlockNoCreateNoEx(-2) == bref);
623
624                 //TODO: Check for AlreadyExistsException
625
626                 /*bool exception_thrown = false;
627                 try{
628                         sector.getBlock(0);
629                 }
630                 catch(InvalidPositionException &e){
631                         exception_thrown = true;
632                 }
633                 UASSERT(exception_thrown);*/
634
635         }
636 };
637 #endif