Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

D:/Net/easyunit/test.h File Reference

#include "testcase.h"
#include "testpartresult.h"

Namespaces

namespace  easyunit

Classes

class  easyunit::Test
 Test class containing all macros to do unit testing. More...

Defines

#define EQUALS_DELTA(expected, actual, delta)   (actual - expected) <= delta && actual >= expected || (expected - actual) <= delta && expected >= actual
#define TO_STRING_EQUALS_F(expected, actual)   StringFrom("Expected : ") + StringFrom(expected) + StringFrom(" but Actual : ") + StringFrom(actual)
#define TO_STRING_EQUALS_S(expected, actual)   StringFrom(expected) + StringFrom(" == ") + StringFrom(actual)
#define TO_S_E_DELTA_F(expected, actual, delta)   StringFrom("Expected : ") + StringFrom(expected) + StringFrom(" but Actual : ") + StringFrom(actual) + StringFrom(" with delta = ") + StringFrom(delta)
#define TO_S_E_DELTA_S(expected, actual, delta)   StringFrom(expected) + StringFrom(" == ") + StringFrom(actual) + StringFrom(" with delta = ") + StringFrom(delta)
#define ASSERT_TRUE(condition)
 Asserts that a condition is true.
#define ASSERT_TRUE_M(condition, message)
 Asserts that a condition is true.
#define ASSERT_EQUALS(expected, actual)
 Asserts that the two parameters are equals.
#define ASSERT_EQUALS_V(expected, actual)
 Asserts that the two parameters are equals.
#define ASSERT_EQUALS_M(expected, actual, message)
 Asserts that the two parameters are equals.
#define ASSERT_EQUALS_DELTA(expected, actual, delta)
 Asserts that the two parameters are equals within a delta.
#define ASSERT_EQUALS_DELTA_M(expected, actual, delta, message)
 Asserts that the two parameters are equals within a delta.
#define ASSERT_EQUALS_DELTA_V(expected, actual, delta)
 Asserts that the two parameters are equals within a delta.
#define FAIL()   { addTestPartResult(new TestPartResult(this, __FILE__, __LINE__,("Test failed."),failure)); return; }
 Make a test fails.
#define FAIL_M(text)   { addTestPartResult(new TestPartResult(this, __FILE__, __LINE__,text,failure)); return; }
 Make a test fails with the given message.
#define TEST(testCaseName, testName)
 Define a test in a TestCase.
#define TESTF(testCaseName, testName)
 Define a test in a TestCase using test fixtures.
#define SETUP(testCaseName)   void testCaseName##Declare##Test::setUp ()
 Setup code for test fixtures.
#define TEARDOWN(testCaseName)   void testCaseName##Declare##Test::tearDown ()
 Teardown code for test fixtures.
#define DECLARE(testCaseName)
 Location to declare variables and objets.
#define END_DECLARE   };
 Ending macro used after DECLARE.

Define Documentation

#define ASSERT_EQUALS expected,
actual   ) 
 

Value:

