
#ifndef PSTEST_H
#define PSTEST_H

#include <stdio.h>
#include <stdbool.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 int (*testFcn)(void);

typedef struct
{
    testFcn     fcn;
    int         testPointNumber;
    const char* testPointName;
    int         expectedReturn;
    bool        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 //////////////////////////////

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

bool p_runTestSuite(
    FILE *fp,
    const char* testPointFile,
    const char* packageName,
    testDescription tests[],
    int 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,
    int exitValue
);

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

#endif
