Luanti 5.11.0-dev
 
Loading...
Searching...
No Matches
test.h File Reference
#include <functional>
#include <exception>
#include <sstream>
#include <vector>
#include "irrlichttypes_extrabloated.h"
#include "porting.h"
#include "filesys.h"
#include "mapnode.h"
+ Include dependency graph for test.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  TestFailedException
 
class  TestBase
 
class  TestManager
 

Macros

#define TEST(fxn, ...)   runTest(#fxn, [&] () { fxn(__VA_ARGS__); });
 
#define UASSERT(x)
 
#define UTEST(x, fmt, ...)
 
#define UASSERTCMP(T, CMP, actual, expected)
 
#define UASSERTEQ(T, actual, expected)   UASSERTCMP(T, ==, actual, expected)
 
#define EXCEPTION_CHECK(EType, code)
 

Functions

bool run_tests ()
 
bool run_tests (const std::string &module_name)
 

Variables

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
 

Macro Definition Documentation

◆ EXCEPTION_CHECK

#define EXCEPTION_CHECK ( EType,
code )
Value:
{ \
bool exception_thrown = false; \
try { \
code; \
} catch (EType &e) { \
exception_thrown = true; \
} \
UASSERT(exception_thrown); \
}

Referenced by TestSerialization::testDeSerializeLongString(), TestSerialization::testDeSerializeString(), TestRandom::testPcgRandomRange(), TestRandom::testPseudoRandomRange(), and TestVoxelManipulator::testVoxelManipulator().

◆ TEST

◆ UASSERT

