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.

Advertisements

About metawrap

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s