void Unit Tests

Iterate regular files and directories in a directory path with a callback function, giving names of files. More...


Files

file  unit.h
 Unit test applet definitions shared for unit test.
file  unit.c
 Unit test applet - shouldn't output much of anything unless there's a problem.
file  unit.h
 Unit test applet definitions shared for unit test.

Defines

#define Test_Error(test)
 Unit test check.
#define UNIT_TEST(Test_Name)
 Perform and profile a unit test, checking options for disabling it.
#define Test_Named(name, test)   { if ( !(test) ) { error_count++; puts( ppFileLine("Failed: " name ppTokStr(test) "\n" ) ); throwassert(#test); } }
 Named unit test - give a descriptive failure for a unit check.

Functions

int arg_find (const char *sz, size_t len)
 Get index of CLI argument.
int arg_count (void)
 Get count of arguments passed to main.
const char * arg_get (int index)
 Get an argument that was passed to main.

Detailed Description

Iterate regular files and directories in a directory path with a callback function, giving names of files.

Parameters:
path Specify the directory to iterate (no ending '/', no "*.*")
szmatch An optional wildcard string (may be NULL) to match using 'strwild()' to filter results
callback User provided callback
instance Instance data to pass to user callback
Skips anything starting with '.' The path given to each callback contains the fully qualified search path

Define Documentation

#define Test_Error ( test   ) 

Value:

{ \
    if ( !(test) ) \
    { \
        error_count++; \
        puts( ppFileLine("Failed: " ppTokStr(test) "\n" ) ); \
        ppDebRel(throwassert(#test);,fgetc(stdin);)\
    }\
}
Unit test check.

Parameters:
test Condition that must return true Give details about test failures when something bad happens

Definition at line 40 of file unit.h.

#define Test_Named ( name,
test   )     { if ( !(test) ) { error_count++; puts( ppFileLine("Failed: " name ppTokStr(test) "\n" ) ); throwassert(#test); } }

Named unit test - give a descriptive failure for a unit check.

Parameters:
name Name to give to unit
test Condition that must return true Blurt something in addition to details about test failures when something "bad" happens

Definition at line 82 of file unit.h.


Function Documentation

int arg_count ( void   ) 

Get count of arguments passed to main.

Returns:
Count of arguments passed to main

Definition at line 134 of file unit.c.

00135 {
00136     return mArgc;
00137 }

int arg_find ( const char *  sz,
size_t  len 
)

Get index of CLI argument.

Parameters:
sz Argument string to look for (case sensitive)
Returns:
Index of argument, if found, or 0 if it's not.

Definition at line 110 of file unit.c.

00111 {
00112     int curr;
00113     for ( curr = 1; curr < mArgc; ++curr )
00114     {
00115         if ( 0 == len )
00116         {
00117             if( !cstrcmp(char)( mArgv[curr], sz ) )
00118                 return curr;
00119         }
00120         else 
00121         {
00122             if ( !cstrncmp(char)( mArgv[curr], sz, len ) )
00123                 return curr;
00124         }
00125     }
00126     return 0;
00127 }

const char* arg_get ( int  index  ) 

Get an argument that was passed to main.

Returns:
String of argument, or "" if index out of bounds

Definition at line 144 of file unit.c.

00145 {
00146     if( index < 0 || index > mArgc )
00147         return "";
00148     return mArgv[index];
00149 }


Generated on Fri Jan 2 15:28:36 2009 for Squat by  doxygen 1.5.6