#define UASSERT ( x)
Value:
if (!(x)) { \
throw TestFailedException(#x, __FILE__, __LINE__); \
}
Definition test.h:17

Referenced by assert_active_in_block(), check_noise_params(), compare_settings(), EventManagerTest::eventTest(), TestAreaStore::genericStoreTest(), TestBase::getTestTempDirectory(), TestMapSettingsManager::makeMetaFile(), Foobar::resolveNodeNames(), Foobaz::resolveNodeNames(), TestVoxelArea::test_addarea(), TestVoxelArea::test_diff(), TestVoxelArea::test_extent(), TestVoxelArea::test_intersect(), TestVoxelArea::test_minor(), TestVoxelArea::test_pad(), TestVoxelArea::test_plus(), TestSAO::testActivate(), TestBan::testAdd(), TestObjDef::testAddGetSetClear(), TestSettings::testAllSettings(), TestUtilities::testAngleWrapAround(), TestActiveObject::testAOAttributes(), TestUtilities::testAsciiPrintableHelper(), TestThreading::testAtomicSemaphoreThread(), TestCollision::testAxisAlignedCollision(), TestUtilities::testBase64(), TestAddress::testBasic(), TestMoveAction::testCallbacks(), TestMoveAction::testCallbacksSwap(), TestAuthDatabase::testChange(), TestModStorageDatabase::testChange(), TestAuthDatabase::testChangePrivileges(), TestObjDef::testClone(), TestCollision::testCollisionMoveSimple(), TestKeycode::testCompare(), TestConnection::testConnectSendReceive(), TestFileSys::testCopyFileContents(), TestAuthDatabase::testCreate(), TestBan::testCreate(), TestModStorageDatabase::testCreate(), TestLua::testCxxExceptions(), TestSettings::testDefaults(), TestAuthDatabase::testDelete(), TestSerialization::testDeSerializeLongString(), TestSerialization::testDeSerializeString(), TestUtilities::testEnrichedString(), TestUtilities::testEulerConversion(), TestSchematic::testFileSerializeDeserialize(), TestSettings::testFlagDesc(), TestSerialization::testFloatFormat(), TestMap::testForEachNodeInArea(), TestMap::testForEachNodeInAreaBlank(), TestMap::testForEachNodeInAreaEmpty(), TestServerActiveObjectMgr::testFreeID(), TestClientActiveObjectMgr::testGetActiveSelectableObjects(), TestBan::testGetBanDescription(), TestBan::testGetBanName(), TestServerModManager::testGetModMediaPaths(), TestServerModManager::testGetModNames(), TestServerModManager::testGetMods(), TestServerModManager::testGetModspec(), TestObjDef::testHandles(), TestConnection::testHelpers(), TestGameUI::testInfoText(), TestGameUI::testInit(), TestServerShutdownState::testInit(), TestSocket::testIPv4Socket(), TestSocket::testIPv6Socket(), TestUtilities::testIsBlockInSight(), TestFileSys::testIsDirDelimiter(), TestAddress::testIsLocalhost(), TestUtilities::testIsNumber(), TestUtilities::testIsPowerOfTwo(), TestUtilities::testIsYes(), TestModChannels::testJoinChannel(), TestModChannels::testLeaveChannel(), TestModStorageDatabase::testListMods(), TestMapBlock::testLoad20(), TestMapBlock::testLoad29(), TestMapBlock::testLoadNonStd(), TestLua::testLuaDestructors(), TestSchematic::testLuaTableSerialize(), TestDataStructures::testMap1(), TestDataStructures::testMap2(), TestDataStructures::testMap3(), TestDataStructures::testMap4(), TestMapSettingsManager::testMapMetaFailures(), TestMapSettingsManager::testMapMetaSaveLoad(), TestMapSettingsManager::testMapSettingsManager(), TestMap::testMaxMapgenLimit(), TestBan::testModificationFlag(), TestMoveAction::testMove(), TestMoveAction::testMoveFillStack(), TestMoveAction::testMovePartial(), TestMoveAction::testMoveSomewhere(), TestMoveAction::testMoveSomewherePartial(), TestMoveAction::testMoveUnallowed(), TestSchematic::testMtsSerializeDeserialize(), TestUtilities::testMyround(), TestConnection::testNetworkPacketSerialize(), TestMapNode::testNodeProperties(), TestNodeResolver::testNodeResolving(), TestNoise::testNoise2dAtOriginWithZeroSeed(), TestNoise::testNoise2dBulk(), TestNoise::testNoise2dPoint(), TestNoise::testNoise2dWithFunPrimes(), TestNoise::testNoise2dWithMaxSeed(), TestNoise::testNoise3dAtOriginWithZeroSeed(), TestNoise::testNoise3dBulk(), TestNoise::testNoise3dPoint(), TestNoise::testNoise3dWithFunPrimes(), TestNoise::testNoise3dWithMaxSeed(), TestNoise::testNoiseInvalidParams(), TestFileSys::testNonExist(), TestSAO::testNotSaved(), TestIrrPtr::testNullHandling(), TestUtilities::testPadString(), TestFileSys::testPathStartsWith(), TestRandom::testPcgRandomBytes(), TestRandom::testPcgRandomNormalDist(), TestRandom::testPcgRandomRange(), TestNodeResolver::testPendingResolveCancellation(), TestProfiler::testProfilerAverage(), TestRandom::testPseudoRandomRange(), TestMeshCompare::testQuad(), TestEventManager::testRealEvent(), TestEventManager::testRealEventAfterDereg(), TestAuthDatabase::testRecall(), TestModStorageDatabase::testRecall(), TestAuthDatabase::testRecallChanged(), TestModStorageDatabase::testRecallChanged(), TestAuthDatabase::testRecallChangedPrivileges(), TestAuthDatabase::testRecallFail(), TestModStorageDatabase::testRecallFail(), TestFileSys::testRecursiveDelete(), TestIrrPtr::testRefCounting(), TestServerActiveObjectMgr::testRegisterObject(), TestBan::testRemove(), TestModStorageDatabase::testRemove(), TestUtilities::testRemoveEscapes(), TestFileSys::testRemoveLastPathComponent(), TestFileSys::testRemoveLastPathComponentWithTrailingDelimiter(), TestServerActiveObjectMgr::testRemoveObject(), TestFileSys::testRemoveRelativePathComponent(), TestUtilities::testRemoveStringEnd(), TestServerShutdownState::testReset(), TestAddress::testResolve(), TestCompression::testRLECompression(), TestFileSys::testSafeWriteToFile(), TestUtilities::testSanitizeUntrusted(), TestMapBlock::testSave29(), TestMapBlock::testSaveLoad(), TestIrrPtr::testSelfAssignment(), TestModChannels::testSendMessageToChannel(), TestInventory::testSerializeDeserialize(), TestSerialization::testSerializeJsonString(), TestSerialization::testSerializeLongString(), TestSerialization::testSerializeString(), TestThreading::testStartStopWait(), TestUtilities::testStartsWith(), TestSAO::testStaticSave(), TestSAO::testStaticToFalse(), TestSAO::testStaticToTrue(), TestGameUI::testStatusText(), TestSerialization::testStreamRead(), TestSerialization::testStreamWrite(), TestUtilities::testStrEqual(), TestUtilities::testStringAllowed(), TestUtilities::testStringJoin(), TestUtilities::testStringReplace(), TestUtilities::testStrToIntConversion(), TestMoveAction::testSwap(), TestMoveAction::testSwapFromUnallowed(), TestMoveAction::testSwapToUnallowed(), TestServerShutdownState::testTick(), TestThreading::testTLS(), TestMeshCompare::testTriangle(), TestServerShutdownState::testTrigger(), TestUtilities::testTrim(), TestUtilities::testUrlDecode(), TestUtilities::testUrlEncode(), TestUtilities::testUTF8(), TestVoxelManipulator::testVoxelArea(), TestVoxelAlgorithms::testVoxelLineIterator(), TestVoxelManipulator::testVoxelManipulator(), TestUtilities::testWrapDegrees_0_360_v3f(), TestUtilities::testWrapRows(), and TestCompression::testZlibCompression().

◆ UASSERTCMP

#define UASSERTCMP ( T,
CMP,
actual,
expected )
Value:
{ \
T a = (actual); \
T e = (expected); \
if (!(a CMP e)) { \
std::ostringstream message; \
message << #actual " " #CMP " " #expected; \
message << std::endl << " actual : " << a; \
message << std::endl << " expected: " << e; \
throw TestFailedException(message.str(), __FILE__, __LINE__); \
} \
}

