void ByteCodeVerifier::Verify(char const * codeText)
    {
        Allocator allocator(c_allocatorBufferSize);
        ByteCodeGenerator code;

        std::stringstream input(codeText);

        TextObjectParser parser(input, allocator, &CompileNode::GetType);
        CompileNode const & node = CompileNode::Parse(parser);

        node.Compile(code);
        code.Seal();

        QueryInstrumentation instrumentation;

        ResultsBuffer results(m_index.GetIngestor().GetDocumentCount());
        ByteCodeInterpreter interpreter(
            code,
            results,
            m_slices.size(),
            m_slices.data(),
            GetIterationsPerSlice(),
            m_initialRank,
            m_rowOffsets.data(),
            nullptr,
            instrumentation,
            0);

        interpreter.Run();

        CheckResults(results);
    }
void CTestRTFTablePostProcessor::CompareAndCheckResults(CStdString szFile1, CStdString szFile2, int iAnchor, int iTablesExpected)
{
	CRtfDocumentChainBuilder builder;

	builder.m_Options.SetTemplate( GET_TEST_FILE_PATH("template.rtf"));
	builder.PrepareRTFFileMembers();
	builder.ProcessOptions();
	builder.EnableHashCodes ();
	HRESULT hr = builder.AssembleRTFFileCollections(AutoInputFileData4Tests( szFile1), AutoInputFileData4Tests( szFile2));
	if(FAILED(hr))
		throw CppUnitException(_T("failed to read one of the input files"));

	hr = builder.BuildChains();
	if(FAILED(hr))
		throw CppUnitException(_T("failed to read one of the input files"));

	builder.PrepareForCompareChains();
	builder.CompareChains(builder.m_pAnchor[0], builder.m_pAnchor[1]);
	builder.FlagActualComparisonComplete();
	builder.Finalise();

	CChainElement* pIter = builder.m_pAnchor[iAnchor];

	bool bFoundJoin = false;
	int iTablesFound = CheckResults(builder, pIter, bFoundJoin);
	assertMessage( iTablesExpected == iTablesFound, _T("Did not find tables it should have"));
	assertMessage(bFoundJoin, _T("should have found a joined table"));
}
void VerifyDiagnosticConsumer::CheckDiagnostics() {
  // Ensure any diagnostics go to the primary client.
  bool OwnsCurClient = Diags.ownsClient();
  DiagnosticClient *CurClient = Diags.takeClient();
  Diags.setClient(PrimaryClient, false);

  if (SrcManager) {
    // Produce an error if no expected-* directives could be found in the
    // source file(s) processed.
    if (Status == HasNoDirectives) {
      Diags.Report(diag::err_verify_no_directives).setForceEmit();
      ++NumErrors;
      Status = HasNoDirectivesReported;
    }

    // Check that the expected diagnostics occurred.
    NumErrors += CheckResults(Diags, *SrcManager, *Buffer, ED);
  } else {
    NumErrors += (PrintUnexpected(Diags, 0, Buffer->err_begin(),
                                  Buffer->err_end(), DiagnosticsEngine::Error) +
                  PrintUnexpected(Diags, 0, Buffer->warn_begin(),
                                  Buffer->warn_end(), DiagnosticsEngine::Warning) +
                  PrintUnexpected(Diags, 0, Buffer->note_begin(),
                                  Buffer->note_end(), DiagnosticsEngine::Note));
  }

  Diags.takeClient();
  Diags.setClient(CurClient, OwnsCurClient);

  // Reset the buffer, we have processed all the diagnostics in it.
  Buffer.reset(new TextDiagnosticBuffer());
  ED.Errors.clear();
  ED.Warnings.clear();
  ED.Notes.clear();
}
Beispiel #4
0
void GnSQLiteTable::SetRow(int nRow)
{
	CheckResults();
	
	if (nRow < 0 || nRow > mnRows-1)
	{
		return;
	}
	
	mnCurrentRow = nRow;
}
Beispiel #5
0
const char* GnSQLiteTable::FieldName(int nCol)
{
	CheckResults();
	
	if ( nCol < 0 || nCol > mnCols-1 )
	{
		return NULL;
	}
	
	return mpaszResults[nCol];
}
Beispiel #6
0
const char* GnSQLiteTable::FieldValue(int nField)
{
	CheckResults();
	
	if (nField < 0 || nField > mnCols-1)
	{
		return NULL;
	}
	
	int nIndex = ( mnCurrentRow * mnCols ) + mnCols + nField;
	return mpaszResults[nIndex];
}
int main(int argc, char* argv[])
{	
  double before, after;

  int M = atoi(argv[1]);
  int N = atoi(argv[2]);
  int P = atoi(argv[3]);

  int **A = Allocate2DArray< int >(M, P);
  int **B = Allocate2DArray< int >(P, N);
  int **C = Allocate2DArray< int >(M, N);
  int **C4 = Allocate2DArray< int >(M, N);

  int i, j;

  for (i = 0; i < M; i++) {
	for (j = 0; j < P; j++) {   
		A[i][j] = ((int)(rand()%100) /10);  
	 } 
  } 

  for (i = 0; i < P; i++) {	
	 for (j = 0; j < N; j++) {
	B[i][j] = ((int)(rand()%100) / 10.0);   
	 } 
  } 

  printf("Execute Standard matmult\n\n");
  before = omp_get_wtime();
  seqMatMult(M, N, P, A, B, C);
  after = omp_get_wtime();
  printf("Standard matrix function done in %10f secs\n\n\n",(after - before));
  
  //printf("The number of cores is %d\n",omp_get_num_procs());
  omp_set_num_threads(8);
  GRAIN = (long)(M*N*2);
  before = omp_get_wtime();
  matmultS(M, N, P, A, B, C4);
  after = omp_get_wtime();
  printf("Strassen matrix function done in %10f secs\n\n\n",(after - before));

  if (CheckResults(M, N, C, C4)) 
	 printf("Error in matmultS\n\n");
  else
	 printf("OKAY\n\n");

  Free2DArray(A);
  Free2DArray(B);
  Free2DArray(C);
  Free2DArray(C4);

  return 0;
}
    void RunTests(ib_strop_t op, const TestDatum *test_data)
    {
        const TestDatum *test;
        ib_status_t rc;

        SetOp(op);
        for (test = test_data; ! test->IsEnd();  ++test) {
            ib_flags_t result;
            rc = RunTest(*test, result);
            CheckResults(*test, rc, result);
        }
    }
