/*Skeleton TestHarness class .cpp*/

#include "TestHarness.h"

/* Note: At first there will be a lot of errors when you 
 * try to compile, I suggest you comment out all the code
 * in the tests to begin with and work on the classes starting 
 * with Pattern, then Input Pattern etc.  Once input pattern
 * is complete you can start testing
 */

#include "InputPattern.h"
#include "OutputPattern.h"
#include "SSNSFile.h"

TestHarness::TestHarness(void)
{	

}

TestHarness::~TestHarness(void)
{

}

bool TestHarness::testInputPatternCreate()
{
	/* Testing a constructor is a bit tricky, 
	 * so here's the code for the first one 
	 * there are better ways to test (try / catch)
         */

	bool testResult = false;

	//Set pointer to NULL (0)
	InputPattern* test = NULL;

	//Allocate
	test = new InputPattern();

	//Make sure its no longer null	
	if(test != NULL)
		testResult = true;

	delete test;
	return testResult;
}

bool TestHarness::testInputPatternSetup()
{
	/* Test the get/set methods here 
	 * remember you can't use == with float
	 * you'll need to check the difference is 
	 * less than 0.0001 (DELTA) */

	/* Create a new SSNSFile object */

	/* Test get and set for s, i, j and k */

	/* delete the test object */

	/* return the test result */

}

bool TestHarness::testInputPatternCreateWithParamters()
{
	/* Create and test overloaded constructor works */
}

bool TestHarness::testInputPatternsDestroy()
{
	/* No memory allocated, difficult to tell if this has worked */
}

bool TestHarness::testInputPatternsPrint()
{
	/* Create an object, set values and print 
         * check will be on screen 
         */
}

bool TestHarness::testOutputPatternCreate()
{
	/* See notes for InputPattern tests above */
}

bool TestHarness::testOutputPatternSetup()
{
	/* See notes for InputPattern tests above */
}

bool TestHarness::testOutputPatternCreateWithParamters()
{
	/* See notes for InputPattern tests above */
}

bool TestHarness::testOutputPatternsDestroy()
{
	/* See notes for InputPattern tests above */
}

bool TestHarness::testOutputPatternsPrint()
{
	/* See notes for InputPattern tests above */
}


bool TestHarness::testSSNSFileCreate()
{
	/* See notes for InputPattern tests above */
}

bool TestHarness::testSSNSFileSetFilepath()
{
	/* Check that the filepath can be set and recovered 
         * take care when comparing strings 
         */
}	

bool TestHarness::testSSNSFileAddGetInputPattern()
{
	/* This is roughly how this test should go. */
	InputPattern* input = new InputPattern(0.1f,0.2f,0.3f,0.4f);
	
	SNNSFile *snns = new SNNSFile();

	/*This creates the arrays for the input and output patterns, 
       * when the class is used in production this will be done by
       * loadFile()
       */
  
	snns->setUpForTesting(1,1);

	snns->addInputPattern(input);

	/* get the pattern back and check its the right one. */
      
	InputPattern *inputBack = snns->getInputPattern(0);

	if(input->isEqual(inputBack))
		return true;
	else 
		return false;

	delete snns; //Do not try and delete the 'input',
                      //'snns' class takes responsiblity for
                      //this object. 
}

bool TestHarness::testSSNSFileAddGetOutputPattern()
{
	/* Check that output patterns can be added 
	 * HINT: This may require an additional method 
	 */
}

bool TestHarness::testSSNSFileLoadFile()
{
	/* Can check this works by giving it a known file
         * loading it and looking at the content.  We can
         * also check the first pattern of each? 
         */
}

bool TestHarness::testSSNSFileLoadedFlag()
{
	/* Can check this works by giving it a known file
         * loading it and looking at the content.  We can
         * also check the first pattern of each? Then check
	 * the file gives what we expect. Should also consider
         * a test for the file not loading (i.e. no filename 
         * and no existent file).  
         */
}

bool TestHarness::testSSNSFilePrintMeta()
{
	/* Load a file, make sure the meta data is what we expect */
}

bool TestHarness::testSSNSFilePrintPatterns()
{
	/* Load a file, make sure the patterns are what we expect */
}

bool TestHarness::testInputPattern()
{
	const int TEST_COUNT = 5;
	int testsComplete = 0;

	if(this->testInputPatternCreate() == true)
	{ 
		printf("InputPattern Create test PASSED \n");
		testsComplete++;
	}
	else
	{
		printf("Input Pattern Create test FAILED \n");
	}

	/* need add the other tests */

	if(testsComplete == TEST_COUNT)
		return true;
	else
		return false;
}

bool TestHarness::testOutputPattern()
{
	/* See above */
}

bool TestHarness::testSSNSFile()
{
	/* See above */
}

int main(char* argc[], int argv)
{
	TestHarness *t = new TestHarness();

	t->testInputPattern();
	t->testOutputPattern();
	t->testSSNSFile();

	delete t;

	return 0;
}
