One Line Unit Test

Added a nice macro to the metawrap testing framework that allows a simple unit test to be put in one line in C and  C++ with exception handling and failover reporting.

void Tests_MwNativeString()
{
    #define MW_UNIT MwNativeString 
    MwNativeString l_string;
    MW_UNIT_TEST_ASSERT(Constructor1,l_string.emptystring(),Ensure that constructor starts with an empty string“);
    MwNativeString l_string2(“Hello”);
    MW_UNIT_TEST_ASSERT(Constructor2,l_string2.is(“Hello”),Ensure that constructor populates.“);
    #undef MW_UNIT
}

Nice and simple. The individual unit test is not segregated from others – so it would not be wise to rely on the results of testcases.

Good articles on “Good OO Design” are rare. This is one of them.

Unknown's avatar

About James McParlane

CTO Massive Interactive. Ex Computer Whiz Kid - Now Grumpy Old Guru.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a comment