template <unsigned int dim> void test_skin_iterator(Box<3,size_t> & bx1, Box<3,size_t> & bx2, grid_sm<3,void> & g_sm,size_t (& bc)[dim] , size_t vol_test)
{
	grid_cpu<3,aggregate<size_t>> gtest(g_sm.getSize());
	gtest.setMemory();
	auto it = gtest.getSubIterator(0);

	while (it.isNext())
	{
		auto key = it.get();

		gtest.get<0>(key) = 0;

		++it;
	}

	size_t count = 0;
	grid_skin_iterator_bc<3> gsi(g_sm,bx1,bx2,bc);

	while (gsi.isNext() == true)
	{
		auto key = gsi.get();

		gtest.get<0>(key) += 1;

		count++;

		++gsi;
	}

	BOOST_REQUIRE_EQUAL(count,(size_t)vol_test);

	bool ret = true;
	auto it2 = gtest.getSubIterator(0);

	while (it2.isNext())
	{
		auto key = it2.get();

		ret &= gtest.get<0>(key) <= 1;

		++it2;
	}

	BOOST_REQUIRE_EQUAL(ret,true);
}
void CTestEngine::ConstructL()
	{
	OstTraceFunctionEntry1( CTESTENGINE_CONSTRUCTL_ENTRY, this );
	CActiveScheduler::Add(this);

	// Display information (construction text and OS build version number
	gtest.Title();
	gtest.Start(_L("Test Engine Initiation"));
	gtest.Printf(_L(">>\n"));
	OstTrace0(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL, ">>\n");
	gtest.Printf(_L(">>   T E S T   R U N \n"));
	OstTrace0(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP01, ">>   T E S T   R U N \n");
	gtest.Printf(_L(">>\n"));
	OstTrace0(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP02, ">>\n");

	// Process the command line option for role
	TInt cmdLineLength(User::CommandLineLength());
	HBufC* cmdLine = HBufC::NewMax(cmdLineLength);
	CleanupStack::PushL(cmdLine);
	TPtr cmdLinePtr = cmdLine->Des();
	User::CommandLine(cmdLinePtr);
	
	// be careful, command line length is limited(248 characters)	
	gtest.Printf(_L("***cmdLine = %lS\n"), cmdLine);
	OstTraceExt1(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP03, "***cmdLine = %lS\n", *cmdLine);
		
	TLex args(*cmdLine);
	args.SkipSpace();
	
	// Obtain the role of this test module
	TPtrC roleToken = args.NextToken(); // e.g. -role=host
	TBool hostFlag(ETrue);
	
	TInt pos(roleToken.FindF(KArgRole));
	if(pos != KErrNotFound)
		{
		pos = roleToken.FindF(_L("="));
		TPtrC role = roleToken.Right(roleToken.Length()-pos-1);
		if(role.Compare(KArgRoleHost) == 0)
			{
			hostFlag = ETrue;
			}
		else if(role.Compare(KArgRoleClient) == 0)
			{
			hostFlag = EFalse;
			}
		else
			{
			gtest.Printf(_L("Test configuration: could not find option -role\n"));
			OstTrace0(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP04, "Test configuration: could not find option -role\n");
			gtest(EFalse);
			}
		}
	else
		{
		gtest.Printf(_L("Test configuration option not found: %S\n"),&KArgRole);
		OstTraceExt1(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP05, "Test configuration option not found: %S\n",KArgRole);
		gtest(EFalse);
		}
		
	// Obtain the test cases to be run
	TPtrC casesToken = args.NextToken();
	
	pos = casesToken.FindF(KArgTestCases);
	if(pos != KErrNotFound)
		{
		pos = casesToken.FindF(_L("="));
		TPtrC testCases = casesToken.Right(casesToken.Length()-pos-1);
	
		// Remaining test cases
		TPtrC remCases(testCases);
		while(pos != KErrNotFound)
			{
			pos = remCases.FindF(_L(","));
			HBufC* tc = HBufC::NewLC(KTestCaseIdLength);
			TPtr tcPtr = tc->Des();
			tcPtr.Append(KTestStringPreamble);	
			
			if(pos == KErrNotFound)
				{
				// This is the last test case identity			
				tcPtr.Append(remCases);
				}
			else
				{ 			
				tcPtr.Append(remCases.Left(KTestIdSize));
				}									
							
			gtest.Printf(_L("Test case specified: %S\n"),tc);
			OstTraceExt1(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP06, "Test case specified: %S\n",*tc);
			
						
			iTestCasesIdentities.Append(tc);
			CleanupStack::Pop(tc);
			remCases.Set(testCases.Right(remCases.Length()-pos-1));
			}
		}
	else
		{
		gtest.Printf(_L("Test configuration option not found: %S\n"),&KArgTestCases);
		OstTraceExt1(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP07, "Test configuration option not found: %S\n",KArgTestCases());
		gtest(EFalse);		
		}
				
	// Obtain the role of this test module
	TPtrC repeatsToken = args.NextToken(); // e.g. -repeats=4
	
	pos = repeatsToken.FindF(KArgTestRepeats);
	if(pos != KErrNotFound)
		{
		pos = repeatsToken.FindF(_L("="));
		TPtrC repeats = repeatsToken.Right(repeatsToken.Length()-pos-1);
		TLex lex(repeats);
		TInt ret = lex.Val(iNumRepeats, EDecimal);
		if(ret)
			{
			gtest.Printf(_L("Test configuration option not found: %S\n"),&KArgTestRepeats);
			OstTraceExt1(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP08, "Test configuration option not found: %S\n",KArgTestRepeats());
			gtest.Printf(_L("DEFAULT to number of repeats = %d\n"),KDefaultNumRepeats);
			OstTrace1(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP09, "DEFAULT to number of repeats = %d\n",KDefaultNumRepeats);
			iNumRepeats = KDefaultNumRepeats;
			}
		gtest.Printf(_L("Test repeats specified: %d cycles\n"),iNumRepeats);
		OstTrace1(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP10, "Test repeats specified: %d cycles\n",iNumRepeats);
		}
	else
		{
		gtest.Printf(_L("Test configuration option not found: %S\n"),&KArgTestRepeats);
		OstTraceExt1(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP11, "Test configuration option not found: %S\n",KArgTestRepeats());
		gtest.Printf(_L("DEFAULT to number of repeats = %d\n"),KDefaultNumRepeats);
		OstTrace1(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP12, "DEFAULT to number of repeats = %d\n",KDefaultNumRepeats);
		iNumRepeats = KDefaultNumRepeats;
		}
		
	// Create the test case controller
	gtest.Printf(_L("Creating the test controller\n"));
	OstTrace0(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP13, "Creating the test controller\n");
	iTestCaseController = CTestCaseController::NewL(*this,hostFlag);

	CleanupStack::PopAndDestroy(cmdLine);

	gtest.Console()->Read(iStatus);
	SetActive();	
	OstTraceFunctionExit1( CTESTENGINE_CONSTRUCTL_EXIT, this );
	}