int CTestRTFTablePostProcessor::CheckResults(CRtfDocumentChainBuilder& builder, CChainElement* pIter, bool &bFoundJoin)
{
	int iTableCount = 0;
	while (pIter)
	{
		RtfObjectTypes rotType = (RtfObjectTypes)pIter->GetType();
		if (rotType == ROT_Table)
		{
			iTableCount++;
			CRTF_Table* pTable = (CRTF_Table *)pIter;
			if (pTable->m_TableSplittingWhitespace[0] != NULL)
			{
				bFoundJoin = true;
				OutputFileData outputFile;
				outputFile.SetWriteToBuffer(true);
				RtfWriterData rwd(pIter->GetFileContext(), outputFile, NULL, true, &builder);
				RtfWriterInfo info(pIter->GetFileContext(), false, false);
				RTFObjectCollection* pColl = new RTFObjectCollection(rotFieldInst,(pIter->GetFileContext()));
				rwd.m_pRoot = pColl;

				pTable->WriteRtf(rwd, info);
				assertMessage(rwd.GetCollectionSize() > 0, _T("Should have written something"));
				// pColl->GetCount() > 0
				assertMessage(pColl->At(0)->GetType() == rotTable, _T("Should be a table here"));
				const RTFTable* pTable2 = (const RTFTable *)pColl->At(0);
				assertMessage(pTable2->m_pTableSplittingWhitespace.size() > 0, _T("Should have some objects"));
				assertMessage(pTable2->m_pTableSplittingWhitespace[0] != NULL, _T("Should have transferred the whitespace paraPluses"));

				rwd.m_bIgnoreWrittenCountsSoTestsCanCleanUpProperly = true;
				rwd.DisassembleWriterData(pColl);
				for (int i=0; i<pColl->GetCount(); i++)
					pColl->DetachObject(i);
				delete pColl;

			}
			else if ( pTable->GetCellCount() == 1)
			{
				CRTF_Cell* pCell = pTable->Cell(0);
			
				CChainElement* pInnerIter = pCell->GetContent();
				iTableCount += CheckResults(builder, pInnerIter, bFoundJoin);
			}
		}
		pIter=pIter->GetNext();
	}

	return iTableCount;
}
void CTestBroadcastMessaging::CTestGetCbmiList::RunL()
    {
    TInt ret=iStatus.Int();
	TInt count=iTestBroadcastMessaging->iTestCount;
	
	if (!ret)
		ret=CheckResults();

	if(ret!=KErrNone)
		{
		if(!(((count)>=KOOMTestNumberStart)&&(ret==KErrNoMemory)))
			iTestBroadcastMessaging->INFO_PRINTF3(_L("Test %d - TTestBroadcastMessaging::CTestGetCbmiList failed with error %d"), count++, ret);	
		}

    CActiveScheduler::Stop();
	}
