Mudbox/UnitTest.h File Reference

UnitTest.h File Reference

Classes

class  UnitTest
 Base class for unit test objects. More...
 

Namespaces

 mudbox
 Class: ConvolutionKernel.
 

Macros

#define MB_START_TEST_OBJECT(testObjName)
 These macros define a test object that contains unit tests. More...
 
#define MB_END_TEST_OBJECT(testObjName)
 
#define MB_START_DEF_TESTS
 
#define MB_END_DEF_TESTS   };
 
#define MB_DECL_TEST(name)
 
#define MB_DEF_TEST(name)
 
#define MB_CHECK(condition)
 

Macro Definition Documentation

#define MB_START_TEST_OBJECT (   testObjName)
Value:
class testObjName : public UnitTest \
{ \
static testObjName* s_pThis; \
astring m_sCommand; \
testObjName() : m_sCommand(this, "cmd") { \
m_sCommand.Connect(Kernel()->NextCommand); \
Go(true,""); \
s_pThis = this; \
}; \
virtual ~testObjName() { \
if( s_pThis == this ) \
s_pThis = 0; \
}; \
void OnNodeEvent( const Attribute &cAttribute, NodeEventType eType ) { \
if( cAttribute == m_sCommand && eType == etValueChanged ) { \
QString sOp = m_sCommand.Value().section( ' ', 0, 0 ); \
if( sOp == "PluginTest" ) \
Go(false, m_sCommand.Value().section( ' ', 1, 1 )); \
}; \
}; \
static void RunAll() { \
if( s_pThis ) \
s_pThis->Go( false, "" ); \
}; \
static QString ClassName() { \
return #testObjName; \
};
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
NodeEventType
Possible event types when Node::OnNodeEvent is called.
Definition: node.h:148
Value of an attribute is changed.
Definition: node.h:151
AttributeInstance< QString > astring
This type has to be used instead of the String type.
Definition: node.h:533
class MBDLL_DECL Kernel
Definition: kernel.h:17
#define DECLARE_CLASS
This macro should be used in declaration of classes which are inherited from the Node class (or any d...
Definition: node.h:91

These macros define a test object that contains unit tests.

To add unit tests to your plugin, put the following boilerplate code in a new .cpp file that gets compiled with your plugin.

#include <UnitTest.h> MB_START_TEST_OBJECT("Tester")

MB_DECL_TEST( TestName )
MB_DECL_TEST( TestName2 )

MB_START_DEF_TESTS
    MB_DEF_TEST( TestName )
    {

tests here } MB_DEF_TEST( TestName2 ) { tests here assert using MB_CHECK( some boolean expression ) to make sure your code is doing what you think its doing! } MB_END_DEF_TESTS

MB_END_TEST_OBJECT("Tester")

Definition at line 61 of file UnitTest.h.

#define MB_END_TEST_OBJECT (   testObjName)
Value:
}; IMPLEMENT_CLASS( testObjName, UnitTest, #testObjName ); \
testObjName* testObjName::s_pThis = 0;
#define IMPLEMENT_CLASS(name, parent, displayname)
Definition: node.h:113

Definition at line 91 of file UnitTest.h.

#define MB_START_DEF_TESTS
Value:
virtual void Go(bool bInit, const QString& sTest) { \
if( bInit ) \
{ \
Kernel()->Interface()->AddCallbackMenuItem( NTR("UnitTest"), ClassName(), NTR("Run all tests"), RunAll ); \
};
#define NTR(s)
NTR(s)
Definition: i18n.h:24
class MBDLL_DECL Kernel
Definition: kernel.h:17

Definition at line 95 of file UnitTest.h.

#define MB_END_DEF_TESTS   };

Definition at line 102 of file UnitTest.h.

#define MB_DECL_TEST (   name)
Value:
static void name() \
{ \
Kernel()->RecordCommand( NTRQ("PluginTest %1%2").arg(ClassName()).arg(#name) ); \
if( s_pThis ) \
s_pThis->Go(false, ClassName() + QString(#name)); \
QString sMsg = NTRQ("Completed Test: %1").arg(ClassName() + QString(#name)); \
Kernel()->Log( sMsg ); \
Kernel()->Interface()->SetStatus( mudbox::Interface::stNormal, sMsg ); \
};
#define NTRQ(s)
NTRQ(s)
Definition: i18n.h:33
GLuint const GLchar * name
Definition: GLee.h:1704
class MBDLL_DECL Kernel
Definition: kernel.h:17

Definition at line 107 of file UnitTest.h.

#define MB_DEF_TEST (   name)
Value:
if( bInit ) \
Kernel()->Interface()->AddCallbackMenuItem( NTR("UnitTest"), ClassName(), #name, name); \
else if ( sTest == ClassName() + QString(#name) || sTest.isEmpty() ) \
#define NTR(s)
NTR(s)
Definition: i18n.h:24
GLuint const GLchar * name
Definition: GLee.h:1704
class MBDLL_DECL Kernel
Definition: kernel.h:17
bool isEmpty() const
Definition: qstring.h:704

Definition at line 121 of file UnitTest.h.

#define MB_CHECK (   condition)
Value:
if( !(condition) ) { \
MB_ASSERT(false); \
Kernel()->Log( NTRQ("UnitTest assert failed: %1").arg( #condition ) ); \
MB_ERROR( NTRQ("UnitTest assert failed: %1").arg( #condition ) ); \
};
#define MB_ASSERT(condition)
Definition: mudbox.h:73
#define MB_ERROR
Definition: mudbox.h:123
GLenum condition
Definition: GLee.h:6231
#define NTRQ(s)
NTRQ(s)
Definition: i18n.h:33
class MBDLL_DECL Kernel
Definition: kernel.h:17

Definition at line 126 of file UnitTest.h.

Go to the source code of this file.