]> git.lizzy.rs Git - minetest.git/blob - src/unittest/test.cpp
Mgvalleys: use standard caves
[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 bool 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         return num_modules_failed;
257 }
258
259 ////
260 //// TestBase
261 ////
262
263 bool TestBase::testModule(IGameDef *gamedef)
264 {
265         rawstream << "======== Testing module " << getName() << std::endl;
266         u32 t1 = porting::getTime(PRECISION_MILLI);
267
268
269         runTests(gamedef);
270
271         u32 tdiff = porting::getTime(PRECISION_MILLI) - t1;
272         rawstream << "======== Module " << getName() << " "
273                 << (num_tests_failed ? "failed" : "passed") << " (" << num_tests_failed
274                 << " failures / " << num_tests_run << " tests) - " << tdiff
275                 << "ms" << std::endl;
276
277         if (!m_test_dir.empty())
278                 fs::RecursiveDelete(m_test_dir);
279
280         return num_tests_failed == 0;
281 }
282
283 std::string TestBase::getTestTempDirectory()
284 {
285         if (!m_test_dir.empty())
286                 return m_test_dir;
287
288         char buf[32];
289         snprintf(buf, sizeof(buf), "%08X", myrand());
290
291         m_test_dir = fs::TempPath() + DIR_DELIM "mttest_" + buf;
292         if (!fs::CreateDir(m_test_dir))
293                 throw TestFailedException();
294
295         return m_test_dir;
296 }
297
298 std::string TestBase::getTestTempFile()
299 {
300         char buf[32];
301         snprintf(buf, sizeof(buf), "%08X", myrand());
302
303         return getTestTempDirectory() + DIR_DELIM + buf + ".tmp";
304 }
305
306
307 /*
308         NOTE: These tests became non-working then NodeContainer was removed.
309               These should be redone, utilizing some kind of a virtual
310                   interface for Map (IMap would be fine).
311 */
312 #if 0
313 struct TestMapBlock: public TestBase
314 {
315         class TC : public NodeContainer
316         {
317         public:
318
319                 MapNode node;
320                 bool position_valid;
321                 core::list<v3s16> validity_exceptions;
322
323                 TC()
324                 {
325                         position_valid = true;
326                 }
327
328                 virtual bool isValidPosition(v3s16 p)
329                 {
330                         //return position_valid ^ (p==position_valid_exception);
331                         bool exception = false;
332                         for(core::list<v3s16>::Iterator i=validity_exceptions.begin();
333                                         i != validity_exceptions.end(); i++)
334                         {
335                                 if(p == *i)
336                                 {
337                                         exception = true;
338                                         break;
339                                 }
340                         }
341                         return exception ? !position_valid : position_valid;
342                 }
343
344                 virtual MapNode getNode(v3s16 p)
345                 {
346                         if(isValidPosition(p) == false)
347                                 throw InvalidPositionException();
348                         return node;
349                 }
350
351                 virtual void setNode(v3s16 p, MapNode & n)
352                 {
353                         if(isValidPosition(p) == false)
354                                 throw InvalidPositionException();
355                 };
356
357                 virtual u16 nodeContainerId() const
358                 {
359                         return 666;
360                 }
361         };
362
363         void Run()
364         {
365                 TC parent;
366
367                 MapBlock b(&parent, v3s16(1,1,1));
368                 v3s16 relpos(MAP_BLOCKSIZE, MAP_BLOCKSIZE, MAP_BLOCKSIZE);
369
370                 UASSERT(b.getPosRelative() == relpos);
371
372                 UASSERT(b.getBox().MinEdge.X == MAP_BLOCKSIZE);
373                 UASSERT(b.getBox().MaxEdge.X == MAP_BLOCKSIZE*2-1);
374                 UASSERT(b.getBox().MinEdge.Y == MAP_BLOCKSIZE);
375                 UASSERT(b.getBox().MaxEdge.Y == MAP_BLOCKSIZE*2-1);
376                 UASSERT(b.getBox().MinEdge.Z == MAP_BLOCKSIZE);
377                 UASSERT(b.getBox().MaxEdge.Z == MAP_BLOCKSIZE*2-1);
378
379                 UASSERT(b.isValidPosition(v3s16(0,0,0)) == true);
380                 UASSERT(b.isValidPosition(v3s16(-1,0,0)) == false);
381                 UASSERT(b.isValidPosition(v3s16(-1,-142,-2341)) == false);
382                 UASSERT(b.isValidPosition(v3s16(-124,142,2341)) == false);
383                 UASSERT(b.isValidPosition(v3s16(MAP_BLOCKSIZE-1,MAP_BLOCKSIZE-1,MAP_BLOCKSIZE-1)) == true);
384                 UASSERT(b.isValidPosition(v3s16(MAP_BLOCKSIZE-1,MAP_BLOCKSIZE,MAP_BLOCKSIZE-1)) == false);
385
386                 /*
387                         TODO: this method should probably be removed
388                         if the block size isn't going to be set variable
389                 */
390                 /*UASSERT(b.getSizeNodes() == v3s16(MAP_BLOCKSIZE,
391                                 MAP_BLOCKSIZE, MAP_BLOCKSIZE));*/
392
393                 // Changed flag should be initially set
394                 UASSERT(b.getModified() == MOD_STATE_WRITE_NEEDED);
395                 b.resetModified();
396                 UASSERT(b.getModified() == MOD_STATE_CLEAN);
397
398                 // All nodes should have been set to
399                 // .d=CONTENT_IGNORE and .getLight() = 0
400                 for(u16 z=0; z<MAP_BLOCKSIZE; z++)
401                 for(u16 y=0; y<MAP_BLOCKSIZE; y++)
402                 for(u16 x=0; x<MAP_BLOCKSIZE; x++)
403                 {
404                         //UASSERT(b.getNode(v3s16(x,y,z)).getContent() == CONTENT_AIR);
405                         UASSERT(b.getNode(v3s16(x,y,z)).getContent() == CONTENT_IGNORE);
406                         UASSERT(b.getNode(v3s16(x,y,z)).getLight(LIGHTBANK_DAY) == 0);
407                         UASSERT(b.getNode(v3s16(x,y,z)).getLight(LIGHTBANK_NIGHT) == 0);
408                 }
409
410                 {
411                         MapNode n(CONTENT_AIR);
412                         for(u16 z=0; z<MAP_BLOCKSIZE; z++)
413                         for(u16 y=0; y<MAP_BLOCKSIZE; y++)
414                         for(u16 x=0; x<MAP_BLOCKSIZE; x++)
415                         {
416                                 b.setNode(v3s16(x,y,z), n);
417                         }
418                 }
419
420                 /*
421                         Parent fetch functions
422                 */
423                 parent.position_valid = false;
424                 parent.node.setContent(5);
425
426                 MapNode n;
427
428                 // Positions in the block should still be valid
429                 UASSERT(b.isValidPositionParent(v3s16(0,0,0)) == true);
430                 UASSERT(b.isValidPositionParent(v3s16(MAP_BLOCKSIZE-1,MAP_BLOCKSIZE-1,MAP_BLOCKSIZE-1)) == true);
431                 n = b.getNodeParent(v3s16(0,MAP_BLOCKSIZE-1,0));
432                 UASSERT(n.getContent() == CONTENT_AIR);
433
434                 // ...but outside the block they should be invalid
435                 UASSERT(b.isValidPositionParent(v3s16(-121,2341,0)) == false);
436                 UASSERT(b.isValidPositionParent(v3s16(-1,0,0)) == false);
437                 UASSERT(b.isValidPositionParent(v3s16(MAP_BLOCKSIZE-1,MAP_BLOCKSIZE-1,MAP_BLOCKSIZE)) == false);
438
439                 {
440                         bool exception_thrown = false;
441                         try{
442                                 // This should throw an exception
443                                 MapNode n = b.getNodeParent(v3s16(0,0,-1));
444                         }
445                         catch(InvalidPositionException &e)
446                         {
447                                 exception_thrown = true;
448                         }
449                         UASSERT(exception_thrown);
450                 }
451
452                 parent.position_valid = true;
453                 // Now the positions outside should be valid
454                 UASSERT(b.isValidPositionParent(v3s16(-121,2341,0)) == true);
455                 UASSERT(b.isValidPositionParent(v3s16(-1,0,0)) == true);
456                 UASSERT(b.isValidPositionParent(v3s16(MAP_BLOCKSIZE-1,MAP_BLOCKSIZE-1,MAP_BLOCKSIZE)) == true);
457                 n = b.getNodeParent(v3s16(0,0,MAP_BLOCKSIZE));
458                 UASSERT(n.getContent() == 5);
459
460                 /*
461                         Set a node
462                 */
463                 v3s16 p(1,2,0);
464                 n.setContent(4);
465                 b.setNode(p, n);
466                 UASSERT(b.getNode(p).getContent() == 4);
467                 //TODO: Update to new system
468                 /*UASSERT(b.getNodeTile(p) == 4);
469                 UASSERT(b.getNodeTile(v3s16(-1,-1,0)) == 5);*/
470
471                 /*
472                         propagateSunlight()
473                 */
474                 // Set lighting of all nodes to 0
475                 for(u16 z=0; z<MAP_BLOCKSIZE; z++){
476                         for(u16 y=0; y<MAP_BLOCKSIZE; y++){
477                                 for(u16 x=0; x<MAP_BLOCKSIZE; x++){
478                                         MapNode n = b.getNode(v3s16(x,y,z));
479                                         n.setLight(LIGHTBANK_DAY, 0);
480                                         n.setLight(LIGHTBANK_NIGHT, 0);
481                                         b.setNode(v3s16(x,y,z), n);
482                                 }
483                         }
484                 }
485                 {
486                         /*
487                                 Check how the block handles being a lonely sky block
488                         */
489                         parent.position_valid = true;
490                         b.setIsUnderground(false);
491                         parent.node.setContent(CONTENT_AIR);
492                         parent.node.setLight(LIGHTBANK_DAY, LIGHT_SUN);
493                         parent.node.setLight(LIGHTBANK_NIGHT, 0);
494                         core::map<v3s16, bool> light_sources;
495                         // The bottom block is invalid, because we have a shadowing node
496                         UASSERT(b.propagateSunlight(light_sources) == false);
497                         UASSERT(b.getNode(v3s16(1,4,0)).getLight(LIGHTBANK_DAY) == LIGHT_SUN);
498                         UASSERT(b.getNode(v3s16(1,3,0)).getLight(LIGHTBANK_DAY) == LIGHT_SUN);
499                         UASSERT(b.getNode(v3s16(1,2,0)).getLight(LIGHTBANK_DAY) == 0);
500                         UASSERT(b.getNode(v3s16(1,1,0)).getLight(LIGHTBANK_DAY) == 0);
501                         UASSERT(b.getNode(v3s16(1,0,0)).getLight(LIGHTBANK_DAY) == 0);
502                         UASSERT(b.getNode(v3s16(1,2,3)).getLight(LIGHTBANK_DAY) == LIGHT_SUN);
503                         UASSERT(b.getFaceLight2(1000, p, v3s16(0,1,0)) == LIGHT_SUN);
504                         UASSERT(b.getFaceLight2(1000, p, v3s16(0,-1,0)) == 0);
505                         UASSERT(b.getFaceLight2(0, p, v3s16(0,-1,0)) == 0);
506                         // According to MapBlock::getFaceLight,
507                         // The face on the z+ side should have double-diminished light
508                         //UASSERT(b.getFaceLight(p, v3s16(0,0,1)) == diminish_light(diminish_light(LIGHT_MAX)));
509                         // The face on the z+ side should have diminished light
510                         UASSERT(b.getFaceLight2(1000, p, v3s16(0,0,1)) == diminish_light(LIGHT_MAX));
511                 }
512                 /*
513                         Check how the block handles being in between blocks with some non-sunlight
514                         while being underground
515                 */
516                 {
517                         // Make neighbours to exist and set some non-sunlight to them
518                         parent.position_valid = true;
519                         b.setIsUnderground(true);
520                         parent.node.setLight(LIGHTBANK_DAY, LIGHT_MAX/2);
521                         core::map<v3s16, bool> light_sources;
522                         // The block below should be valid because there shouldn't be
523                         // sunlight in there either
524                         UASSERT(b.propagateSunlight(light_sources, true) == true);
525                         // Should not touch nodes that are not affected (that is, all of them)
526                         //UASSERT(b.getNode(v3s16(1,2,3)).getLight() == LIGHT_SUN);
527                         // Should set light of non-sunlighted blocks to 0.
528                         UASSERT(b.getNode(v3s16(1,2,3)).getLight(LIGHTBANK_DAY) == 0);
529                 }
530                 /*
531                         Set up a situation where:
532                         - There is only air in this block
533                         - There is a valid non-sunlighted block at the bottom, and
534                         - Invalid blocks elsewhere.
535                         - the block is not underground.
536
537                         This should result in bottom block invalidity
538                 */
539                 {
540                         b.setIsUnderground(false);
541                         // Clear block
542                         for(u16 z=0; z<MAP_BLOCKSIZE; z++){
543                                 for(u16 y=0; y<MAP_BLOCKSIZE; y++){
544                                         for(u16 x=0; x<MAP_BLOCKSIZE; x++){
545                                                 MapNode n;
546                                                 n.setContent(CONTENT_AIR);
547                                                 n.setLight(LIGHTBANK_DAY, 0);
548                                                 b.setNode(v3s16(x,y,z), n);
549                                         }
550                                 }
551                         }
552                         // Make neighbours invalid
553                         parent.position_valid = false;
554                         // Add exceptions to the top of the bottom block
555                         for(u16 x=0; x<MAP_BLOCKSIZE; x++)
556                         for(u16 z=0; z<MAP_BLOCKSIZE; z++)
557                         {
558                                 parent.validity_exceptions.push_back(v3s16(MAP_BLOCKSIZE+x, MAP_BLOCKSIZE-1, MAP_BLOCKSIZE+z));
559                         }
560                         // Lighting value for the valid nodes
561                         parent.node.setLight(LIGHTBANK_DAY, LIGHT_MAX/2);
562                         core::map<v3s16, bool> light_sources;
563                         // Bottom block is not valid
564                         UASSERT(b.propagateSunlight(light_sources) == false);
565                 }
566         }
567 };
568
569 struct TestMapSector: public TestBase
570 {
571         class TC : public NodeContainer
572         {
573         public:
574
575                 MapNode node;
576                 bool position_valid;
577
578                 TC()
579                 {
580                         position_valid = true;
581                 }
582
583                 virtual bool isValidPosition(v3s16 p)
584                 {
585                         return position_valid;
586                 }
587
588                 virtual MapNode getNode(v3s16 p)
589                 {
590                         if(position_valid == false)
591                                 throw InvalidPositionException();
592                         return node;
593                 }
594
595                 virtual void setNode(v3s16 p, MapNode & n)
596                 {
597                         if(position_valid == false)
598                                 throw InvalidPositionException();
599                 };
600
601                 virtual u16 nodeContainerId() const
602                 {
603                         return 666;
604                 }
605         };
606
607         void Run()
608         {
609                 TC parent;
610                 parent.position_valid = false;
611
612                 // Create one with no heightmaps
613                 ServerMapSector sector(&parent, v2s16(1,1));
614
615                 UASSERT(sector.getBlockNoCreateNoEx(0) == 0);
616                 UASSERT(sector.getBlockNoCreateNoEx(1) == 0);
617
618                 MapBlock * bref = sector.createBlankBlock(-2);
619
620                 UASSERT(sector.getBlockNoCreateNoEx(0) == 0);
621                 UASSERT(sector.getBlockNoCreateNoEx(-2) == bref);
622
623                 //TODO: Check for AlreadyExistsException
624
625                 /*bool exception_thrown = false;
626                 try{
627                         sector.getBlock(0);
628                 }
629                 catch(InvalidPositionException &e){
630                         exception_thrown = true;
631                 }
632                 UASSERT(exception_thrown);*/
633
634         }
635 };
636 #endif