void
HwmpReactiveRegressionTest::DoRun ()
{
  RngSeedManager::SetSeed (12345);
  RngSeedManager::SetRun (7);
  CreateNodes ();
  CreateDevices ();
  InstallApplications ();

  Simulator::Stop (m_time);
  Simulator::Run ();
  Simulator::Destroy ();

  CheckResults ();
  delete m_nodes, m_nodes = 0;
}
Beispiel #12
0
const char* GnSQLiteTable::FieldValue(const char* szField)
{
	CheckResults();
	
	if (szField)
	{
		for (int nField = 0; nField < mnCols; nField++)
		{
			if (strcmp(szField, mpaszResults[nField]) == 0)
			{
				int nIndex = ( mnCurrentRow * mnCols ) + mnCols + nField;
				return mpaszResults[nIndex];
			}
		}
	}
	
	return NULL;
}
void CWatcherActiveStep::RunL()
	{
	if (iTestState==EStateFinish)
		{
		Deque();
		CActiveScheduler::Stop();
		return;
		}

	if (iMediaChange)
		{
		iMediaChange=EFalse;
		CheckResults();
		}
	else
		{
		RunTestsL();
		}
	}
    void Simulate(const std::string& rOutputDirName,
                  const std::string& rModelName,
                  boost::shared_ptr<AbstractCardiacCellInterface> pCell)
    {
        double end_time = GetAttribute(pCell, "SuggestedCycleLength", 700.0); // ms
        if (pCell->GetSolver() || dynamic_cast<AbstractRushLarsenCardiacCell*>(pCell.get()))
        {
            double dt = GetAttribute(pCell, "SuggestedForwardEulerTimestep", 0.0);
            if (dt > 0.0)
            {
                pCell->SetTimestep(dt);
            }
        }
#ifdef CHASTE_CVODE
        AbstractCvodeSystem* p_cvode_cell = dynamic_cast<AbstractCvodeSystem*>(pCell.get());
        if (p_cvode_cell)
        {
            // Set a larger max internal time steps per sampling interval (CVODE's default is 500)
            p_cvode_cell->SetMaxSteps(1000);
            // Numerical or analytic J for CVODE?
            if (!mUseCvodeJacobian)
            {
                p_cvode_cell->ForceUseOfNumericalJacobian();
            }
        }
#endif
        double sampling_interval = 1.0; // ms; used as max dt for CVODE too
        Timer::Reset();
        OdeSolution solution = pCell->Compute(0.0, end_time, sampling_interval);
        std::stringstream message;
        message << "Model " << rModelName << " writing to " << rOutputDirName << " took";
        Timer::Print(message.str());

        const unsigned output_freq = 10; // Only output every N samples
        solution.WriteToFile(rOutputDirName, rModelName, "ms", output_freq, false);
        // Check an AP was produced
        std::vector<double> voltages = solution.GetVariableAtIndex(pCell->GetVoltageIndex());
        CellProperties props(voltages, solution.rGetTimes());
        props.GetLastActionPotentialDuration(90.0); // Don't catch the exception here if it's thrown
        // Compare against saved results
        CheckResults(rModelName, voltages, solution.rGetTimes(), output_freq);
    }
