Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

psTest.h

Go to the documentation of this file.
00001 /** @file  psTest.h
00002  *
00003  *  Testing infrastructure functions.
00004  *
00005  *  @author Robert DeSonia, MHPCC
00006  *
00007  *  @version $Revision: 1.4 $ $Name: rel12 $
00008  *  @date $Date: 2005/06/17 00:10:55 $
00009  *
00010  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
00011  *
00012  */
00013 
00014 
00015 #ifndef PSTEST_H
00016 #define PSTEST_H
00017 
00018 #include <stdio.h>
00019 
00020 #include "psType.h"
00021 
00022 #define printPositiveTestHeader(filePtr, packageName, testPointName) \
00023 p_printPositiveTestHeader(filePtr, __FILE__, packageName, testPointName)
00024 
00025 #define printNegativeTestHeader(filePtr, packageName, testPointName, expectedError, exitValue) \
00026 p_printNegativeTestHeader(filePtr, __FILE__, packageName, testPointName, expectedError, exitValue)
00027 
00028 #define printFooter(filePtr, packageName, testPointName, success) \
00029 p_printFooter(filePtr, __FILE__, packageName, testPointName, success)
00030 
00031 /** Specifies the format of a user-defined function for use with psTest functions. */
00032 typedef psS32 (*testFcn)(void);
00033 
00034 /** Defines a data structure containing test description information. */
00035 typedef struct
00036 {
00037     testFcn     fcn;                   ///< Specified test function
00038     psS32       testPointNumber;       ///< Test Point Number
00039     const char* testPointName;         ///< Test Point Name
00040     psS32       expectedReturn;        ///< Expected return value
00041     psBool      isDuplicateEntry;      ///< Is the entry a duplicate?
00042 }
00043 testDescription;
00044 
00045 #define runTest(filePtr, packageName, testPointName, fcn, expectedReturn, useFork) \
00046 p_runTest(filePtr, __FILE__, packageName, testPointName, fcn, expectedReturn, useFork)
00047 
00048 #define runTestSuite(filePtr, packageName, tests, argc, argv) \
00049 p_runTestSuite(filePtr, __FILE__, packageName, tests, argc, argv)
00050 
00051 
00052 /////////////////////////// PRIVATE FUNCTIONS //////////////////////////////
00053 
00054 ///XXX: Comments correct?
00055 
00056 /** Procedure used to run a test.
00057  *  
00058  *  @return psBool:    True if successful.
00059  */
00060 psBool p_runTest(
00061     FILE *fp,                          ///< File to test
00062     const char* testPointFile,         ///< Test point in file
00063     const char* packageName,           ///< Package name
00064     const char* testPointName,         ///< Test point name
00065     testFcn fcn,                       ///< Function tested
00066     psS32 expectedReturn,              ///< Expected return
00067     psBool useFork                     ///< Fork to use
00068 );
00069 
00070 /** Procedure used to run the test suite.
00071  *  
00072  *  @return psBool:    True if successful. 
00073  */
00074 psBool p_runTestSuite(
00075     FILE *fp,                          ///< File to test
00076     const char* testPointFile,         ///< Test point in file
00077     const char* packageName,           ///< Package name
00078     testDescription tests[],           ///< Description of tests
00079     psS32 argc,                        ///< Number of test arguments
00080     char * const argv[]                ///< Test arguments
00081 );
00082 
00083 /** Prints a positive test header to file */
00084 void p_printPositiveTestHeader(
00085     FILE *fp,                          ///< File to which to print
00086     const char* testPointFile,         ///< Test point in file
00087     const char* packageName,           ///< Package name
00088     const char* testPointName          ///< Test point name
00089 );
00090 
00091 /** Prints a negative test header to file */
00092 void p_printNegativeTestHeader(
00093     FILE *fp,                          ///< File to which to print
00094     const char* testPointFile,         ///< Test point in file
00095     const char* packageName,           ///< Package name
00096     const char* testPointName,         ///< Test point name
00097     const char* expectedError,         ///< Expected error
00098     psS32 exitValue                    ///< Exit value
00099 );
00100 
00101 /** Prints a footer to file */
00102 void p_printFooter(
00103     FILE *fp,                          ///< File to which to print
00104     const char* testPointFile,         ///< Test point in file
00105     const char* packageName,           ///< Package name
00106     const char* testPointName,         ///< Test point name
00107     psBool success                     ///< True if successful
00108 );
00109 
00110 #endif // #ifndef PSTEST_H

Generated on Mon Jul 3 14:13:44 2006 for Pan-STARRS Foundation Library by  doxygen 1.4.4