mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-04 07:05:26 -04:00
Addition of new makefile scripts.
Addition of the new serialiser (the start anyway). Addition of regression test system. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@249 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
e0304cd2de
commit
a89e5a4784
30 changed files with 4700 additions and 0 deletions
40
libretroshare/src/util/exampletst.c
Normal file
40
libretroshare/src/util/exampletst.c
Normal file
|
@ -0,0 +1,40 @@
|
|||
|
||||
#include "utest.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/* must define the global variables */
|
||||
INITTEST();
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int a = 2;
|
||||
int b = 3;
|
||||
int c = 2;
|
||||
|
||||
CHECK( a == c );
|
||||
|
||||
REPORT( "Initial Tests");
|
||||
|
||||
CHECK( (0 == strcmp("123", "123")) );
|
||||
|
||||
REPORT( "Successful Tests");
|
||||
|
||||
CHECK( a == b );
|
||||
CHECK( (0 == strcmp("123", "12345")) );
|
||||
|
||||
REPORT( "Failed Tests" );
|
||||
|
||||
CHECK( 1 );
|
||||
CHECK( a == c );
|
||||
|
||||
REPORT( "Later Successful Tests");
|
||||
|
||||
|
||||
FINALREPORT( "Example Tests" );
|
||||
|
||||
return TESTRESULT();
|
||||
}
|
||||
|
||||
|
||||
|
23
libretroshare/src/util/utest.h
Normal file
23
libretroshare/src/util/utest.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
#ifndef _UNIT_TEST_MACROS_H__
|
||||
#define _UNIT_TEST_MACROS_H__
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define TFAILURE( s ) printf( "FAILURE: " __FILE__ ":%-4d %s\n", __LINE__, s )
|
||||
#define TSUCCESS( s ) printf( "SUCCESS: " __FILE__ ":%-4d %s\n", __LINE__, s )
|
||||
|
||||
/* careful with this line (no protection) */
|
||||
#define INITTEST() int ok = 1; int gok = 1;
|
||||
|
||||
/* declare the variables */
|
||||
extern int ok;
|
||||
extern int gok;
|
||||
|
||||
#define CHECK( b ) do { if ( ! (b) ) { ok = 0; TFAILURE( #b ); } } while(0)
|
||||
#define FAILED( s ) do { ok = 0; TFAILURE( s ); } while(0)
|
||||
#define REPORT( s ) do { if ( ! (ok) ) { ok = 0; TFAILURE( s ); } else { TSUCCESS( s );} gok &= ok; ok = 1; } while(0)
|
||||
#define REPORT2( b, s ) do { if ( ! (b) ) { ok = 0; TFAILURE( s ); } else { TSUCCESS( s );} gok &= ok; ok = 1; } while(0)
|
||||
#define FINALREPORT( s ) do { gok &= ok; ok = 1; if ( ! (gok) ) { TFAILURE( s ); } else { TSUCCESS( s );} } while(0)
|
||||
#define TESTRESULT() (!gok)
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue