示例#1
0
void 
TestCaseTest::checkFailure( bool failSetUp, 
                            bool failRunTest,
                            bool failTearDown )
{
  try
  {
    MockTestCase testCase( "mock-test" );
    if ( failSetUp )
      testCase.makeSetUpThrow();
    if ( failRunTest )
      testCase.makeRunTestThrow();
    if ( failTearDown )
      testCase.makeTearDownThrow();
    testCase.setExpectedSetUpCall( 1 );
    testCase.setExpectedRunTestCall( failSetUp ? 0 : 1 );
    testCase.setExpectedTearDownCall( failSetUp ? 0 : 1 );
    
    testCase.run( m_result );

    testCase.verify();
  }
  catch ( FailureException & )
  {
    CPPUNIT_ASSERT_MESSAGE( "exception should have been caught", false );
  }
}
示例#2
0
int setPorteAvion(int nbPorteAvion, int plateau[PLATEAU_HEIGHT][PLATEAU_WIDTH]){
    int i = 0;
    int x = -1;
    int y = -1;
    int flag = 1;

    for(i=0;i<nbPorteAvion;i++){
        while(flag){
            //Allow user to select coordinate
            y = userChoise();
            x = userChoise();

            //Test if boat can go in the array of cells
            if(testCase(x,y,PORTE_AVION_WIDTH,plateau) == 0){

                //Set realy the boat in the array
                setNavire(x,y,PORTE_AVION_WIDTH,PORTE_AVION_ID,plateau);

                //If all ok return
                flag = 0;
            }
        }
        flag = 1;
    }
}
示例#3
0
文件: TRIE.C 项目: not-jay/Tries-ADT
boolean testCase(Trie trie, char *str, DeleteCase caseNum) {
	Node current = trie->dummy;
	boolean result = false;
	int i;

	switch(caseNum) {
		case case1:
			for(i = 0; i < strlen(str) - 1; i++) {
				current = findChild(current, str[i]);
				if(current->children > 1) return false;
			}
			result = !(current->children > 1);
			break;
		case case2:
			for(i = 0; i < strlen(str); i++) {
				current = findChild(current, str[i]);
			}
			result = (current->children >= 1);
			break;
		case case3:
			result = !testCase(trie, str, case2);
			break;
	}

	return result;
}
示例#4
0
/*
 * Entry point of program execution
 */
int main( void )
{
    
    printf("test result: %d\n", testCase());
    
    //assert(0);
    return 0;                 // not reachable
}
/**
See BT_ROMCONFIG_USER_002.script
*/
TVerdict CTestStepBtRomConfigUser002::doTestStepL()
	{
	INFO_PRINTF1(_L("&gt;&gt;CTestStepBtRomConfigUser002::doTestStepL()"));
	
	CActiveScheduler* sched(new (ELeave)CActiveScheduler);
	CActiveScheduler::Install(sched);
	CleanupStack::PushL(sched);

	User::LeaveIfError(iSocketServ.Connect());
	
	TInt expectedError(KErrNotSupported);

	const TInt numTestCases(25);
	
	for (TInt testCase(0); testCase < numTestCases; ++testCase)
		{
		TRAPD(err, TestBluetoothSocketConstructorL(testCase, expectedError));
		
		if (expectedError != err)
			{
			// this is only used for logging readability purposes
			const TDesC* expectedErrorDesPtr(0);

			switch (expectedError)
				{
			case KErrNotFound:
				expectedErrorDesPtr = &KErrNotFoundLit;
				break;
			case KErrNone:
				expectedErrorDesPtr = &KErrNoneLit;
				break;
			case KErrBadName:
				expectedErrorDesPtr = &KErrBadNameLit;
				break;
			case KErrNotSupported:
				expectedErrorDesPtr = &KErrNotSupportedLit;
				break;
			default:
				User::Panic(KUnexpectedError, testCase);
				}

			INFO_PRINTF5(_L("Failed: Expected %S(%d) and got %d calling CBluetoothSocket constructor case %d"), 
						 expectedErrorDesPtr, expectedError, err, testCase);
			SetTestStepResult(EFail);
			}
		}
	
	INFO_PRINTF2(_L("Tested %d cases"), numTestCases);
	
	iSocketServ.Close();
	
	CleanupStack::PopAndDestroy(sched);
	INFO_PRINTF1(_L("&lt;&lt;CTestStepBtRomConfigUser002::doTestStepL()"));
	
	CheckAndSetTestResult();
	return TestStepResult();
	}
示例#6
0
int main(int argc, char *argv[])
{
#ifndef NOCATCH
  try
  {
#endif
	TestCase testCase( argc, argv );

#ifdef RELOCATE
	std::vector<Geometry::byte> altbuffer;
#endif
	
#ifdef RELOCATE
	altbuffer.resize(testCase.geom->size());
	testCase.geom->relocate( &(altbuffer[0]) );
	std::memcpy( &(altbuffer[0]), testCase.geom->getBuffer(), testCase.geom->size() );
	std::memset( testCase.geom->getBuffer(), 0, testCase.geom->size() );
#endif
	
#ifdef RELOCATE
	testCase.geom.reset();

	G4VPhysicalVolume *geomRoot =
		(G4VPhysicalVolume*)&(altbuffer[0]);
#else
	G4VPhysicalVolume *geomRoot =
		(G4VPhysicalVolume*)testCase.geom->getBuffer();
#endif
	
	const my_clock_t t0 = my_clock();
	BEGIN_ENERGY_MEASUREMENT;
	cpuexec(
		// number of rounds multiplies problem size, no separate rounds
		testCase.getSize() * testCase.getRounds(),
		&(testCase.input[0]),
		geomRoot,
		&(testCase.output[0]),
		testCase.phys_step );
	const my_clock_t t1 = my_clock();
	END_ENERGY_MEASUREMENT;
	
	std::cerr << "Elapsed: " << tdiffms(t0,t1) << " ms\n";
	
	testCase.outputData( "imgcpu.txt" );
	
	return EXIT_SUCCESS;
#ifndef NOCATCH
  }
  catch ( const std::runtime_error &e )
  {
	std::cerr << e.what() << std::endl;
	return EXIT_FAILURE;
  }
#endif
}
示例#7
0
void cOutputCreatorTest::testDatabaseResults()  throw()
{
    printNote( "DATABASE RESULTS TESTS" );

    try
    {
        unsigned long long ulSummaryId = m_poOC->uploadActionSummary();

        QSqlQuery obSummaryQuery( QString( "SELECT nbPatients, nbMovements, cellName FROM cyclerconfigs WHERE cyclerconfigId=%1" ).arg( ulSummaryId ) );

        testCase( "Number of cyclerconfigs records created", 1, obSummaryQuery.size() );

        obSummaryQuery.first();
        testCase( "Value of nbPatients column of the new record", 80, obSummaryQuery.value( 0 ).toInt() );
        testCase( "Value of nbMovements column of the new record", 52, obSummaryQuery.value( 1 ).toInt() );
        testCase( "Value of the cellName column of the new record", "LARA_TEST_CELL", obSummaryQuery.value( 2 ).toString().toStdString() );

        m_poOC->uploadActionList();

        QSqlQuery obListQuery( QString( "SELECT occurrencePattern FROM occurrences WHERE cyclerconfigId=%1" ).arg( ulSummaryId ) );

        testCase( "Number of occurrences records created", 4, obListQuery.size() );

        if( obListQuery.first() )
            testCase( "Value of occurrencePattern column of occurrence record 1",
                      "LARA_TEST_OK_ALWAYS", obListQuery.value( 0 ).toString().toStdString() );

        if( obListQuery.next() )
            testCase( "Value of occurrencePattern column of occurrence record 2",
                      "LARA_TEST_OK_OK", obListQuery.value( 0 ).toString().toStdString() );

        if( obListQuery.next() )
            testCase( "Value of occurrencePattern column of occurrence record 3",
                      "", obListQuery.value( 0 ).toString().toStdString() );

        if( obListQuery.next() )
            testCase( "Value of occurrencePattern column of occurrence record 4",
                      "LARA_TEST_FAILED_FAILED", obListQuery.value( 0 ).toString().toStdString() );

    } catch( cSevException &e )
    {
        g_obLogger << e;
        m_uiFailedNum++;
    }
}
示例#8
0
文件: TRIE.C 项目: not-jay/Tries-ADT
/*
 * Trie deletion has 3 cases
 *
 * Case 1: The word is a separate branch in the tree and it doesn't have
 *         any other children. Simply delete the starting node.
 * Case 2: The word contains suffices. Only remove the "word" marker
 * Case 3: The reverse of Case 2. The word is a suffix. Delete only the
 *		   suffix
 *
 * This only replaces the deleted node with NULL and then calling the
 * sortChild() function and then realloc()
 *
 * realloc() only fails if size == 0 or if the block cannot be reallocated
 */
void deleteWord(Trie trie, char *str) {
	Node current = trie->dummy, temp = NULL;
	int i, tmp;

	if(!searchWord(trie, str)) return;

	/* Test for case 1*/
	if(testCase(trie, str, case1)) {
		/* Simply remove the node */
		i = findChildID(current, str[0]);
		nodeDelete(current->child[i]);
		resizeChildren(current);
	} else if(testCase(trie, str, case2)) { /* Test for case 2 */
		/* No real deletion occurs here, the nodes would
		 * still be there, but it makes the word unsearchable
		 */
		for(i = 0; i < strlen(str); i++) {
			current = findChild(current, str[i]);
		}
		current->endMarker = false;
	} else if(testCase(trie, str, case3)) { /* Test for case 3 */
		/* Traverse the word and keep track on which node
		 * had children > 1, then find the next matching node
		 * and delete it
		 */
		 temp = trie->dummy;

		 for(i = 0; i < strlen(str); i++) {
			temp = findChild(temp, str[i]);
			if(temp->children > 1) {
				current = temp;
				tmp = i+1;
			}
		 }
		 i = findChildID(current, str[tmp]);
		 nodeDelete(current->child[i]);
		 resizeChildren(current);
	}
}
示例#9
0
int setCroiseur(int nbCroiseur, int plateau[PLATEAU_HEIGHT][PLATEAU_WIDTH]){
    int i = 0;
    int x = -1;
    int y = -1;
    int flag = 1;

    for(i=0;i<nbCroiseur;i++){
        while(flag){
            y = doRand(0,PLATEAU_HEIGHT);
            x = doRand(0,PLATEAU_WIDTH);
            if(testCase(x,y,CROISEUR_WIDTH,plateau) == 0){
                setNavire(x,y,CROISEUR_WIDTH,CROISEUR_ID,plateau);
                flag = 0;
            }
        }
        flag = 1;
    }
}
示例#10
0
int setCorvette(int nbCorvette, int plateau[PLATEAU_HEIGHT][PLATEAU_WIDTH]){
    int i = 0;
    int x = -1;
    int y = -1;
    int flag = 1;

    for(i=0;i<nbCorvette;i++){
        while(flag){
            y = doRand(0,PLATEAU_HEIGHT);
            x = doRand(0,PLATEAU_WIDTH);
            if(testCase(x,y,CORVETTE_WIDTH,plateau) == 0){
                setNavire(x,y,CORVETTE_WIDTH,CORVETTE_ID,plateau);
                flag = 0;
            }
        }
        flag = 1;
    }
}
示例#11
0
int setDestroyer(int nbDestroyer, int plateau[PLATEAU_HEIGHT][PLATEAU_WIDTH]){
    int i = 0;
    int x = -1;
    int y = -1;
    int flag = 1;

    for(i=0;i<nbDestroyer;i++){
        while(flag){
            y = doRand(0,PLATEAU_HEIGHT);
            x = doRand(0,PLATEAU_WIDTH);
            if(testCase(x,y,DESTROYER_WIDTH,plateau) == 0){
                setNavire(x,y,DESTROYER_WIDTH,DESTROYER_ID,plateau);
                flag = 0;
            }
        }
        flag = 1;
    }
}
示例#12
0
文件: Q1a.cpp 项目: dunnrr/COMP272
int main(void)
{
	PriorityQueue<int> queue;						//create queue
	int test = 1;									//assign test case value
	
	testCase(test);									//print out test case no.
	queue.add(19);									//add items to queue
	queue.add(7);
	queue.add(1);
	queue.add(5);
	queue.add(3);
	queue.add(20);
	queue.add(15);
	queue.add(5);
	printQueue(queue);								//print queue
	
	testCase(test);									//print out test case no.
	sizeQueue(queue);								//queue size

	testCase(test);									//print out test case no.
	minQueue(queue);								//retrieve minimum element

	testCase(test);									//print out test case no.
	while (!queue.empty())							//cycle until empty
	{
		deleteMin(queue);							//delete minimum element
		printQueue(queue);							//print queue
	}

	testCase(test);									//print out test case no.
	sizeQueue(queue);								//queue size

	testCase(test);									//print out test case no.
	minQueue(queue);								//retrieve minimum element

	testCase(test);									//print out test case no.
	deleteMin(queue);								//delete minimum element
	return EXIT_SUCCESS;							//exit success
}
示例#13
0
//--------------------------------------------------------------------------
void PixelFormatTests::testBulkConversion()
{
    UnitTestSuite::getSingletonPtr()->startTestMethod(__FUNCTION__);

    // Self match
    testCase(PF_A8R8G8B8, PF_A8R8G8B8);

    // Optimized
    testCase(PF_A8R8G8B8,PF_A8B8G8R8);
    testCase(PF_A8R8G8B8,PF_B8G8R8A8);
    testCase(PF_A8R8G8B8,PF_R8G8B8A8);
    testCase(PF_A8B8G8R8,PF_A8R8G8B8);
    testCase(PF_A8B8G8R8,PF_B8G8R8A8);
    testCase(PF_A8B8G8R8,PF_R8G8B8A8);
    testCase(PF_B8G8R8A8,PF_A8R8G8B8);
    testCase(PF_B8G8R8A8,PF_A8B8G8R8);
    testCase(PF_B8G8R8A8,PF_R8G8B8A8);
    testCase(PF_R8G8B8A8,PF_A8R8G8B8);
    testCase(PF_R8G8B8A8,PF_A8B8G8R8);
    testCase(PF_R8G8B8A8,PF_B8G8R8A8);

    testCase(PF_A8B8G8R8, PF_L8);
    testCase(PF_L8, PF_A8B8G8R8);
    testCase(PF_A8R8G8B8, PF_L8);
    testCase(PF_L8, PF_A8R8G8B8);
    testCase(PF_B8G8R8A8, PF_L8);
    testCase(PF_L8, PF_B8G8R8A8);
    testCase(PF_L8, PF_L16);
    testCase(PF_L16, PF_L8);
    testCase(PF_R8G8B8, PF_B8G8R8);
    testCase(PF_B8G8R8, PF_R8G8B8);
    testCase(PF_B8G8R8, PF_R8G8B8);
    testCase(PF_R8G8B8, PF_B8G8R8);
    testCase(PF_R8G8B8, PF_A8R8G8B8);
    testCase(PF_B8G8R8, PF_A8R8G8B8);
    testCase(PF_R8G8B8, PF_A8B8G8R8);
    testCase(PF_B8G8R8, PF_A8B8G8R8);
    testCase(PF_R8G8B8, PF_B8G8R8A8);
    testCase(PF_B8G8R8, PF_B8G8R8A8);
    testCase(PF_A8R8G8B8, PF_R8G8B8);
    testCase(PF_A8R8G8B8, PF_B8G8R8);
    testCase(PF_X8R8G8B8, PF_A8R8G8B8);
    testCase(PF_X8R8G8B8, PF_A8B8G8R8);
    testCase(PF_X8R8G8B8, PF_B8G8R8A8);
    testCase(PF_X8R8G8B8, PF_R8G8B8A8);
    testCase(PF_X8B8G8R8, PF_A8R8G8B8);
    testCase(PF_X8B8G8R8, PF_A8B8G8R8);
    testCase(PF_X8B8G8R8, PF_B8G8R8A8);
    testCase(PF_X8B8G8R8, PF_R8G8B8A8);
}
示例#14
0
文件: unittests.cpp 项目: DaniM/lyngo
//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------
TestCase::TestCase (std::string&& name, TestCaseFunction&& testCase)
: name (name)
{
	testCase (this);
}
示例#15
0
int main (int argc, char *argv[]) {
    testCase();
    return EXIT_SUCCESS;
}
示例#16
0
void cActionDefTest::testPatterns() throw()
{
    printNote( "PATTERN TESTS" );

    try
    {
        cPattern  *poPattern;
        poPattern = new cPattern();

        testCase( "Pattern empty constructor Name", "", poPattern->name().toStdString() );

        testCase( "Pattern empty constructor Pattern", "", poPattern->pattern().toStdString() );

        testCase( "Pattern empty constructor Captures List empty", true, poPattern->captures().empty() );

        delete poPattern;

        poPattern = new cPattern( NULL );

        testCase( "Pattern NULL DOM Element Name", "", poPattern->name().toStdString() );

        testCase( "Pattern NULL DOM Element Pattern", "", poPattern->pattern().toStdString() );

        testCase( "Pattern NULL DOM Element Captures List empty", true, poPattern->captures().empty() );

        delete poPattern;

        QDomDocument obDomDoc( "ActionTest" );
        QDomElement obDomElem = obDomDoc.createElement( "pattern" );
        obDomElem.setAttribute( "name", "GRENADE_INSTRUCTIONS" );
        obDomElem.setAttribute( "regexp", "([\\d]*)[\\D]*([\\d]*)[\\D]*([\\d]*)" );
        QDomElement obCap1 = obDomDoc.createElement( "captured_attrib" );
        obCap1.setAttribute( "name", "NOT_COUNT" );
        QDomElement obCap2 = obDomDoc.createElement( "captured_attrib" );
        obCap2.setAttribute( "name", "NEITHER_COUNT" );
        QDomElement obCap3 = obDomDoc.createElement( "captured_attrib" );
        obCap3.setAttribute( "name", "EXCEPT_COUNT" );
        obDomElem.appendChild( obCap1 );
        obDomElem.appendChild( obCap2 );
        obDomElem.appendChild( obCap3 );

        poPattern = new cPattern( &obDomElem );

        testCase( "Pattern Correct DOM Element Name", "GRENADE_INSTRUCTIONS", poPattern->name().toStdString() );

        testCase( "Pattern Correct DOM Element Pattern", "([\\d]*)[\\D]*([\\d]*)[\\D]*([\\d]*)", poPattern->pattern().toStdString() );

        testCase( "Pattern Correct DOM Element Captures List size", 3, poPattern->captures().size() );

        QStringList slNumbers = poPattern->capturedTexts( "4 shalt thou not count, neither count thou 2, excepting that thou then proceed to 3." );

        testCase( "Pattern Correct DOM Element Captured Text List size", 4, slNumbers.size() );

        testCase( "Pattern Correct DOM Element Captured Attrib 1 Name", "NOT_COUNT", poPattern->captures().at( 0 ).toStdString() );

        testCase( "Pattern Correct DOM Element Captured Attrib 1 Text", "4", slNumbers.at( 1 ).toStdString() );

        testCase( "Pattern Correct DOM Element Captured Attrib 2 Name", "NEITHER_COUNT", poPattern->captures().at( 1 ).toStdString() );

        testCase( "Pattern Correct DOM Element Captured Attrib 2 Text", "2", slNumbers.at( 2 ).toStdString() );

        testCase( "Pattern Correct DOM Element Captured Attrib 3 Name", "EXCEPT_COUNT", poPattern->captures().at( 2 ).toStdString() );

        testCase( "Pattern Correct DOM Element Captured Attrib 3 Text", "3", slNumbers.at( 3 ).toStdString() );

        delete poPattern;

    } catch( cSevException &e )
    {
        g_obLogger << e;
        m_uiFailedNum++;
    }
}
int main(){
	testCase();
	return 0;
}
示例#18
0
void cActionDefTest::testActionDefList() throw()
{
    printNote( "ACTION DEFINITION LIST TESTS" );

    try
    {
        cActionDefList obActionDefList( "test/test_actions.xml", "data/lara_actions.xsd" );

        unsigned int uiPatternCount = 0;
        for( cActionDefList::tiPatternList itPattern = obActionDefList.patternBegin();
            itPattern != obActionDefList.patternEnd();
            itPattern++ )
        {
            switch( ++uiPatternCount )
            {
                case 1: testCase( "ActionDefList Pattern 1 Name", "PAT_HUNT_NAME", itPattern->name().toStdString() );
                        break;
                case 2: testCase( "ActionDefList Pattern 2 Name", "PAT_HOLY_HAND_GRENADE", itPattern->name().toStdString() );
                        break;
                case 3: testCase( "ActionDefList Pattern 3 Name", "PAT_WASTED_GRENADE", itPattern->name().toStdString() );
                        break;
                case 4: testCase( "ActionDefList Pattern 4 Name", "PAT_TARGET_SPOTTED", itPattern->name().toStdString() );
                        break;
            }
        }

        testCase( "ActionDefList Pattern count", 4, uiPatternCount );

        unsigned int uiSingleLinerCount = 0;
        for( cActionDefList::tiSingleLinerList itSingleLiner = obActionDefList.singleLinerBegin();
            itSingleLiner != obActionDefList.singleLinerEnd();
            itSingleLiner++ )
        {
            switch( ++uiSingleLinerCount )
            {
                case 1: testCase( "ActionDefList SingleLiner 1 Name", "HOLY_HAND_GRENADE", itSingleLiner->name().toStdString() );
                        break;
                case 2: testCase( "ActionDefList SingleLiner 2 Name", "WASTED_GRENADE", itSingleLiner->name().toStdString() );
                        break;
                case 3: testCase( "ActionDefList SingleLiner 3 Name", "NEW_TARGET", itSingleLiner->name().toStdString() );
                        break;
            }
        }

        testCase( "ActionDefList SingleLiner count", 3, uiSingleLinerCount );

        unsigned int uiCountActionCount = 0;
        for( cActionDefList::tiCountActionList itCountAction = obActionDefList.countActionBegin();
            itCountAction != obActionDefList.countActionEnd();
            itCountAction++ )
        {
            switch( ++uiCountActionCount )
            {
                case 1: testCase( "ActionDefList CountAction 1 Name", "nbManeuvers", itCountAction->name().toStdString() );
                        break;
                case 2: testCase( "ActionDefList CountAction 2 Name", "nbGrenades", itCountAction->name().toStdString() );
                        break;
            }
        }

        testCase( "ActionDefList Count Action count", 2, uiCountActionCount );

        testCase( "ActionDefList Timestamp Regexp", "(\\d*)-(\\d*)-(\\d*) (\\d*):(\\d*):(\\d*)\\.(\\d*)", obActionDefList.timeStampRegExp().pattern().toStdString() );

        testCase( "ActionDefList Valid TimestampPart", cTimeStampPart::DAY, obActionDefList.timeStampPart( 2 ) );

        testCase( "ActionDefList Invalid Timestamp Part", cTimeStampPart::MIN, obActionDefList.timeStampPart( 42 ) );

        cActionDefList obBadActionDefList( "test/bad_actions.xml", "data/lara_actions.xsd" );

        testCase( "Bad ActionDefList Timestamp Regexp (XML validation ERROR above is EXPECTED)", "", obBadActionDefList.timeStampRegExp().pattern().toStdString() );

    } catch( cSevException &e )
    {
        g_obLogger << e;
        m_uiFailedNum++;
    }
}
示例#19
0
void cActionDefTest::testSingleLinerDef() throw()
{
    printNote( "SINGLE LINER TESTS" );

    try
    {
        cActionDefSingleLiner *poSingleLiner;

        poSingleLiner = new cActionDefSingleLiner;

        testCase( "SingleLiner empty constructor Name", "", poSingleLiner->name().toStdString() );

        testCase( "SingleLiner empty constructor Upload", cActionUpload::MIN, poSingleLiner->upload() );

        testCase( "SingleLiner empty constructor Pattern", "", poSingleLiner->pattern().toStdString() );

        testCase( "SingleLiner empty constructor Result", cActionResult::MIN, poSingleLiner->result() );

        delete poSingleLiner;

        poSingleLiner = new cActionDefSingleLiner( NULL );

        testCase( "SingleLiner NULL Dom Element Name", "", poSingleLiner->name().toStdString() );

        testCase( "SingleLiner NULL Dom Element Upload", cActionUpload::MIN, poSingleLiner->upload() );

        testCase( "SingleLiner NULL Dom Element Pattern", "", poSingleLiner->pattern().toStdString() );

        testCase( "SingleLiner NULL Dom Element Result", cActionResult::MIN, poSingleLiner->result() );

        delete poSingleLiner;

        QDomDocument obDomDoc( "ActionTest" );
        QDomElement obDomElem = obDomDoc.createElement( "single_liner" );
        obDomElem.setAttribute( "name", "TestSingleLiner" );
        obDomElem.setAttribute( "pattern", "Test Pattern" );
        obDomElem.setAttribute( "result", "OK" );
        obDomElem.setAttribute( "upload", "ALWAYS" );

        poSingleLiner = new cActionDefSingleLiner( &obDomElem );

        testCase( "SingleLiner Correct DOM Element Name", "TestSingleLiner", poSingleLiner->name().toStdString() );

        testCase( "SingleLiner Correct DOM Element Upload", cActionUpload::ALWAYS, poSingleLiner->upload() );

        testCase( "SingleLiner Correct DOM Element Pattern", "Test Pattern", poSingleLiner->pattern().toStdString() );

        testCase( "SingleLiner Correct DOM Element Result", cActionResult::OK, poSingleLiner->result() );

        delete poSingleLiner;

        obDomElem.removeAttribute( "pattern" );
        poSingleLiner = new cActionDefSingleLiner( &obDomElem );

        testCase( "SingleLiner Missing Attribute Name", "TestSingleLiner", poSingleLiner->name().toStdString() );

        testCase( "SingleLiner Missing Attribute Pattern", "", poSingleLiner->pattern().toStdString() );

        delete poSingleLiner;

    } catch( cSevException &e )
    {
        g_obLogger << e;
        m_uiFailedNum++;
    }
}
示例#20
0
void cActionDefTest::testCountActions() throw()
{
    printNote( "COUNT ACTION TESTS" );

    try
    {
        cCountAction *poCountAction;

        poCountAction = new cCountAction;

        testCase( "CountAction empty constructor Name", "", poCountAction->name().toStdString() );

        testCase( "CountAction empty constructor Action Container empty", true, poCountAction->actionsToCountBegin() == poCountAction->actionsToCountEnd() );

        delete poCountAction;

        poCountAction = new cCountAction( NULL );

        testCase( "CountAction NULL DOM Element Name", "", poCountAction->name().toStdString() );

        testCase( "CountAction NULL DOM Element Action Container empty", true, poCountAction->actionsToCountBegin() == poCountAction->actionsToCountEnd() );

        delete poCountAction;

        QDomDocument obDomDoc( "ActionTest" );
        QDomElement obDomElem = obDomDoc.createElement( "count_action" );
        obDomElem.setAttribute( "name", "CountSpam" );
        QDomElement obAction1 = obDomDoc.createElement( "action" );
        obAction1.setAttribute( "name", "SPAM" );
        QDomElement obAction2 = obDomDoc.createElement( "action" );
        obAction2.setAttribute( "name", "SPAM_A_LOT" );
        obAction2.setAttribute( "attrib", "PIECES_OF_SPAM" );
        QDomElement obAction3 = obDomDoc.createElement( "action" );
        obAction3.setAttribute( "name", "SPAM_A_LOT_SPAM" );
        obDomElem.appendChild( obAction1 );
        obDomElem.appendChild( obAction2 );
        obDomElem.appendChild( obAction3 );
        poCountAction = new cCountAction( &obDomElem );

        testCase( "CountAction Correct DOM Element Name", "CountSpam", poCountAction->name().toStdString() );

        unsigned int uiActionCount = 0;
        for( cCountAction::tiActionsToCount itAction = poCountAction->actionsToCountBegin();
            itAction != poCountAction->actionsToCountEnd();
            itAction++ )
        {
            switch( ++uiActionCount )
            {
            case 1: testCase( "CountAction Correct DOM Element Action 1 Name", "SPAM", itAction->qsName.toStdString() ); break;
            case 2: testCase( "CountAction Correct DOM Element Action 2 Name", "SPAM_A_LOT", itAction->qsName.toStdString() );
                    testCase( "CountAction Correct DOM Element Action 2 Attrib", "PIECES_OF_SPAM", itAction->qsAttrib.toStdString() ); break;
            case 3: testCase( "CountAction Correct DOM Element Action 3 Name", "SPAM_A_LOT_SPAM", itAction->qsName.toStdString() ); break;
            }
        }

        testCase( "CountAction Correct DOM Element Action count", 3, uiActionCount );

        delete poCountAction;

    } catch( cSevException &e )
    {
        g_obLogger << e;
        m_uiFailedNum++;
    }
}
示例#21
0
 /** Constructor.
  * The CLASSNAMETestSuite constructor adds all CLASSNAME tests to
  * the test suite. If you write an additional test, add the test
  * case here.
  */
 CLASSNAMETestSuite() :
         vigra::test_suite("CLASSNAME")
 {
     add(testCase(&CLASSNAMETestSuite::fail));
 }
