
#ifndef PSTEST_H
#define PSTEST_H

#include <stdio.h>

#include "psType.h"

#define printPositiveTestHeader(filePtr, packageName, testPointName) \
p_printPositiveTestHeader(filePtr, __FILE__, packageName, testPointName)

#define printNegativeTestHeader(filePtr, packageName, testPointName, expectedError, exitValue) \
p_printNegativeTestHeader(filePtr, __FILE__, packageName, testPointName, expectedError, exitValue)

#define printFooter(filePtr, packageName, testPointName, success) \
p_printFooter(filePtr, __FILE__, packageName, testPointName, success)

typedef psS32 (*testFcn)(void);

typedef struct
{
    testFcn     fcn;
    psS32       testPointNumber;
    const char* testPointName;
    psS32       expectedReturn;
    psBool      isDuplicateEntry;
}
testDescription;

#define runTest(filePtr, packageName, testPointName, fcn, expectedReturn, useFork) \
p_runTest(filePtr, __FILE__, packageName, testPointName, fcn, expectedReturn, useFork)

#define runTestSuite(filePtr, packageName, tests, argc, argv) \
p_runTestSuite(filePtr, __FILE__, packageName, tests, argc, argv)


/////////////////////////// PRIVATE FUNCTIONS //////////////////////////////

psBool p_runTest(
    FILE *fp,
    const char* testPointFile,
    const char* packageName,
    const char* testPointName,
    testFcn fcn,
    psS32 expectedReturn,
    psBool useFork
);

psBool p_runTestSuite(
    FILE *fp,
    const char* testPointFile,
    const char* packageName,
    testDescription tests[],
    psS32 argc,
    char * const argv[]
);

void p_printPositiveTestHeader(
    FILE *fp,
    const char* testPointFile,
    const char* packageName,
    const char* testPointName
);

void p_printNegativeTestHeader(
    FILE *fp,
    const char* testPointFile,
    const char* packageName,
    const char* testPointName,
    const char* expectedError,
    psS32 exitValue
);

void p_printFooter(
    FILE *fp,
    const char* testPointFile,
    const char* packageName,
    const char* testPointName,
    psBool success
);

#endif // #ifndef PSTEST_H