Beispiel #15
0
int GnSQLiteTable::NumRows()
{
	CheckResults();
	return mnRows;
}
int main(int argc, char* argv[])   
{      
	int i, j; 
	double start, time1, time2;

   int M = MM;
   int N = NN;
   int P = PP;
 
   if (argc != 4) {
      printf("Suggested Usage: %s <M> <N> <P> \n", argv[0]);
      printf("Using default values\n");
   }
   else {
      M = atoi(argv[1]);
      N = atoi(argv[2]);
      P = atoi(argv[3]);
   }

	double  **A = Allocate2DArray< double >(M, P);
	double  **B = Allocate2DArray< double >(P, N);

	double **C1 = Allocate2DArray< double >(M, N);
	double **C4 = Allocate2DArray< double >(M, N);

	for (i = 0; i < M; i++) {   
		for (j = 0; j < P; j++) {   
			A[i][j] = (double)(rand()%100) / 10.0;   
		}      
	}   

	for (i = 0; i < P; i++) {   
		for (j = 0; j < N; j++) {   
			B[i][j] = (double)(rand()%100) / 10.0;   
		}      
	}   

   printf("Matrix Dimensions: M = %d  P = %d  N = %d\n\n", M, P, N);
	printf("Execute matmult1\n");
	start = omp_get_wtime();
	matmult1(M, N, P, A, B, C1);
	time1 = omp_get_wtime() - start;
	printf("Time = %f seconds\n\n",time1);

	printf("Execute matmultr\n");
	start = omp_get_wtime();
	matmultr(M, N, P, A, B, C4);
	time2 = omp_get_wtime() - start;
	printf("Time = %f seconds\n\n",time2);

   printf("Checking...");
   if (CheckResults(M, N, C1, C4))
     printf("Error in Recursive Matrix Multiplication\n\n");
   else {
     printf("OKAY\n\n");
     printf("Speedup = %5.1fX\n", time1/time2);
   }


	Free2DArray< double >(A);
	Free2DArray< double >(B);
	Free2DArray< double >(C1);
	Free2DArray< double >(C4);

	return 0;   
}  
int main(int argc, char* argv[])   
{      
  double before, time1, time2;
  int M = MM;
  int N = NN;
  int P = PP;
 
  if (argc != 4) {
          printf("Suggested Usage: %s <M> <N> <P> \n", argv[0]);
     printf("Using default values\n");
  }
  else {
     M = atoi(argv[1]);
     N = atoi(argv[2]);
     P = atoi(argv[3]);
  }

  double **A = Allocate2DArray< double >(M, P);
  double **B = Allocate2DArray< double >(P, N);
  double **C = Allocate2DArray< double >(M, N);
  double **C4 = Allocate2DArray< double >(M, N);

  int i, j;   

  for (i = 0; i < M; ++i) {   
    for (j = 0; j < P; ++j) {   
      A[i][j] = 5.0 - ((double)(rand()%100) / 10.0);  
    }      
  }   

  for (i = 0; i < P; ++i) {   
    for (j = 0; j < N; ++j) {   
      B[i][j] = 5.0 - ((double)(rand()%100) / 10.0);   
    }      
  }   

  for (i = 0; i < M; ++i) {   
    for (j = 0; j < N; ++j) {   
      C[i][j] = 0.0;
      C4[i][j] = 0.0;
    }      
  }   

  printf("Execute Standard matmult  M = %d  N = %d  P = %d\n\n", M, N, P);
  before = omp_get_wtime();
  seqMatMult(M, N, P, A, B, C);
  time1 = omp_get_wtime() - before;
  printf("Standard matrix function done in %7.2f secs\n\n\n",(float)time1);

  before = omp_get_wtime();
  matmultS(M, N, P, A, B, C4);
  time2 = omp_get_wtime() - before;
  printf("Strassen matrix function done in %7.2f secs\n\n\n",time2);

   printf("Checking...");
   if (CheckResults(M, N, C, C4))
     printf("Error in Strassen Matrix Multiplication\n\n");
   else {
     printf("OKAY\n\n");
     printf("Speedup = %5.1fX\n", time1/time2);
   }

  Free2DArray< double >(A);
  Free2DArray< double >(B);
  Free2DArray< double >(C);
  Free2DArray< double >(C4);

  return 0;   
}  
Beispiel #18
0
bool GnSQLiteTable::FieldIsNull(int nField)
{
	CheckResults();
	return ( FieldValue(nField) == 0 );
}
Beispiel #19
0
bool GnSQLiteTable::FieldIsNull(const char* szField)
{
	CheckResults();
	return ( FieldValue(szField) == 0 );
}
Beispiel #20
0
int GnSQLiteTable::NumFields()
{
	CheckResults();
	return mnCols;
}