示例#22
0
void PixelFormatTests::testBulkConversion()
{
    // Self match
    testCase(PF_A8R8G8B8, PF_A8R8G8B8);
    // Optimized
	testCase(PF_A8R8G8B8,PF_A8B8G8R8);
	testCase(PF_A8R8G8B8,PF_B8G8R8A8);
	testCase(PF_A8R8G8B8,PF_R8G8B8A8);
	testCase(PF_A8B8G8R8,PF_A8R8G8B8);
	testCase(PF_A8B8G8R8,PF_B8G8R8A8);
	testCase(PF_A8B8G8R8,PF_R8G8B8A8);
	testCase(PF_B8G8R8A8,PF_A8R8G8B8);
	testCase(PF_B8G8R8A8,PF_A8B8G8R8);
	testCase(PF_B8G8R8A8,PF_R8G8B8A8);
	testCase(PF_R8G8B8A8,PF_A8R8G8B8);
	testCase(PF_R8G8B8A8,PF_A8B8G8R8);
	testCase(PF_R8G8B8A8,PF_B8G8R8A8);

    testCase(PF_A8B8G8R8, PF_L8);
    testCase(PF_L8, PF_A8B8G8R8);
    testCase(PF_A8R8G8B8, PF_L8);
    testCase(PF_L8, PF_A8R8G8B8);
    testCase(PF_B8G8R8A8, PF_L8);
    testCase(PF_L8, PF_B8G8R8A8);
    testCase(PF_L8, PF_L16);
    testCase(PF_L16, PF_L8);
    testCase(PF_R8G8B8, PF_B8G8R8);
    testCase(PF_B8G8R8, PF_R8G8B8);
    testCase(PF_B8G8R8, PF_R8G8B8);
    testCase(PF_R8G8B8, PF_B8G8R8);
    testCase(PF_R8G8B8, PF_A8R8G8B8);
    testCase(PF_B8G8R8, PF_A8R8G8B8);
    testCase(PF_R8G8B8, PF_A8B8G8R8);
    testCase(PF_B8G8R8, PF_A8B8G8R8);
    testCase(PF_R8G8B8, PF_B8G8R8A8);
    testCase(PF_B8G8R8, PF_B8G8R8A8);
	testCase(PF_A8R8G8B8, PF_R8G8B8);
	testCase(PF_A8R8G8B8, PF_B8G8R8);
	testCase(PF_X8R8G8B8, PF_A8R8G8B8);
	testCase(PF_X8R8G8B8, PF_A8B8G8R8);
	testCase(PF_X8R8G8B8, PF_B8G8R8A8);
	testCase(PF_X8R8G8B8, PF_R8G8B8A8);
	testCase(PF_X8B8G8R8, PF_A8R8G8B8);
	testCase(PF_X8B8G8R8, PF_A8B8G8R8);
	testCase(PF_X8B8G8R8, PF_B8G8R8A8);
	testCase(PF_X8B8G8R8, PF_R8G8B8A8);

    //CPPUNIT_ASSERT_MESSAGE("Conversion mismatch", false);
}
int main( int argc, char *argv[] )
{
#ifndef NOCATCH
	try
	{
#endif
		// Initialize geometry and input/output buffers
		TestCase testCase( argc, argv );
#ifndef PHYSICS
		int numInput = testCase.xres * testCase.yres;
#else
		int numInput = testCase.getSize();
#endif
		
		const int numOutput = numInput;
		
		const int blockSize = 32;
		
		const char *BINARY_FILE_NAME = "prog.ptx";
		const char *SOURCE_FILE_NAME = "prog.cl";
		
		// Command line handling
		bool isBinary = false;
		
		for ( int i=1; i<argc; ++i )
		{
			const std::string arg( argv[i] );
			if ( arg == "-b" )
				isBinary = true;
			/*else
				throw std::runtime_error( "Invalid option "+arg );*/
		}
		
		// Load or compile program
		std::cerr << (isBinary ? "Loading" : "Compiling") << "...";
		//EDIT: Removing all of his clock functions, can use the VS Porfiler if necessary.
		//const my_clock_t tc0 = my_clock();
		
		CL::SingleFileSingleGPUSetup gpuSetup(
			isBinary ? BINARY_FILE_NAME : SOURCE_FILE_NAME,
			isBinary, COMPILER_FLAGS );
		
		//const my_clock_t tc1 = my_clock();
		std::cout<<"SETUP complete"<<std::endl;

		//std::cerr << "done in " << tdiff(tc0,tc1) << " seconds\n\n";
		
		#ifdef VERBOSE
		std::cerr << " ---- Build log\n" << gpuSetup.getBuildLog() << "\n";
		#endif
		
		// Save "binary" (PTX bytecode) for reuse
		if ( !isBinary )
		{
			std::ofstream f( BINARY_FILE_NAME );
			gpuSetup.writeBinary( f );
		}
		
		//EDIT: Changing code to get rid of kernel getptr
		//1) Define new kernel relocate 
		//2) Use function getPtrs to get the vector ptrs and use it to define size (ptrs.size()) and offset (sizeof(int)) on host.
		//3) Allocate some mem on GPU to store ptrs and use it in the relocate kernel.
		//4) Move the enqueue write here so that the WorldVolumePointer is defined.
		//5) As soon as the kernel is done, free the memory used for ptrs.
		// Import handles to OpenCL kernels (functions)

		CL::Kernel kernelTrace( gpuSetup, "trace" );
		CL::Kernel kernelRelocate( gpuSetup, "relocate" );
		//EDIT: New kernel check
		CL::Kernel kernelCheck ( gpuSetup, "check");

		// Reserve GPU & host buffers
		//EDIT Getting size of ptrs
		int size = testCase.geom->ptrs_size();
		int size_of_logical_checks = 1;
		
		const int auxBufSz = sizeof(cl_mem);
		
		// Page-locked buffers for fast DMA-IO
		CL::PinnedBufferPair gpuInput( gpuSetup, numInput*sizeof(StubParticle), CL_MEM_READ_WRITE, CL_MAP_WRITE );
		CL::PinnedBufferPair gpuOutput( gpuSetup, numOutput*sizeof(G4double), CL_MEM_WRITE_ONLY, CL_MAP_READ );
		CL::PinnedBufferPair gpuAux( gpuSetup, auxBufSz, CL_MEM_READ_WRITE, CL_MAP_READ | CL_MAP_WRITE );
		//EDIT
		CL::PinnedBufferPair ptrs( gpuSetup, size*2*sizeof(int), CL_MEM_READ_WRITE, CL_MAP_WRITE );
		CL::PinnedBufferPair result( gpuSetup,size_of_logical_checks*sizeof(cl_mem), CL_MEM_WRITE_ONLY, CL_MAP_READ );
			
		std::cout<<"Pinned Buffers allocation complete"<<std::endl;
		// GPU only buffers
		//EDIT
		
		CL::Buffer gpuGeom( gpuSetup, CL_MEM_READ_WRITE, testCase.geom->size());
		//EDIT2:
		//gpuSetup.enqueueWriteBuffer( gpuGeom, testCase.geom->getBuffer() );
		
		
		
		std::cout<<"Device Buffers allocation complete"<<std::endl;

		std::memcpy( ptrs.getHostPtr(), &(testCase.geom->ptrs[0]), size*2*sizeof(int) );
		//EDIT 2:
	   //print_stuff(ptrs.getHostPtr(), size);
		ptrs.transferToDevice();
		gpuSetup.finish();

		
		kernelCheck.setArg( 0 , gpuGeom);
		kernelCheck.setArg(	1, result.getDeviceBuffer());
		gpuSetup.enqueueKernel(kernelCheck, 1, 1);
		gpuSetup.finish();
		//EDIT
		result.transferFromDevice();
		gpuSetup.finish();
		int answer = *(int*)(result.getHostPtr());
		std::cout<<"Result before relocate is "<< answer<< std::endl;
	/*EDIT2
		kernelRelocate.setArg( 0, ptrs.getDeviceBuffer());
		kernelRelocate.setArg (1, gpuGeom);
		kernelRelocate.setArg(2, sizeof(int), &size);
    */
		//MODIFY
		//gpuSetup.enqueueKernel(kernelRelocate,size*2,2);
		//gpuSetup.finish();
		//OLD
		// Fetch address of gpuGeom in device memory space (kludge)
		//kernelGetPtr.setArg( 0, gpuGeom );
		//kernelGetPtr.setArg( 1, gpuAux.getDeviceBuffer() );
		//gpuSetup.enqueueTask( kernelGetPtr );
		//gpuAux.transferFromDevice( CL_TRUE, 0, sizeof(cl_mem) );
		//cl_mem gpuhandle = *(cl_mem*)gpuAux.getHostPtr();
		//EDIT2
		cl_mem gpuhandle = *(cl_mem*)result.getHostPtr();
		#ifdef VERBOSE
		std::cerr << "GPU geometry location: " << gpuhandle << "\n\n";
		#endif
		std::cout<< "About to run relocate, no problem so far\n";
		
		//OLD:EDIT2
		testCase.geom->relocate( gpuhandle );

		//EDIT2
		/*kernelCheck.setArg( 0 , gpuGeom);
		kernelCheck.setArg(	1, result.getDeviceBuffer());
		gpuSetup.enqueueKernel(kernelCheck, 1, 1);
		gpuSetup.finish();*/
		//EDIT
		result.transferFromDevice();
		gpuSetup.finish();
		int answer2 = *(int*)(result.getHostPtr());
		//std::cout<<"Result is "<< answer2<< std::endl;
		std::cout<<"size of pointer to void on GPU is "<< answer2<<" and on CPU it is "<<sizeof(void *)<< std::endl;

		// Generate particles (input) ... kind of stupid way to do this
		//EDIT2:

		// MODIFY: He also notes how this is not the optimal way of doing this. Memory can be saved here.
		std::memcpy( gpuInput.getHostPtr(), &(testCase.input[0]), gpuInput.size() );
		//EDIT2
		gpuSetup.enqueueWriteBuffer( gpuGeom, testCase.geom->getBuffer() );
		
		gpuInput.transferToDevice();
		gpuSetup.finish();
		// Set GPU kernel arguments
		kernelTrace.setArg( 0, gpuInput.getDeviceBuffer() );
		kernelTrace.setArg( 1, gpuOutput.getDeviceBuffer() );
		kernelTrace.setArg( 2, gpuGeom );
		kernelTrace.setArg( 3, sizeof(G4double), &(testCase.phys_step) );
		kernelTrace.setArg( 4, sizeof(cl_int), &numInput );
		
		
			std::cout<<"Arguments set"<<std::endl;
		// Write input to GPU memory
		// const my_clock_t t1 = my_clock();
		//OLD
		/*gpuSetup.enqueueWriteBuffer( gpuGeom, testCase.geom->getBuffer() );*/
		
		
		std::cout<< "Write complete, transfer done, finish\n";

		// Actual execution
		//const my_clock_t t2 = my_clock();
		gpuSetup.enqueueKernel( kernelTrace, numInput, blockSize );
		gpuSetup.finish();
		std::cout<<"Kernel trace done\n";
		
		// Transfer results back to host memory
		//const my_clock_t t3 = my_clock();
		gpuOutput.transferFromDevice();
		gpuSetup.finish();
		//const my_clock_t t4 = my_clock();
		
		// Print time summary
		//std::cerr << "Elapsed: " << tdiffms(t1,t4) << " ms"
			//<< "\n  Transfer: " << tdiffms( t1, t2 )+tdiffms(t3,t4)
			//<< "\n\tto GPU:\t" << tdiffms( t1, t2 )
			//<< "\n\tfrom GPU:\t" << tdiffms( t3, t4 )
			//<< "\n  Calculation: " << tdiffms( t2, t3 ) << "\n\n";

		//MODIFY
		// Output results (also a stupid copy)
		std::memcpy( &(testCase.output[0]), gpuOutput.getHostPtr(), gpuOutput.size() );
		testCase.outputData( "imggpu.txt" );

		return EXIT_SUCCESS;
		
#ifndef NOCATCH
	}
	catch ( const std::runtime_error &e )
	{
		std::cerr << e.what() << std::endl;
		return EXIT_FAILURE;
	}
#endif
}
int main() {
    Q_ASSERT(testCase("abc.txt", "*.txt"));
    Q_ASSERT(!testCase("abc.txt", "*.cpp"));

    Q_ASSERT(testCase("Makefile.am", "*Makefile*"));

    Q_ASSERT(testCase("control", "control"));

    Q_ASSERT(testCase("abcd", "a??d"));

    Q_ASSERT(testCase("a", "?"));
    Q_ASSERT(testCase("a", "*?*"));
    Q_ASSERT(testCase("a", "*"));
    Q_ASSERT(testCase("a", "**"));
    Q_ASSERT(testCase("a", "***"));

    Q_ASSERT(testCase("", "*"));
    Q_ASSERT(testCase("", "**"));
    Q_ASSERT(!testCase("", "?"));

    Q_ASSERT(testCase("ab", "a*"));
    Q_ASSERT(testCase("ab", "*b"));
    Q_ASSERT(testCase("ab", "a?"));
    Q_ASSERT(testCase("ab", "?b"));

    Q_ASSERT(testCase("aXXbXXbYYaYc", "a*b*c"));

    
    qDebug() << endl << "DONE";
	return 0;
}
int main() {
  testCase(UINT_MAX, -1);
  testCase(UINT_MAX - 0.03, -2);
  testCase(UINT_MAX - 1, -2);
  testCase(UINT_MAX - 2, -3);
  testCase(UINT_MAX - 5, -6);

  testCase(UINT_MAX - 2.5, -4);
  testCase(UINT_MAX - 2.4, -4);
  testCase(UINT_MAX - 2.6, -4);

  testCase(UINT_MAX / 2, 2147483647);
  testCase(UINT_MAX / 2 + 1, -2147483648);
  testCase(UINT_MAX / 2 - 1.0, 2147483646);
  testCase(UINT_MAX / 2 + 1.999999999, -2147483647);

  testCase(-1, -1);
  testCase(0, 0);
  testCase(1.5, 1);
  testCase(INT_MAX + 1, -2147483648);
  testCase(INT_MAX, 2147483647);
}
示例#26
0
int main( int argc, char *argv[] )
{
#ifndef NOCATCH
	try
	{
#endif
		// Initialize geometry and input/output buffers
		TestCase testCase( argc, argv );
#ifndef PHYSICS
		int numInput = testCase.xres * testCase.yres;
#else
		int numInput = testCase.getSize();
#endif
		
		const int numOutput = numInput;
		
		
		int number_of_increments = 5;
		

		const char *BINARY_FILE_NAME = "prog.ptx";
		const char *SOURCE_FILE_NAME = "prog.cl";
		
		// Command line handling
		bool isBinary = false;
		
		for ( int i=1; i<argc; ++i )
		{
			const std::string arg( argv[i] );
			if ( arg == "-b" )
				isBinary = true;
			/*else
				throw std::runtime_error( "Invalid option "+arg );*/
		}
		
		// Load or compile program
		std::cerr << (isBinary ? "Loading" : "Compiling") << "...";
		//EDIT: Removing all of his clock functions, can use the VS Porfiler if necessary.
		//const my_clock_t tc0 = my_clock();
		
		CL::SingleFileSingleGPUSetup gpuSetup(
			isBinary ? BINARY_FILE_NAME : SOURCE_FILE_NAME,
			isBinary, COMPILER_FLAGS );
		
		//const my_clock_t tc1 = my_clock();
		std::cout<<"SETUP complete"<<std::endl;

		//std::cerr << "done in " << tdiff(tc0,tc1) << " seconds\n\n";
		
		#ifdef VERBOSE
		std::cerr << " ---- Build log\n" << gpuSetup.getBuildLog() << "\n";
		#endif
		
		// Save "binary" (PTX bytecode) for reuse
		if ( !isBinary )
		{
			std::ofstream f( BINARY_FILE_NAME );
			gpuSetup.writeBinary( f );
		}
		
		//EDIT: Changing code to get rid of kernel getptr
		//1) Define new kernel relocate 
		//2) Use function getPtrs to get the vector ptrs and use it to define size (ptrs.size()) and offset (sizeof(int)) on host.
		//3) Allocate some mem on GPU to store ptrs and use it in the relocate kernel.
		//4) Move the enqueue write here so that the WorldVolumePointer is defined.
		//5) As soon as the kernel is done, free the memory used for ptrs.
		// Import handles to OpenCL kernels (functions)


		CL::Kernel kernelTrace( gpuSetup, "trace" );
			// Kernel trace is the main kernel which does the navigation.
		CL::Kernel kernelRelocate( gpuSetup, "relocate" );
			// The kernel version of relocate. It is possible to run relocate without using the kernel straight on the host.
		CL::Kernel kernelTest( gpuSetup, "test");
			// Kernel to check for inconsistencies. 
		
		//EDIT: New kernel check
		CL::Kernel kernelCheck ( gpuSetup, "check");
			
		
		//EDIT2
		CL::Kernel kernelCheckGeometry(gpuSetup, "checkgeom");
			// Kernel to confirm gemoetry relocation happened as it should.	

		// Reserve GPU & host buffers
		//EDIT Getting size of ptrs
		int size = testCase.geom->ptrs_size();
		//REMOVE:
		std::cout<<"Size of ptrs is = "<<size<<std::endl;

		int size_of_logical_checks = 1000;
		
		const int auxBufSz = sizeof(cl_mem);
		
		// Page-locked buffers for fast DMA-IO
		CL::PinnedBufferPair gpuInput( gpuSetup, numInput*sizeof(StubParticle), CL_MEM_READ_WRITE, CL_MAP_WRITE );
		CL::PinnedBufferPair gpuOutput( gpuSetup, numOutput*sizeof(G4double), CL_MEM_WRITE_ONLY, CL_MAP_READ );
		CL::PinnedBufferPair gpuAux( gpuSetup, auxBufSz, CL_MEM_READ_WRITE, CL_MAP_READ | CL_MAP_WRITE );
		//EDIT
		CL::PinnedBufferPair ptrs( gpuSetup, size*2*sizeof(int), CL_MEM_READ_WRITE, CL_MAP_WRITE );
		CL::PinnedBufferPair result( gpuSetup,size_of_logical_checks*sizeof(cl_mem), CL_MEM_WRITE_ONLY, CL_MAP_READ );
			
		#if (GLOBAL_MODE ==1)
		// sizeof( size_t ) ?
		CL::Buffer Numbers_Of_Solid( gpuSetup, CL_MEM_READ_WRITE, numInput*sizeof(int));
		
		CL::Buffer Sum_Of_Solid( gpuSetup, CL_MEM_READ_WRITE, numInput*sizeof(int));
		
		CL::Buffer Solids( gpuSetup, CL_MEM_READ_WRITE, numInput*sizeof(SolidInfo));
		
		CL::Buffer Result_For_Current_Solid( gpuSetup, CL_MEM_READ_WRITE, numInput*sizeof(ResultInfo));
		
		CL::Buffer Compacter_Result( gpuSetup, CL_MEM_READ_WRITE, numInput*sizeof(FinalResult));

        #endif
		CL::Buffer nullVNode( gpuSetup, CL_MEM_READ_WRITE, 2 *sizeof(G4SmartVoxelNode ));
		CL::Buffer noStepArray ( gpuSetup, CL_MEM_READ_WRITE, numInput*sizeof ( bool ));
		CL::Buffer LocationArray( gpuSetup, CL_MEM_READ_WRITE, numInput * sizeof( PointInformation));
		std::cout<<"Pinned Buffers allocation complete"<<std::endl;
		// GPU only buffers
		//EDIT
		
		CL::Buffer gpuGeom( gpuSetup, CL_MEM_READ_WRITE, testCase.geom->size());
		//EDIT2:
		//gpuSetup.enqueueWriteBuffer( gpuGeom, testCase.geom->getBuffer() );
		
		


		std::cout<<"Device Buffers allocation complete"<<std::endl;

		std::memcpy( ptrs.getHostPtr(), &(testCase.geom->ptrs[0]), size*2*sizeof(GEOMTYPE) );
		//EDIT 2:
	   //check_navigation(ptrs.getHostPtr(), size);
		ptrs.transferToDevice();
		gpuSetup.finish();

		//EDIT
		kernelTest.setArg(0, result.getDeviceBuffer());
		if( GLOBAL_MODE  == 1)
		   kernelTest.setArg(1, noStepArray);
		

		gpuSetup.enqueueKernel( kernelTest, 8, 8);
		gpuSetup.finish();
		result.transferFromDevice();
		gpuSetup.finish();
		FinalResult * final;
		
		int * a = ( int *)(ptrs.getHostPtr());
		std::cout<<"Printing input: \n";
		for (int i=0; i<8; i++)
			std::cout<< a[i]  << " ";
		//EDIT : Printing the output array
		std::cout<<"Printing output: \n";
		for (int i=0; i<8; i++)
			std::cout<< (( int *)(result.getHostPtr()))[i] << " ";
		//EDIT: Changed kernel Test to fix Prefix Sum
		//std::cout<< " Values that were returned: ";
		//std::cout<<" For thread 1: ";
		//final = (FinalResult *)result.getHostPtr();
		//final += sizeof( FinalResult);
		//std::cout<<": Min. Step value = "<< final->step<< " and safety returned = "<< final->safety << std::endl;


		// MODIFY: have to loop through this and add as a check

		/*
		for( int i =0 ; i < 4; i++)
		{	
			std::cout<<" For thread "<< i;
			final = (FinalResult **)result.getHostPtr();
			std::cout<<": Min. Step value = "<< final[i]->step<< " and safety returned = "<< final[i]->safety << std::endl;
			
		}
		*/
		/*std::cout<<"\nOriginal values: ";
		for( int i =0 ; i<32; i++)
		{
		std::cout << ((int *)ptrs.getHostPtr())[i]<<" ";
		}
		*/

		//NOTE: kernelCheck is badly named. It was originally the replacement for kernel getPtr and was used to return the geometry start location on the GPU.
		// IT can also be used to check the sizes on CPU and GPu are consistent

		kernelCheck.setArg( 0 , gpuGeom);
		kernelCheck.setArg(	1, result.getDeviceBuffer());
		gpuSetup.enqueueKernel(kernelCheck, 1, 1);
		gpuSetup.finish();
		//EDIT
		result.transferFromDevice();
		gpuSetup.finish();

		std::cout<< "On the CPU, size of GEOMTYPE = " << sizeof( GEOMTYPE )<<"\n";
		//REMOVE:
		std::cout<<"Size of GEOMTYPE on GPU -> "<<*((int  *)result.getHostPtr())<<std::endl;
		//MODIFY:
			// Assert that these are equal here.

		//EDIT2:
		//int answer = *(int*)(result.getHostPtr());
		//std::cout<<"Result before is "<< answer<< std::endl;
		
		std::cout<< "About to run relocate, no problem so far\n";

		//EDIT2
		/*
		gpuSetup.enqueueWriteBuffer( gpuGeom, testCase.geom->getBuffer() );
		gpuSetup.finish();
		kernelRelocate.setArg( 0, ptrs.getDeviceBuffer());
		kernelRelocate.setArg (1, gpuGeom);
		kernelRelocate.setArg(2, sizeof(int), &size);
		


		//MODIFY
		gpuSetup.enqueueKernel(kernelRelocate,size*2,2);
		gpuSetup.finish();
		*/
		//OLD
		// Fetch address of gpuGeom in device memory space (kludge)
		//kernelGetPtr.setArg( 0, gpuGeom );
		//kernelGetPtr.setArg( 1, gpuAux.getDeviceBuffer() );
		//gpuSetup.enqueueTask( kernelGetPtr );
		//gpuAux.transferFromDevice( CL_TRUE, 0, sizeof(cl_mem) );
		//cl_mem gpuhandle = *(cl_mem*)gpuAux.getHostPtr();
		
		//EDIT2
		cl_mem gpuhandle = *(cl_mem*)result.getHostPtr();
	
		
		
		
		//OLD:EDIT2
		testCase.geom->relocate( gpuhandle );

		//EDIT2
		gpuSetup.enqueueWriteBuffer( gpuGeom, testCase.geom->getBuffer() );

		//EDIT2: Kernel which returns the checks
		if(CHECK == 2 || CHECK == 4)
		{
			kernelCheckGeometry.setArg( 0 , gpuGeom);
			kernelCheckGeometry.setArg( 1 , result.getDeviceBuffer());
			kernelCheckGeometry.setArg( 2, sizeof(int), &number_of_increments);
			gpuSetup.enqueueKernel(kernelCheckGeometry, 1, 1);
			gpuSetup.finish();
	
			result.transferFromDevice();
			gpuSetup.finish();

			check_navigation( result.getHostPtr(), testCase.geom->VolumeStore, number_of_increments);
						// print for Geometry test;
		}

		

		// MODIFY: He also notes how this is not the optimal way of doing this. Memory can be saved here.
		std::memcpy( gpuInput.getHostPtr(), &(testCase.input[0]), gpuInput.size() );
		//REMOVE
		std::cout<<"About to run trace\n";
		
		// THis part was written for test purpose to see if error was caused due to shared memory

	
		// This kernel is getting to have WAY too many arguments
		gpuInput.transferToDevice();
		gpuSetup.finish();
		// Set GPU kernel arguments
		kernelTrace.setArg( 0, gpuInput.getDeviceBuffer() );
		kernelTrace.setArg( 1, gpuOutput.getDeviceBuffer() );
		kernelTrace.setArg( 2, gpuGeom );
		kernelTrace.setArg( 3, sizeof(G4double), &(testCase.phys_step) );
		kernelTrace.setArg( 4, sizeof(cl_int), &numInput );	
#ifdef CHECK
		kernelTrace.setArg( 5, result.getDeviceBuffer());
#endif
		// Two uses -: One for debugging and one for checking. Remove at some point.
		if( CHECK == 1 || CHECK == 4)
			kernelTrace.setArg( 5, result.getDeviceBuffer());
#if( GLOBAL_MODE ==1)
		//kernelTrace.setArg( 6, Numbers_Of_Solid );
		//kernelTrace.setArg( 7, Sum_Of_Solid );
		kernelTrace.setArg( 6, Solids );
		kernelTrace.setArg( 7, Result_For_Current_Solid );
		kernelTrace.setArg( 8, Compacter_Result );		
		kernelTrace.setArg( 9, nullVNode);
#endif

/*
NOTE: The current way of setting kernel trace's arguments is bad and is bound to cause problems in future
Change the implementation to either removes one check or perhaps just replace the existing check with something
more useful.
*/
		
		std::cout<<"Arguments set and value of Physical step sent on CPU is = "<< (testCase.phys_step)<<std::endl;
		// Write input to GPU memory
		// const my_clock_t t1 = my_clock();
		//OLD
		/*gpuSetup.enqueueWriteBuffer( gpuGeom, testCase.geom->getBuffer() );*/
		
		
		std::cout<< "Write complete, transfer done, finish\n";
		

		// Actual execution
		//const my_clock_t t2 = my_clock();
		//EDIT
		//gpuSetup.enqueueKernel( kernelTrace, numInput, blockSize );
		gpuSetup.enqueueKernel( kernelTrace, BlockSize, BlockSize );

		
		gpuSetup.finish();
		std::cout<<"Kernel trace done\n";
		

		//EDIT2:
		result.transferFromDevice();
		gpuSetup.finish();
		
		if( CHECK==1 || CHECK==4)
			check_navigation( result.getHostPtr(), testCase.geom->VolumeStore, 0);
					// Run distance check

		// Transfer results back to host memory
		//const my_clock_t t3 = my_clock();
		gpuOutput.transferFromDevice();
		gpuSetup.finish();


		//for (int i=0; i<10; i++)
			//std::cout<< (( int *)(result.getHostPtr()))[i] << " ";
		
			std::cout<< "\n";
		
		for (int i=0; i<32; i++)
			std::cout<< (( G4double *)(result.getHostPtr()))[i] << " ";

		std::cout<<"From CPU -> the first particles position and direction are -" <<" X-: "<<testCase.input[0].pos.x<<" Y-: "<<testCase.input[0].pos.y<<" Z-: "<<testCase.input[0].pos.z;
		std::cout<<" \n and directions are -:  X-: "<<testCase.input[0].dir.x<<" Y-: "<<testCase.input[0].dir.y<<" Z-: "<<testCase.input[0].dir.z;
		//const my_clock_t t4 = my_clock();
		
		// Print time summary
		//std::cerr << "Elapsed: " << tdiffms(t1,t4) << " ms"
			//<< "\n  Transfer: " << tdiffms( t1, t2 )+tdiffms(t3,t4)
			//<< "\n\tto GPU:\t" << tdiffms( t1, t2 )
			//<< "\n\tfrom GPU:\t" << tdiffms( t3, t4 )
			//<< "\n  Calculation: " << tdiffms( t2, t3 ) << "\n\n";

		//MODIFY
		// Output results (also a stupid copy)
		std::memcpy( &(testCase.output[0]), gpuOutput.getHostPtr(), gpuOutput.size() );
		testCase.outputData( "imggpu.txt" );

		return EXIT_SUCCESS;
		
#ifndef NOCATCH
	}
	catch ( const std::runtime_error &e )
	{
		std::cerr << e.what() << std::endl;
		return EXIT_FAILURE;
	}
#endif
}