mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-03 20:40:35 +00:00
Merge pull request #594 from LuisAntonRebollo/unit-tests-without-crash
Increased stability Torque3D: unit-tests running without a crash.
This commit is contained in:
commit
feec36731e
18 changed files with 113 additions and 19 deletions
|
|
@ -29,6 +29,8 @@
|
|||
|
||||
#include "unit/test.h"
|
||||
|
||||
#include "core/util/journal/process.h"
|
||||
|
||||
|
||||
namespace UnitTesting
|
||||
{
|
||||
|
|
@ -275,6 +277,9 @@ bool TestRun::test(const char* module, bool skipInteractive)
|
|||
|
||||
Platform::setCurrentDirectory(cwdSave);
|
||||
|
||||
// sanity check for avoid Process::requestShutdown() called on some tests
|
||||
Process::processEvents();
|
||||
|
||||
// And indicate our failure situation in the return value.
|
||||
return !_failureCount;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,9 +91,17 @@ public:
|
|||
// for this functionality later
|
||||
void unit_test( UnitTest *test )
|
||||
{
|
||||
AssertFatal(test, "CachedInterfaceExampleComponent::unit_test - NULL UnitTest");
|
||||
|
||||
if( !test )
|
||||
return;
|
||||
|
||||
test->test( mpU32 != NULL, "Pointer to dependent interface is NULL" );
|
||||
test->test( *(*mpU32) & ( 1 << 24 ), "Pointer to interface data is bogus." );
|
||||
test->test( *(*mpU32) != *mMyId, "Two of me have the same ID, bad!" );
|
||||
if( mpU32 )
|
||||
{
|
||||
test->test( *(*mpU32) & ( 1 << 24 ), "Pointer to interface data is bogus." );
|
||||
test->test( *(*mpU32) != *mMyId, "Two of me have the same ID, bad!" );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -130,13 +138,16 @@ CreateUnitTest(TestComponentInterfacing, "Components/Composition")
|
|||
test( componentB->getOwner() == testComponent, "testComponent did not properly set the mOwner field of componentB to NULL." );
|
||||
|
||||
// Register the object with the simulation, kicking off the interface registration
|
||||
test( testComponent->registerObject(), "Failed to register testComponent" );
|
||||
const bool registered = testComponent->registerObject();
|
||||
test( registered, "Failed to register testComponent" );
|
||||
|
||||
// Interface tests
|
||||
componentA->unit_test( this );
|
||||
componentB->unit_test( this );
|
||||
|
||||
testComponent->deleteObject();
|
||||
if( registered )
|
||||
{
|
||||
componentA->unit_test( this );
|
||||
componentB->unit_test( this );
|
||||
testComponent->deleteObject();
|
||||
}
|
||||
|
||||
test( m.check(), "Component composition test leaked memory." );
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue