/** @file  tst_psTime_02.c
 *
 *  @brief Test driver for psTime functions
 *
 *  This test driver contains the following tests for psTime:
 *     A) Incorrect ISO time data
 *     B) Attempt to use null timeval
 *     C) Free data
 *
 *  @author  Ross Harman, MHPCC
 *
 *  @version $Revision: 1.9 $  $Name: not supported by cvs2svn $
 *  @date  $Date: 2005-02-17 19:26:24 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
 *
 */

#include "pslib.h"
#include "psTest.h"

psS32 main(psS32 argc, char* argv[])
{

    // Test A - Incorrect ISO time data
    printNegativeTestHeader(stdout,"psTime", "Incorrect ISO time data", "Time not allowed", 0);
    psTimeFromISOTime("2004-99-21T18:22:24.272Z");
    psTimeFromISOTime("2004-07-99T18:22:24.272Z");
    psTimeFromISOTime("2004-07-21T99:22:24.272Z");
    psTimeFromISOTime("2004-07-21T18:99:24.272Z");
    psTimeFromISOTime("2004-07-21T18:22:99.272Z");
    psTimeFromISOTime("2004-07-21T18:22:24.-999Z");
    printFooter(stdout, "psTime", "Incorrect ISO time data", true);


    // Test B - Attempt to use null timeval
    printNegativeTestHeader(stdout,"psTime", "Attempt to use null timeval", "Null value for timeval arg not allowed", 0);
    psTimeFromTimeval(NULL);
    printFooter(stdout, "psTime", "Attempt to use null timeval", true);


    // Test C - Free data
    printPositiveTestHeader(stdout, "psTime", "Test C - Free data");
    if ( psMemCheckLeaks(0, NULL, stdout,false) != 0) {
        psError(PS_ERR_UNKNOWN,true,"Memory leaks detected");
        return 10;
    }
    psMemCheckCorruption(0);
    psS32 nBad = psMemCheckCorruption(0);
    if(nBad) {
        printf("ERROR: Found %d bad memory blocks\n", nBad);
    }
    printFooter(stdout, "psTime", "Test C - Free data", true);

    return 0;
}
