Category : C Source Code
Archive   : ACTLIB14.ZIP
Filename : CHECK.H

 
Output of file : CHECK.H contained in archive : ACTLIB14.ZIP
/***
* Copyright (C) 1993 Marc Stern (internet: [email protected])
*
* File : check.h
*
* Description : General macros for testing pre- and post-conditions.
*
* OS/Compiler : All
*
* Decisions : Will use the tracing if defined
*
* Usage : - To check a precondition call the function
* 'precond( string_to_print, expression );'
*
* - Define 'PRE' to actually perform precondition check.
*
* - To check a postcondition call the function
* 'postcond( string_to_print, expression );'
*
* - Define 'POST' to actually perform postcondition check.
*
* - To check a condition call the function
* 'check( string_to_print, expression );'
*
* - Define 'CHECK' to actually perform check.
*
***/


#ifndef __Check_H
#define __Check_H

#include "trace.h"

#ifdef TRACE
#define ch_trace trace
#else
#define ch_trace( args ) printf args
#endif

/* MACROS DEFINITIONS */


#ifdef PRE

#define precond( test , expr ) \
if ( ! (expr) ) \
{ printf( "\n" ) ; \
ch_trace( ("*** " #test " : Precondition failed\n") ) ; \
ch_trace( (" ** in file : " __FILE__ "\n") ) ; \
ch_trace( (" ** at line : %d\n" , __LINE__) ) ; \
ch_trace( (" ** '" #expr "' is false\n\n") ) ; \
}

#else

#define precond( test , expr )

#endif

#ifdef POST

#define postcond( test , expr ) \
if ( ! (expr) ) \
{ printf( "\n" ) ; \
ch_trace( ("*** " #test " : Postcondition failed\n") ) ; \
ch_trace( (" ** in file : " __FILE__ "\n") ) ; \
ch_trace( (" ** at line : %d\n" , __LINE__) ) ; \
ch_trace( (" ** '" #expr "' is false\n\n") ) ; \
}

#else

#define postcond( test , expr )

#endif

#ifdef CHECK

#define check( test , expr ) \
if ( ! (expr) ) \
{ printf( "\n" ) ; \
ch_trace( ("*** " #test " : Check failed\n") ) ; \
ch_trace( (" ** in file : " __FILE__ "\n") ) ; \
ch_trace( (" ** at line : %d\n" , __LINE__) ) ; \
ch_trace( (" ** '" #expr "' is false\n\n") ) ; \
}

#else

#define check( test , expr )

#endif



#endif


  3 Responses to “Category : C Source Code
Archive   : ACTLIB14.ZIP
Filename : CHECK.H

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/