Referenced by compare_settings(), TestKeycode::testCreateFromString(), TestServerActiveObjectMgr::testGetAddedActiveObjectsAroundPos(), TestServerActiveObjectMgr::testGetObjectsInsideRadius(), TestModStorageDatabase::testListMods(), TestModStorageDatabase::testRecall(), TestModStorageDatabase::testRecallChanged(), and TestAddress::testResolve().

◆ UASSERTEQ

#define UASSERTEQ ( T,
actual,
expected )   UASSERTCMP(T, ==, actual, expected)

Referenced by TestCompression::_testZlibLimit(), assert_active_in_block(), check_noise_params(), TestAreaStore::genericStoreTest(), TestVoxelArea::test_add_p(), TestVoxelArea::test_add_x(), TestVoxelArea::test_add_y(), TestVoxelArea::test_add_z(), TestVoxelArea::test_contains_i(), TestVoxelArea::test_contains_point(), TestVoxelArea::test_contains_voxelarea(), TestVoxelArea::test_diff(), TestVoxelArea::test_equal(), TestVoxelArea::test_index_v3s16_all_neg(), TestVoxelArea::test_index_v3s16_all_pos(), TestVoxelArea::test_index_v3s16_x_neg(), TestVoxelArea::test_index_v3s16_xy_neg(), TestVoxelArea::test_index_v3s16_xz_neg(), TestVoxelArea::test_index_v3s16_y_neg(), TestVoxelArea::test_index_v3s16_yz_neg(), TestVoxelArea::test_index_v3s16_z_neg(), TestVoxelArea::test_index_xyz_all_neg(), TestVoxelArea::test_index_xyz_all_pos(), TestVoxelArea::test_index_xyz_x_neg(), TestVoxelArea::test_index_xyz_xy_neg(), TestVoxelArea::test_index_xyz_xz_neg(), TestVoxelArea::test_index_xyz_y_neg(), TestVoxelArea::test_index_xyz_yz_neg(), TestVoxelArea::test_index_xyz_z_neg(), TestVoxelArea::test_volume(), TestSAO::testActivate(), TestObjDef::testAddGetSetClear(), TestAddress::testBasic(), TestLogging::testBitCheck(), TestObjDef::testClone(), TestCollision::testCollisionMoveSimple(), TestUtilities::testColorizeURL(), TestFileSys::testCopyFileContents(), TestServerModManager::testCreation(), TestLua::testCxxExceptions(), TestGettext::testFmtgettext(), TestMap::testForEachNodeInArea(), TestClientActiveObjectMgr::testGetActiveSelectableObjects(), TestServerModManager::testGetModMediaPaths(), TestServerModManager::testGetModMediaPathsWrongDir(), TestServerModManager::testGetModNames(), TestServerModManager::testGetModNamesWrongDir(), TestServerModManager::testGetMods(), TestServerModManager::testGetModspec(), TestServerModManager::testGetModsWrongDir(), TestObjDef::testHandles(), TestServerModManager::testIsConsistent(), TestVoxelAlgorithms::testLighting(), TestAuthDatabase::testListNames(), TestMapBlock::testLoad20(), TestMapBlock::testLoad29(), TestMapBlock::testLoadNonStd(), TestUtilities::testLowercase(), TestSchematic::testLuaTableSerialize(), TestDataStructures::testMap4(), TestDataStructures::testMap5(), TestMapSettingsManager::testMapMetaSaveLoad(), TestMap::testMaxMapgenLimit(), TestSchematic::testMtsSerializeDeserialize(), TestConnection::testNetworkPacketSerialize(), TestNodeResolver::testNodeResolving(), TestSAO::testNotSaved(), TestLogging::testNullChecks(), TestRandom::testPcgRandom(), TestRandom::testPseudoRandom(), TestAuthDatabase::testRecall(), TestAuthDatabase::testRecallChanged(), TestAuthDatabase::testRecallChangedPrivileges(), TestCompression::testRLECompression(), TestFileSys::testSafeWriteToFile(), TestUtilities::testSanitizeDirName(), TestUtilities::testSanitizeUntrusted(), TestMapBlock::testSave29(), TestAreaStore::testSerialization(), TestInventory::testSerializeDeserialize(), TestSerialization::testSerializeJsonString(), TestCraft::testShapeless(), TestSAO::testStaticSave(), TestSAO::testStaticToFalse(), TestSAO::testStaticToTrue(), TestServerModManager::testUnsatisfiedMods(), TestUtilities::testUTF8(), TestVoxelAlgorithms::testVoxelLineIterator(), TestCompression::testZlibCompression(), TestCompression::testZlibLargeData(), and TestCompression::testZstdLargeData().

◆ UTEST

#define UTEST ( x,
fmt,
... )
Value:
if (!(x)) { \
char utest_buf[1024]; \
snprintf(utest_buf, sizeof(utest_buf), fmt, __VA_ARGS__); \
throw TestFailedException(utest_buf, __FILE__, __LINE__); \
}

Referenced by TestCompression::_testZlibLimit(), TestIrrPtr::testRefCounting(), TestCompression::testZlibLargeData(), and TestCompression::testZstdLargeData().

Function Documentation

◆ run_tests() [1/2]

bool run_tests ( )

References g_logger, TestManager::getTestModules(), porting::getTimeMs(), LL_ERROR, rawstream, and Logger::setLevelSilenced().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ run_tests() [2/2]

bool run_tests ( const std::string & module_name)

References findTestModule(), g_logger, porting::getTimeMs(), LL_ERROR, rawstream, and Logger::setLevelSilenced().

+ Here is the call graph for this function:

Variable Documentation

◆ t_CONTENT_BRICK

◆ t_CONTENT_GRASS

◆ t_CONTENT_LAVA

◆ t_CONTENT_STONE

◆ t_CONTENT_TORCH

◆ t_CONTENT_WATER