X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;ds=sidebyside;f=src%2Ftest.cpp;h=07ef772eff7755c2b74de152bea0091520b1d30a;hb=4a6b9a6ac1b07239474bce8d3ebf772ce75e862e;hp=f8f9547423fc2abafbfc2d32f2d409b08b58ad70;hpb=a176f9eb36033196040443991a0723c39886b8a2;p=dragonfireclient.git diff --git a/src/test.cpp b/src/test.cpp index f8f954742..07ef772ef 100644 --- a/src/test.cpp +++ b/src/test.cpp @@ -23,7 +23,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "map.h" #include "player.h" #include "main.h" -#include "heightmap.h" #include "socket.h" #include "connection.h" #include "utility.h" @@ -193,7 +192,7 @@ struct TestMapNode // Transparency n.d = CONTENT_AIR; assert(n.light_propagates() == true); - n.d = 0; + n.d = CONTENT_STONE; assert(n.light_propagates() == false); } }; @@ -268,6 +267,7 @@ struct TestVoxelManipulator assert(v.getNode(v3s16(-1,0,-1)).d == 2); EXCEPTION_CHECK(InvalidPositionException, v.getNode(v3s16(0,1,1))); +#if 0 /* Water stuff */ @@ -332,6 +332,7 @@ struct TestVoxelManipulator dstream<<"Final result of flowWater:"<setHeightmap(dummyheightmap); + ServerMapSector sector(&parent, v2s16(1,1)); EXCEPTION_CHECK(InvalidPositionException, sector.getBlockNoCreate(0)); EXCEPTION_CHECK(InvalidPositionException, sector.getBlockNoCreate(1)); @@ -652,116 +651,6 @@ struct TestMapSector } }; -struct TestHeightmap -{ - void TestSingleFixed() - { - const s16 BS1 = 4; - OneChildHeightmap hm1(BS1); - - // Test that it is filled with < GROUNDHEIGHT_VALID_MINVALUE - for(s16 y=0; y<=BS1; y++){ - for(s16 x=0; x<=BS1; x++){ - v2s16 p(x,y); - assert(hm1.m_child.getGroundHeight(p) - < GROUNDHEIGHT_VALID_MINVALUE); - } - } - - hm1.m_child.setGroundHeight(v2s16(1,0), 2.0); - //hm1.m_child.print(); - assert(fabs(hm1.getGroundHeight(v2s16(1,0))-2.0)<0.001); - hm1.setGroundHeight(v2s16(0,1), 3.0); - assert(fabs(hm1.m_child.getGroundHeight(v2s16(0,1))-3.0)<0.001); - - // Fill with -1.0 - for(s16 y=0; y<=BS1; y++){ - for(s16 x=0; x<=BS1; x++){ - v2s16 p(x,y); - hm1.m_child.setGroundHeight(p, -1.0); - } - } - - f32 corners[] = {0.0, 0.0, 1.0, 1.0}; - hm1.m_child.generateContinued(0.0, 0.0, corners); - - hm1.m_child.print(); - assert(fabs(hm1.m_child.getGroundHeight(v2s16(1,0))-0.2)<0.05); - assert(fabs(hm1.m_child.getGroundHeight(v2s16(4,3))-0.7)<0.05); - assert(fabs(hm1.m_child.getGroundHeight(v2s16(4,4))-1.0)<0.05); - } - - void TestUnlimited() - { - //g_heightmap_debugprint = true; - const s16 BS1 = 4; - UnlimitedHeightmap hm1(BS1, - new ConstantGenerator(0.0), - new ConstantGenerator(0.0), - new ConstantGenerator(5.0)); - // Go through it so it generates itself - for(s16 y=0; y<=BS1; y++){ - for(s16 x=0; x<=BS1; x++){ - v2s16 p(x,y); - hm1.getGroundHeight(p); - } - } - // Print it - dstream<<"UnlimitedHeightmap hm1:"<setGroundHeight(p1, v1); - // Read from UnlimitedHeightmap - assert(fabs(hm1.getGroundHeight(p1)-v1)<0.001); - } - - void Random() - { - dstream<<"Running random code (get a human to check this)"<generateContinued(0.0, 0.0, corners); - hm1.print();*/ - - //assert(0); - } - - void Run() - { - //srand(7); // Get constant random - srand(time(0)); // Get better random - - TestSingleFixed(); - TestUnlimited(); - Random(); - } -}; - struct TestSocket { void Run() @@ -1062,18 +951,18 @@ struct TestConnection assert(got_exception); } { - //u8 data1[1100]; - SharedBuffer data1(1100); - for(u16 i=0; i<1100; i++){ + const int datasize = 30000; + SharedBuffer data1(datasize); + for(u16 i=0; i20) + if(datasize>20) dstream<<"..."; dstream<