medfall

A super great game engine
Log | Files | Refs

commit 269a37d28e97b39bcb285487a252bf4588bdc6f1
parent f98f61997026b180c4a8fdd062cafa2967f311ca
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Fri Apr  7 22:35:58 +0300

Add ggunit.h

Diffstat:
ggunit.h | 46++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+), 0 deletions(-)
diff --git a/ggunit.h b/ggunit.h @@ -0,0 +1,46 @@ +#pragma once + +#if defined( UNITTESTS ) + +#include <stdio.h> + +#define CONCAT_HELPER( a, b ) a##b +#define CONCAT( a, b ) CONCAT_HELPER( a, b ) +#define COUNTER_NAME( x ) CONCAT( x, __COUNTER__ ) + +#define AT_STARTUP( code ) \ + namespace COUNTER_NAME( StartupCode ) { \ + static struct AtStartup { \ + AtStartup() { code; } \ + } AtStartupInstance; \ + } + +#define UNITTEST( name, body ) \ + namespace { \ + AT_STARTUP( \ + int passed = 0; \ + int failed = 0; \ + puts( name ); \ + body; \ + printf( "%d passed, %d failed\n\n", passed, failed ); \ + ) \ + } + +#define TEST( p ) \ + if( !( p ) ) { \ + failed++; \ + puts( " FAIL: " #p ); \ + } \ + else { \ + passed++; \ + } + +#define private public +#define protected public + +#else + +#define UNITTEST( name, body ) +#define TEST( p ) + +#endif