From b45df9d6a73d97671cbdd38d77e9b153a80fb458 Mon Sep 17 00:00:00 2001 From: kwolekr Date: Tue, 5 May 2015 11:36:40 -0400 Subject: Tests: Add NodeResolver unittests Minor misc. NodeResolver cleanups Prefix faux content type constants for testing with t_ to avoid confusion or name collisions --- src/unittest/test.cpp | 77 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 71 insertions(+), 6 deletions(-) (limited to 'src/unittest/test.cpp') diff --git a/src/unittest/test.cpp b/src/unittest/test.cpp index 6fea0b8a0..57843da5e 100644 --- a/src/unittest/test.cpp +++ b/src/unittest/test.cpp @@ -25,9 +25,12 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "itemdef.h" #include "gamedef.h" -content_t CONTENT_STONE; -content_t CONTENT_GRASS; -content_t CONTENT_TORCH; +content_t t_CONTENT_STONE; +content_t t_CONTENT_GRASS; +content_t t_CONTENT_TORCH; +content_t t_CONTENT_WATER; +content_t t_CONTENT_LAVA; +content_t t_CONTENT_BRICK; //////////////////////////////////////////////////////////////////////////////// @@ -111,7 +114,7 @@ void TestGameDef::defineSomeNodes() f.tiledef[i].name = "default_stone.png"; f.is_ground_content = true; idef->registerItem(itemdef); - CONTENT_STONE = ndef->set(f.name, f); + t_CONTENT_STONE = ndef->set(f.name, f); //// Grass itemdef = ItemDefinition(); @@ -131,7 +134,7 @@ void TestGameDef::defineSomeNodes() f.tiledef[i].name = "default_dirt.png^default_grass_side.png"; f.is_ground_content = true; idef->registerItem(itemdef); - CONTENT_GRASS = ndef->set(f.name, f); + t_CONTENT_GRASS = ndef->set(f.name, f); //// Torch (minimal definition for lighting tests) itemdef = ItemDefinition(); @@ -144,7 +147,69 @@ void TestGameDef::defineSomeNodes() f.sunlight_propagates = true; f.light_source = LIGHT_MAX-1; idef->registerItem(itemdef); - CONTENT_TORCH = ndef->set(f.name, f); + t_CONTENT_TORCH = ndef->set(f.name, f); + + //// Water + itemdef = ItemDefinition(); + itemdef.type = ITEM_NODE; + itemdef.name = "default:water"; + itemdef.description = "Water"; + itemdef.inventory_image = "[inventorycube" + "{default_water.png" + "{default_water.png" + "{default_water.png"; + f = ContentFeatures(); + f.name = itemdef.name; + f.alpha = 128; + f.liquid_type = LIQUID_SOURCE; + f.liquid_viscosity = 4; + f.is_ground_content = true; + f.groups["liquids"] = 3; + for(int i = 0; i < 6; i++) + f.tiledef[i].name = "default_water.png"; + idef->registerItem(itemdef); + t_CONTENT_WATER = ndef->set(f.name, f); + + //// Lava + itemdef = ItemDefinition(); + itemdef.type = ITEM_NODE; + itemdef.name = "default:lava"; + itemdef.description = "Lava"; + itemdef.inventory_image = "[inventorycube" + "{default_lava.png" + "{default_lava.png" + "{default_lava.png"; + f = ContentFeatures(); + f.name = itemdef.name; + f.alpha = 128; + f.liquid_type = LIQUID_SOURCE; + f.liquid_viscosity = 7; + f.light_source = LIGHT_MAX-1; + f.is_ground_content = true; + f.groups["liquids"] = 3; + for(int i = 0; i < 6; i++) + f.tiledef[i].name = "default_lava.png"; + idef->registerItem(itemdef); + t_CONTENT_LAVA = ndef->set(f.name, f); + + + //// Brick + itemdef = ItemDefinition(); + itemdef.type = ITEM_NODE; + itemdef.name = "default:brick"; + itemdef.description = "Brick"; + itemdef.groups["cracky"] = 3; + itemdef.inventory_image = "[inventorycube" + "{default_brick.png" + "{default_brick.png" + "{default_brick.png"; + f = ContentFeatures(); + f.name = itemdef.name; + for(int i = 0; i < 6; i++) + f.tiledef[i].name = "default_brick.png"; + f.is_ground_content = true; + idef->registerItem(itemdef); + t_CONTENT_BRICK = ndef->set(f.name, f); } //// -- cgit v1.2.3