{ if (expected == actual) {\ addTestPartResult(new easyunit::TestPartResult(this, __FILE__,__LINE__,TO_STRING_EQUALS_S(#expected,#actual),success));\ } else {\ addTestPartResult(new easyunit::TestPartResult(this, __FILE__,__LINE__,TO_STRING_EQUALS_F(#expected,#actual),failure)); return;\ }}
Asserts that the two parameters are equals.

Operator == must be defined. If the two parameters are not equals, a failure is generated.

Parameters:
expected Expected value
actual Actual value to be compared

#define ASSERT_EQUALS_DELTA expected,
actual,
delta   ) 
 

Value:

{ if (EQUALS_DELTA(expected,actual,delta) ) {\ addTestPartResult(new easyunit::TestPartResult(this, __FILE__,__LINE__,TO_S_E_DELTA_S(#expected,#actual,#delta),success));\ } else {\ addTestPartResult(new easyunit::TestPartResult(this, __FILE__,__LINE__,TO_S_E_DELTA_F(#expected,#actual,#delta),failure)); return;\ }}
Asserts that the two parameters are equals within a delta.

Operators == and - must be defined. If the two parameters are not equals, a failure is generated.

Parameters:
expected Expected value
actual Actual value to be compared
delta Delta accepted between the two values

#define ASSERT_EQUALS_DELTA_M expected,
actual,
delta,
message   ) 
 

Value:

{ if (EQUALS_DELTA(expected,actual,delta)) {\ addTestPartResult(new easyunit::TestPartResult(this, __FILE__,__LINE__,#expected,success));\ } else {\ addTestPartResult(new easyunit::TestPartResult(this, __FILE__,__LINE__,message,failure)); return;\ }}
Asserts that the two parameters are equals within a delta.

Operators == and - must be defined. If the two parameters are not equals, a failure is generated.

Parameters:
expected Expected value
actual Actual value to be compared
delta Delta accepted between the two values
message Message that will be displayed if this assertion fails

#define ASSERT_EQUALS_DELTA_V expected,
actual,
delta   ) 
 

Value:

{ if (EQUALS_DELTA(expected,actual,delta)) {\ addTestPartResult(new easyunit::TestPartResult(this, __FILE__,__LINE__,TO_S_E_DELTA_S(expected,actual,delta),success));\ } else {\ addTestPartResult(new easyunit::TestPartResult(this, __FILE__,__LINE__,TO_S_E_DELTA_F(expected,actual,delta),failure)); return;\ }}
Asserts that the two parameters are equals within a delta.

Operators == and - must be defined. If the two parameters are not equals, a failure is generated.

Parameters must be primitive data types or StringFrom (custom type) must be overloaded.

See also:
easyunit::SimpleString
Parameters:
expected Expected value
actual Actual value to be compared
delta Delta accepted between the two values

#define ASSERT_EQUALS_M expected,
actual,
message   ) 
 

Value:

{ if (expected == actual) {\ addTestPartResult(new easyunit::TestPartResult(this, __FILE__,__LINE__,#expected,success));\ } else {\ addTestPartResult(new easyunit::TestPartResult(this, __FILE__,__LINE__,message,failure)); return;\ }}
Asserts that the two parameters are equals.

Operator == must be defined. If the two parameters are not equals, a failure is generated.

Parameters:
expected Expected value
actual Actual value to be compared
message Message that will be displayed if this assertion fails

#define ASSERT_EQUALS_V expected,
actual   ) 
 

Value:

{ if (expected == actual) {\ addTestPartResult(new easyunit::TestPartResult(this, __FILE__,__LINE__,TO_STRING_EQUALS_S(expected,actual),success));\ } else {\ addTestPartResult(new easyunit::TestPartResult(this, __FILE__,__LINE__,TO_STRING_EQUALS_F(expected,actual),failure)); return;\ }}
Asserts that the two parameters are equals.

Operator == must be defined. If the two parameters are not equals, a failure is generated.

Parameters must be primitive data types or StringFrom (custom type) must be overloaded.

See also:
easyunit::SimpleString
Parameters:
expected Expected value
actual Actual value to be compared

#define ASSERT_TRUE condition   ) 
 

Value:

{ if (condition) {\ addTestPartResult(new easyunit::TestPartResult(this, __FILE__,__LINE__,#condition,success));\ } else {\ addTestPartResult(new easyunit::TestPartResult(this, __FILE__,__LINE__, #condition,failure)); return;\ }}
Asserts that a condition is true.

If the condition is not true, a failure is generated.

Parameters:
condition Condition to fullfill for the assertion to pass

#define ASSERT_TRUE_M condition,
message   ) 
 

Value:

{ if (condition) {\ addTestPartResult(new easyunit::TestPartResult(this, __FILE__,__LINE__,#condition,success));\ } else {\ addTestPartResult(new easyunit::TestPartResult(this, __FILE__,__LINE__, message,failure)); return;\ }}
Asserts that a condition is true.

If the condition is not true, a failure is generated.

Parameters:
condition Condition to fullfill for the assertion to pass
message Message that will be displayed if this assertion fails

#define DECLARE testCaseName   ) 
 

Value:

class testCaseName##Declare##Test : public Test \ { public: testCaseName##Declare##Test(const SimpleString& testCaseName, const SimpleString& testName) : Test (testCaseName , testName) {} \ virtual void run() = 0; void setUp(); void tearDown(); \ protected:
Location to declare variables and objets.

This is where user should declare members accessible by TESTF, SETUP and TEARDOWN.

User should not use brackets after using this macro. User should not initialize any members here.

Parameters:
testCaseName TestCase name of the fixtures
See also:
END_DECLARE for more information.

#define END_DECLARE   };
 

Ending macro used after DECLARE.

User should use this macro after declaring members with DECLARE macro.

#define EQUALS_DELTA expected,
actual,
delta   )     (actual - expected) <= delta && actual >= expected || (expected - actual) <= delta && expected >= actual
 

 
#define FAIL  )     { addTestPartResult(new TestPartResult(this, __FILE__, __LINE__,("Test failed."),failure)); return; }
 

Make a test fails.

#define FAIL_M text   )     { addTestPartResult(new TestPartResult(this, __FILE__, __LINE__,text,failure)); return; }
 

Make a test fails with the given message.

Parameters:
text Failure message

#define SETUP testCaseName   )     void testCaseName##Declare##Test::setUp ()
 

Setup code for test fixtures.

This code is executed before each TESTF.

User should put his setup code between brackets after using this macro.

Parameters:
testCaseName TestCase name of the fixtures.

#define TEARDOWN testCaseName   )     void testCaseName##Declare##Test::tearDown ()
 

Teardown code for test fixtures.

This code is executed after each TESTF.

User should put his setup code between brackets after using this macro.

Parameters:
testCaseName TestCase name of the fixtures.

#define TEST testCaseName,
testName   ) 
 

Value:

class testCaseName##testName##Test : public Test \ { public: testCaseName##testName##Test() : Test (#testCaseName , #testName) {} \ void run(); } \ testCaseName##testName##Instance; \ void testCaseName##testName##Test::run ()
Define a test in a TestCase.

User should put his test code between brackets after using this macro.

Parameters:
testCaseName TestCase name where the test belongs to
testName Unique test name

#define TESTF testCaseName,
testName   ) 
 

Value:

class testCaseName##testName##Test : public testCaseName##Declare##Test \ { public: testCaseName##testName##Test() : testCaseName##Declare##Test (#testCaseName , #testName) {} \ void run(); } \ testCaseName##testName##Instance; \ void testCaseName##testName##Test::run ()
Define a test in a TestCase using test fixtures.

User should put his test code between brackets after using this macro.

This macro should only be used if test fixtures were declared earlier in this order: DECLARE, SETUP, TEARDOWN.

Parameters:
testCaseName TestCase name where the test belongs to. Should be the same name of DECLARE, SETUP and TEARDOWN.
testName Unique test name.

#define TO_S_E_DELTA_F expected,
actual,
delta   )     StringFrom("Expected : ") + StringFrom(expected) + StringFrom(" but Actual : ") + StringFrom(actual) + StringFrom(" with delta = ") + StringFrom(delta)
 

#define TO_S_E_DELTA_S expected,
actual,
delta   )     StringFrom(expected) + StringFrom(" == ") + StringFrom(actual) + StringFrom(" with delta = ") + StringFrom(delta)
 

#define TO_STRING_EQUALS_F expected,
actual   )     StringFrom("Expected : ") + StringFrom(expected) + StringFrom(" but Actual : ") + StringFrom(actual)
 

#define TO_STRING_EQUALS_S expected,
actual   )     StringFrom(expected) + StringFrom(" == ") + StringFrom(actual)
 


Generated on Fri Mar 4 09:51:25 2005 for EasyUnit by doxygen 1.3.8