Following is my 'assert' definition:
#ifdef MY_DEBUG
#define ASSERT(f, message) \
if(f) \
NULL; \
else{ \
while(1){ \
IV_PRINTF(("Error: ASSERT Violation -- , %s\n", message));
\
EtiUtilWaitMilliSeconds(10000000); \
}}
#else
#define ASSERT(f, message) NULL
#endif
Try to use 'assert' in following cases:
-
That an input parameter's value falls within its expected range (or an output parameter's value does)
-
That a file or stream is open (or closed) when a routine begins executing (or when it ends executing)
-
That a file or stream is at the beginning (or end) when a routine begins executing (or when it ends executing)
-
That a file or stream is open for read-only, write-only, or both read and write
-
That the value of an input-only variable is not changed by a routine
-
That a pointer is non-null
-
That an array or other container passed into a routine can contain at least X number of data elements
-
That a table has been initialized to contain real values
-
That a container is empty (or full) when a routine begins executing (or when it finishes)
-
That the results from a highly optimized, complicated routine match the results from a slower but clearly written routine
No comments:
Post a Comment