本文整理汇总了C++中CPPUNIT_FAIL函数的典型用法代码示例。如果您正苦于以下问题:C++ CPPUNIT_FAIL函数的具体用法?C++ CPPUNIT_FAIL怎么用?C++ CPPUNIT_FAIL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CPPUNIT_FAIL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testReadFile
void testReadFile()
{
//Read STL-Image from file
mitk::STLFileReader::Pointer reader = mitk::STLFileReader::New();
if (!reader->CanReadFile(m_SurfacePath, "", "")) {CPPUNIT_FAIL("Cannot read test data STL file.");}
reader->SetFileName(m_SurfacePath);
reader->Update();
mitk::Surface::Pointer surface = reader->GetOutput();
//check some basic stuff
CPPUNIT_ASSERT_MESSAGE("Reader output not NULL",surface.IsNotNull());
CPPUNIT_ASSERT_MESSAGE("IsInitialized()",surface->IsInitialized());
CPPUNIT_ASSERT_MESSAGE("mitk::Surface::SetVtkPolyData()",(surface->GetVtkPolyData()!=NULL));
CPPUNIT_ASSERT_MESSAGE("Availability of geometry",(surface->GetGeometry()!=NULL));
//use vtk stl reader for reference
vtkSmartPointer<vtkSTLReader> myVtkSTLReader = vtkSmartPointer<vtkSTLReader>::New();
myVtkSTLReader->SetFileName( m_SurfacePath.c_str() );
myVtkSTLReader->Update();
vtkSmartPointer<vtkPolyData> myVtkPolyData = myVtkSTLReader->GetOutput();
//vtkPolyData from vtkSTLReader directly
int n = myVtkPolyData->GetNumberOfPoints();
//vtkPolyData from mitkSTLFileReader
int m = surface->GetVtkPolyData()->GetNumberOfPoints();
CPPUNIT_ASSERT_MESSAGE("Number of Points in VtkPolyData",(n == m));
}
示例2: catch
void DefaultNetworkPublishingComponentTests::setUp()
{
try
{
dtCore::SetDataFilePathList(dtCore::GetDeltaDataPathList());
mLogger = &dtUtil::Log::GetInstance("defaultnetworkpublishingcomponenttests.cpp");
mGameManager = new dtGame::GameManager(*GetGlobalApplication().GetScene());
mGameManager->SetApplication(GetGlobalApplication());
mNetPubComp = new DefaultNetworkPublishingComponent;
mDefMsgProc = new DefaultMessageProcessor;
mTestComp = new TestComponent;
mGameManager->AddComponent(*mDefMsgProc, GameManager::ComponentPriority::HIGHEST);
mGameManager->AddComponent(*mNetPubComp, GameManager::ComponentPriority::NORMAL);
mGameManager->AddComponent(*mTestComp, GameManager::ComponentPriority::NORMAL);
mGameManager->CreateActor(*dtActors::EngineActorRegistry::GAME_MESH_ACTOR_TYPE, mGameActorProxy);
dtCore::System::GetInstance().SetShutdownOnWindowClose(false);
dtCore::System::GetInstance().Start();
mTestComp->reset();
//Publish the actor.
mGameManager->AddActor(*mGameActorProxy, false, false);
dtCore::System::GetInstance().Step();
}
catch (const dtUtil::Exception& ex)
{
CPPUNIT_FAIL((std::string("Error: ") + ex.ToString()).c_str());
}
}
示例3: testWriteAll
void testWriteAll()
{
uint16_t addr;
getReady();
// Enable write
writeOpAddr(EWEN_OPCODE, EWEN_OPCODE_BITS, 0, EWEN_ADDR_BITS);
standby();
// Fill all memory
writeOpAddr(WRAL_OPCODE, WRAL_OPCODE_BITS, 0, WRAL_ADDR_BITS);
writeData(0xABBA);
standby();
if (waitForCompletion()) {
stop();
getReady();
// Write successful -- verify all memory
for ( addr=0; addr < EEPROM93C46::SIZE; addr++ ) {
CPPUNIT_ASSERT_EQUAL((uint16_t)0xABBA, readAt(addr));
}
}
else {
CPPUNIT_FAIL("EEPROM write was not completed");
}
stop();
}
示例4: GenerateData_3DImage_CompareToReference
void GenerateData_3DImage_CompareToReference()
{
int upperThr = 255;
int lowerThr = 60;
int outsideVal = 0;
int insideVal = 100;
us::ServiceReference<OclResourceService> ref = GetModuleContext()->GetServiceReference<OclResourceService>();
OclResourceService* resources = GetModuleContext()->GetService<OclResourceService>(ref);
resources->GetContext(); //todo why do i need to call this before GetMaximumImageSize()?
if(resources->GetMaximumImageSize(2, CL_MEM_OBJECT_IMAGE3D) == 0)
{
//GPU device does not support 3D images. Skip this test.
MITK_INFO << "Skipping test.";
return;
}
try{
m_oclBinaryFilter->SetInput( m_Random3DImage );
m_oclBinaryFilter->SetUpperThreshold( upperThr );
m_oclBinaryFilter->SetLowerThreshold( lowerThr );
m_oclBinaryFilter->SetOutsideValue( outsideVal );
m_oclBinaryFilter->SetInsideValue( insideVal );
m_oclBinaryFilter->Update();
mitk::Image::Pointer outputImage = mitk::Image::New();
outputImage = m_oclBinaryFilter->GetOutput();
// reference computation
//This is not optimal here, but since we use a random image
//we cannot know the reference image at this point.
typedef itk::Image< unsigned char, 3> ImageType;
typedef itk::BinaryThresholdImageFilter< ImageType, ImageType > ThresholdFilterType;
ImageType::Pointer itkInputImage = ImageType::New();
CastToItkImage( m_Random3DImage, itkInputImage );
ThresholdFilterType::Pointer refThrFilter = ThresholdFilterType::New();
refThrFilter->SetInput( itkInputImage );
refThrFilter->SetLowerThreshold( lowerThr );
refThrFilter->SetUpperThreshold( upperThr );
refThrFilter->SetOutsideValue( outsideVal );
refThrFilter->SetInsideValue( insideVal );
refThrFilter->Update();
mitk::Image::Pointer referenceImage = mitk::Image::New();
mitk::CastToMitkImage(refThrFilter->GetOutput(), referenceImage);
MITK_ASSERT_EQUAL( referenceImage, outputImage,
"OclBinaryThresholdFilter should be equal to regular itkBinaryThresholdImageFilter.");
}
catch(mitk::Exception &e)
{
std::string errorMessage = "Caught unexpected exception ";
errorMessage.append(e.what());
CPPUNIT_FAIL(errorMessage.c_str());
}
}
示例5: CPPUNIT_ASSERT_MESSAGE
void ConnectTests::connect ()
{
rdbi_context_def *rdbi_context;
int id;
try
{
CPPUNIT_ASSERT_MESSAGE ("rdbi_initialize failed", RDBI_SUCCESS == do_rdbi_init (&rdbi_context));
try
{
CPPUNIT_ASSERT_MESSAGE ("rdbi_connect failed", RDBI_SUCCESS == do_rdbi_connect (rdbi_context, id));
CPPUNIT_ASSERT_MESSAGE ("rdbi_disconnect failed", RDBI_SUCCESS == rdbi_disconnect (rdbi_context));
}
catch (CppUnit::Exception exception)
{
rdbi_term (&rdbi_context);
throw exception;
}
CPPUNIT_ASSERT_MESSAGE ("rdbi_term failed", RDBI_SUCCESS == rdbi_term (&rdbi_context));
}
catch (CppUnit::Exception exception)
{
throw exception;
}
catch (...)
{
CPPUNIT_FAIL ("unexpected exception encountered");
}
}
示例6: CPPUNIT_FAIL
void HTMLChatViewTest::checkResultBody(QString validOutput) {
QString out = view->dumpContent();
delete view;
delete form;
int a = out.indexOf("<body>"),
b = out.lastIndexOf("</body>");
if (a < 0 || b < 0) {
CPPUNIT_FAIL("no <body> element");
}
out.chop(out.size() - b);
out = out.right(out.size() - a - 6).replace('\n', "");
validOutput.replace('\n', "");
for (int i = 0; i < validOutput.size(); ++i) {
if (validOutput[i] != out[i]) {
qDebug() << i << out.left(i);
break;
}
}
CPPUNIT_ASSERT_EQUAL(validOutput.toStdString(), out.toStdString());
}
示例7: SpectrumDataSetStokes
void FilterBankAdapterTest::test_readFile()
{
try {
{ // Use Case:
// read in a file with a header
// requesty to read a single block
// Expect:
// header and block to be read in and DataBlob filled
// TestConfig config("StreamDataSet.xml", "lib");
// create the DataBlob
SpectrumDataSetStokes* blob = new SpectrumDataSetStokes();
QString xml = "";
pelican::test::AdapterTester tester("FilterBankAdapter", xml);
tester.setDataFile(pelican::test::TestConfig::findTestFile("testData.dat","lib"));
tester.execute(blob);
CPPUNIT_ASSERT_EQUAL( (unsigned int)1 , blob->nPolarisations() );
CPPUNIT_ASSERT_EQUAL( (unsigned int)496 , blob->nChannels() );
delete blob;
}
}
catch( QString& e ) {
CPPUNIT_FAIL( e.toStdString() );
}
}
示例8: storeNode
void EdgeIterationTest::testGetOutEdges()
{
_engine->evaluate(QString::fromStdString("var it = g.getOutEdges(n1); storeNode(n1);"));
if(_engine->hasUncaughtException())
CPPUNIT_FAIL(qPrintable(_engine->uncaughtException().toString()));
tlp::Graph *testGraph = _graph->asGraph();
tlp::Iterator<tlp::edge> *it = testGraph->getOutEdges(_testNode->asNode());
int itCount = 0;
while (it->hasNext()) {
_engine->evaluate(QString::fromStdString("storeEdge(it.next());"));
if(_engine->hasUncaughtException())
CPPUNIT_FAIL(qPrintable(_engine->uncaughtException().toString()));
CPPUNIT_ASSERT(_testEdge->asEdge() == it->next());
itCount++;
}
CPPUNIT_ASSERT(itCount == 1); // only n1->n2 (edge coming from n1)
}
示例9: test_unpack_pack
void test_unpack_pack(){
datapack_t handle = datapack_open("tests/data2.pak");
if ( !handle ){
CPPUNIT_FAIL(std::string("unpack_open(..) failed: ") + strerror(errno));
}
char* tmp;
int ret = unpack_filename(handle, "data3.txt", &tmp);
if ( ret != 0 ){
CPPUNIT_FAIL(std::string("unpack_filename(..) failed: ") + strerror(ret));
}
CPPUNIT_ASSERT_EQUAL(std::string(tmp), std::string("test data\n"));
free(tmp);
datapack_close(handle);
}
示例10: exs
/**
* test d'SERDataSource
*/
void CppUnitMessages::test3ExceptionReport() {
std::vector<ServiceException*> exs ( 1, new ServiceException ( locator,code,message,"wmts" ) ) ;
exs.push_back ( new ServiceException ( locator,OWS_NOAPPLICABLE_CODE,"Autre message!!","wmts" ) ) ;
SERDataSource *serDSC= new SERDataSource ( &exs ) ;
if ( serDSC==NULL ) CPPUNIT_FAIL ( "Impossible de créer l'objet SERDataSource !" ) ;
std::string exTxt= serDSC->getMessage() ;
if ( exTxt.length() <=0 ) CPPUNIT_FAIL ( "Message de longueur nulle pour le rapport d'exception !" ) ;
CPPUNIT_ASSERT_MESSAGE ( "attribut code absent du message :\n"+exTxt,exTxt.find ( " exceptionCode=\""+ServiceException::getCodeAsString ( OWS_NOAPPLICABLE_CODE ) +"\"",0 ) !=std::string::npos ) ;
CPPUNIT_ASSERT_MESSAGE ( "Exception absent du message :\n"+exTxt,exTxt.find ( "<Exception ",0 ) !=std::string::npos ) ;
CPPUNIT_ASSERT_MESSAGE ( "ExceptionReport absent du message :\n"+exTxt,exTxt.find ( "<ExceptionReport ",0 ) !=std::string::npos ) ;
CPPUNIT_ASSERT_MESSAGE ( "attribut xmlns absent du message ou incorrect (xmlns=\"http://opengis.net/ows/1.1\" attendu) :\n"+exTxt,exTxt.find ( "xmlns=\"http://www.opengis.net/ows/1.1\"",0 ) !=std::string::npos ) ;
// TODO : validation du XML
delete serDSC ;
exs.clear() ;
} // test3ExceptionReport
示例11: tearDown
void CInfiniteMediatorTest::testFilterReturnsNULL()
{
tearDown();
// Set up the mediator
std::string proto("file://");
std::string infname("./run-0000-00.evt");
std::string outfname("./copy2-run-0000-00.evt");
// std::ifstream ifile (infname.c_str());
// std::ofstream ofile (outfname.c_str());
// m_source = new CIStreamDataSource(ifile);
// m_sink = new COStreamDataSink(ofile);
try {
URL uri(proto+infname);
m_source = new CFileDataSource(uri, std::vector<uint16_t>());
m_sink = new CFileDataSink(outfname);
m_filter = new CNullFilter;
m_mediator = new CInfiniteMediator(0,0,0);
m_mediator->setDataSource(m_source);
m_mediator->setDataSink(m_sink);
m_mediator->setFilter(m_filter);
m_mediator->mainLoop();
// kill all of the sinks and sources
tearDown();
// set up defaults so that we don't segfault at tearDown
setUp();
} catch (CException& exc) {
std::stringstream errmsg; errmsg << "Caught exception:" << exc.ReasonText();
CPPUNIT_FAIL(errmsg.str().c_str());
} catch (int errcode) {
std::stringstream errmsg; errmsg << "Caught integer " << errcode;
CPPUNIT_FAIL(errmsg.str().c_str());
} catch (std::string errmsg) {
CPPUNIT_FAIL(errmsg.c_str());
}
struct stat st;
stat(outfname.c_str(), &st);
CPPUNIT_ASSERT_EQUAL( 0, int(st.st_size) );
remove(outfname.c_str());
}
示例12: set_service_class_thread
void set_service_class_thread(boost::thread *thrd)
{
if (nullptr == service_class_thread) {
service_class_thread = thrd;
} else {
CPPUNIT_FAIL("Unexpected service class thread received.");
}
}
示例13: ASSERT_VALUE
void ASSERT_VALUE(int32_t value, const MetricSnapshot & snapshot, const char *name)
{
const Metric* _metricValue_((snapshot).getMetrics().getMetric(name));
if (_metricValue_ == 0) {
CPPUNIT_FAIL("Metric value '" + std::string(name) + "' not found in snapshot");
}
CPPUNIT_ASSERT_EQUAL(value, int32_t(_metricValue_->getLongValue("value")));
}
示例14: sprintf
void UnitTestUtil::CheckOutput( const char* masterFileName, const char* outFileName )
{
if ( CompareFiles( masterFileName, outFileName ) != 0 ) {
char buffer[5000];
sprintf( buffer, "Output file %s differs from expected output file %s", outFileName, masterFileName );
CPPUNIT_FAIL (buffer);
}
}
示例15: compareWith
void compareWith() {
Index i, j;
NPerm p, q;
for (i = 0; i < nIdx; ++i) {
p = NPerm::atIndex(idx[i]);
if (p.compareWith(p) != 0) {
std::ostringstream msg;
msg << "Routine compareWith() does not conclude that "
<< p.str() << " == " << p.str() << ".";
CPPUNIT_FAIL(msg.str());
}
if (! looksEqual(p, p)) {
std::ostringstream msg;
msg << "Permutation " << p.str()
<< " does not appear to be equal to itself.";
CPPUNIT_FAIL(msg.str());
}
}
for (i = 0; i < nIdx; ++i) {
p = NPerm::atIndex(idx[i]);
for (j = i + 1; j < nIdx; ++j) {
q = NPerm::atIndex(idx[j]);
if (p.compareWith(q) != -1) {
std::ostringstream msg;
msg << "Routine compareWith() does not conclude that "
<< p.str() << " < " << q.str() << ".";
CPPUNIT_FAIL(msg.str());
}
if (q.compareWith(p) != 1) {
std::ostringstream msg;
msg << "Routine compareWith() does not conclude that "
<< q.str() << " > " << p.str() << ".";
CPPUNIT_FAIL(msg.str());
}
if (! looksDistinct(p, q)) {
std::ostringstream msg;
msg << "Permutations " << q.str() << " and "
<< p.str() << " do not appear to be distinct.";
CPPUNIT_FAIL(msg.str());
}
}
}
}