当前位置: 首页>>代码示例>>C++>>正文


C++ CPPUNIT_ASSERT_MESSAGE函数代码示例

本文整理汇总了C++中CPPUNIT_ASSERT_MESSAGE函数的典型用法代码示例。如果您正苦于以下问题:C++ CPPUNIT_ASSERT_MESSAGE函数的具体用法?C++ CPPUNIT_ASSERT_MESSAGE怎么用?C++ CPPUNIT_ASSERT_MESSAGE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CPPUNIT_ASSERT_MESSAGE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: member

void AcsAlarmTestCase::testFaultState()
{
	const std::string member(MEMBER_VALUE);
	const std::string family(FAMILY_VALUE);
	const std::string descriptor(DESCRIPTOR_VALUE);

	acsalarm::ASIMessage message;
	laserSource::CERNASIMessage cernMsg(message);

	// create the FaultState
	std::auto_ptr<acsalarm::FaultState> fltstate = ACSAlarmSystemInterfaceFactory::createFaultState(family, member, CODE_VALUE);

	// test family getters
	CPPUNIT_ASSERT_MESSAGE("FaultState::getFamily appears to be broken", (family == fltstate->getFamily()) );
	CPPUNIT_ASSERT_MESSAGE("FaultState::getMember appears to be broken", (member == fltstate->getMember()) );
	CPPUNIT_ASSERT_MESSAGE("FaultState::getCode appears to be broken", (CODE_VALUE == fltstate->getCode()) );

	// test family setter
	std::string newfamily = "newfamily";
	fltstate->setFamily(newfamily);
	CPPUNIT_ASSERT_MESSAGE("FaultState::setFamily appears to be broken", (newfamily == fltstate->getFamily()) );

	// restore previous value
	fltstate->setFamily(family);

	// test member setter
	std::string newmember = "newmember";
	fltstate->setMember(newmember);
	CPPUNIT_ASSERT_MESSAGE("FaultState::setMember appears to be broken", (newmember == fltstate->getMember()) );

	// restore previous value
	fltstate->setMember(member);

	// test code setter
	int newcode = 2;
	fltstate->setCode(newcode);
	CPPUNIT_ASSERT_MESSAGE("FaultState::setCode appears to be broken", (newcode == fltstate->getCode()) );

	// restore previous value
	fltstate->setCode(CODE_VALUE);

	// test descriptor setter
	fltstate->setDescriptor(descriptor);
	CPPUNIT_ASSERT_MESSAGE("FaultState::setDescriptor appears to be broken", (descriptor == fltstate->getDescriptor()) );

	// test timestamp getters/setters
	acsalarm::Timestamp * tstampPtr = new acsalarm::Timestamp(SECONDS_VALUE, MICROSECONDS_VALUE);
	std::auto_ptr<acsalarm::Timestamp> tstampAutoPtr(tstampPtr);
	fltstate->setUserTimestamp(tstampAutoPtr);
	CPPUNIT_ASSERT_MESSAGE("FaultState::setUserTimestamp appears to be broken", (*tstampPtr == fltstate->getUserTimestamp()) );

	// test properties getters/setters
	acsalarm::Properties * propsPtr = new acsalarm::Properties();
	propsPtr->setProperty(faultState::ASI_PREFIX_PROPERTY_STRING, PREFIX_VALUE_VALUE);
	propsPtr->setProperty(faultState::ASI_SUFFIX_PROPERTY_STRING, SUFFIX_VALUE_VALUE);
	propsPtr->setProperty(TEST_NAME_VALUE, TEST_VALUE_VALUE);
	std::auto_ptr<acsalarm::Properties> propsAutoPtr(propsPtr);
	fltstate->setUserProperties(propsAutoPtr);
	CPPUNIT_ASSERT_MESSAGE("FaultState::setUserProperties appears to be broken", (*propsPtr == fltstate->getUserProperties()) );

	// test activated by backup getters/setters
	bool activatedByBackup = true;
	fltstate->setActivatedByBackup(activatedByBackup);
	CPPUNIT_ASSERT_MESSAGE("FaultState::setActivatedByBackup appears to be broken", (activatedByBackup == fltstate->getActivatedByBackup()) );
	activatedByBackup = false;
	fltstate->setActivatedByBackup(activatedByBackup);
	CPPUNIT_ASSERT_MESSAGE("FaultState::setActivatedByBackup appears to be broken", (activatedByBackup == fltstate->getActivatedByBackup()) );

	// test terminated by backup getters/setters
	bool terminatedByBackup = true;
	fltstate->setTerminatedByBackup(terminatedByBackup);
	CPPUNIT_ASSERT_MESSAGE("FaultState::setTerminatedByBackup appears to be broken", (terminatedByBackup == fltstate->getTerminatedByBackup()) );
	terminatedByBackup = false;
	fltstate->setTerminatedByBackup(terminatedByBackup);
	CPPUNIT_ASSERT_MESSAGE("FaultState::setTerminatedByBackup appears to be broken", (terminatedByBackup == fltstate->getTerminatedByBackup()) );

	// test faultStateToXMLmethod
	verifyFaultStateXML(cernMsg.faultStateToXML(fltstate.get()));
}
开发者ID:ACS-Community,项目名称:ACS,代码行数:79,代码来源:testXML.cpp

示例2: Map

void AnnotatedHierarchicalAStarTest::getPathShouldReturnTheShortestPathBetweenTwoLowLevelNodesGivenACapabilityAndClearanceAndAnnotatedClusterAbstractionParameter()
{
	Map *m = new Map(acmap.c_str());
	AnnotatedClusterAbstraction* aca = new AnnotatedClusterAbstraction(m, new AnnotatedAStar(), TESTCLUSTERSIZE);
	AnnotatedClusterFactory* acfactory = new AnnotatedClusterFactory();
	aca->buildClusters(acfactory);
	aca->buildEntrances();

	graph  *absg = aca->getAbstractGraph(1);
	int numNodesExpected = absg->getNumNodes();
	int numEdgesExpected = absg->getNumEdges();
	int numCachedPathsExpected = aca->getPathCacheSize();
	
	node *start = aca->getNodeFromMap(2,1);
	node* goal = aca->getNodeFromMap(4,5);
	
	int capability = kGround;
	int size = 1;

	ahastar->setGraphAbstraction(aca);
	ahastar->setClearance(size);
	ahastar->setCapability(capability);

	path* p = ahastar->getPath(aca, start,goal);	
	
	int expectedLength = 10;	
	CPPUNIT_ASSERT_EQUAL_MESSAGE("path length wrong", expectedLength, (int)p->length());	

	CPPUNIT_ASSERT_MESSAGE("failed to find a valid path when one exists", p != 0);
	CPPUNIT_ASSERT_MESSAGE("start of path is wrong", start == p->n);
	path* cur = p->next;
	CPPUNIT_ASSERT_MESSAGE("node @ start+1 in path is wrong", aca->getNodeFromMap(3,1)== cur->n);
	cur = cur->next;
	CPPUNIT_ASSERT_MESSAGE("node @ start+2 in path is wrong", aca->getNodeFromMap(4,1)== cur->n);
	cur = cur->next;
	CPPUNIT_ASSERT_MESSAGE("node @ start+3 in path is wrong", aca->getNodeFromMap(5,1)== cur->n);
	cur = cur->next;
	CPPUNIT_ASSERT_MESSAGE("node @ start+4 in path is wrong", aca->getNodeFromMap(6,2)== cur->n);
	cur = cur->next;
	CPPUNIT_ASSERT_MESSAGE("node @ start+5 in path is wrong", aca->getNodeFromMap(6,3)== cur->n);
	cur = cur->next;
	CPPUNIT_ASSERT_MESSAGE("node @ start+6 in path is wrong", aca->getNodeFromMap(6,4) == cur->n);
	cur = cur->next;
	CPPUNIT_ASSERT_MESSAGE("node @ start+7 in path is wrong", aca->getNodeFromMap(5,4)== cur->n);
	cur = cur->next;
	CPPUNIT_ASSERT_MESSAGE("node @ start+8 in path is wrong", aca->getNodeFromMap(5,5)== cur->n);
	CPPUNIT_ASSERT_MESSAGE("end of path is wrong", goal == p->tail()->n);
	
	double expectedDist =  9.41;
	double dist = aca->distance(p);
	dist = ((int)(dist*100+0.5))/100.0;

	CPPUNIT_ASSERT_EQUAL_MESSAGE("path distance wrong", expectedDist, dist);
	
	CPPUNIT_ASSERT_EQUAL_MESSAGE("node count in abstract graph is wrong", numNodesExpected, absg->getNumNodes());
	CPPUNIT_ASSERT_EQUAL_MESSAGE("edge count in abstract graph is wrong", numEdgesExpected, absg->getNumEdges());
	CPPUNIT_ASSERT_EQUAL_MESSAGE("path cache size is wrong", numCachedPathsExpected, aca->getPathCacheSize());
	
	delete p;
	delete acfactory;
	delete aca;
}
开发者ID:Elsopuro,项目名称:ahastar,代码行数:62,代码来源:AnnotatedHierarchicalAStarTest.cpp

示例3: testImageToUnstructuredGridFilterInitialization

 void testImageToUnstructuredGridFilterInitialization()
 {
   mitk::ImageToUnstructuredGridFilter::Pointer testFilter = mitk::ImageToUnstructuredGridFilter::New();
   CPPUNIT_ASSERT_MESSAGE("Testing instantiation of test object", testFilter.IsNotNull());
   CPPUNIT_ASSERT_MESSAGE("Testing initialization of threshold member variable", testFilter->GetThreshold() == -0.1);
 }
开发者ID:junaidnaseer,项目名称:MITK,代码行数:6,代码来源:mitkImageToUnstructuredGridFilterTest.cpp

示例4: GetErrorMessage_Default_ReturnsEmptyString

 void GetErrorMessage_Default_ReturnsEmptyString()
 {
   CPPUNIT_ASSERT_MESSAGE("Error message should be empty", !strcmp(m_TrackingTool->GetErrorMessage(), ""));
 }
开发者ID:Cdebus,项目名称:MITK,代码行数:4,代码来源:mitkTrackingToolTest.cpp

示例5: CPPUNIT_ASSERT_MESSAGE

void MultiAgentTest::doTest()
{
	sml::Kernel* pKernel = sml::Kernel::CreateKernelInNewThread();
	CPPUNIT_ASSERT_MESSAGE( pKernel->GetLastErrorDescription(), !pKernel->HadError() );

	// We'll require commits, just so we're testing that path
	pKernel->SetAutoCommit( false ) ;

	// Comment this in if you need to debug the messages going back and forth.
	//pKernel->SetTraceCommunications(true) ;

	CPPUNIT_ASSERT( numberAgents < MAX_AGENTS );

	std::vector< std::string > names;
	std::vector< sml::Agent* > agents;
	std::vector< std::stringstream* > trace;
	std::vector< int > callbackPrint;

	// Create the agents
	for ( int agentCounter = 0 ; agentCounter < numberAgents ; ++agentCounter )
	{
		std::stringstream name;
		name << "agent" << 1 + agentCounter;
		names.push_back( name.str() );

		sml::Agent* pAgent   = pKernel->CreateAgent( name.str().c_str() ) ;
		CPPUNIT_ASSERT( pAgent != NULL );
		CPPUNIT_ASSERT_MESSAGE( pKernel->GetLastErrorDescription(), !pKernel->HadError() );

		agents.push_back( pAgent );

		std::stringstream path;
		// TODO: use boost filesystem
		CPPUNIT_ASSERT( pAgent->LoadProductions( "test_agents/testmulti.soar" ) );
		createInput( pAgent, 0 );

		// Collect the trace output from the run
		trace.push_back( new std::stringstream() );
		callbackPrint.push_back( pAgent->RegisterForPrintEvent( sml::smlEVENT_PRINT, MultiAgentTest::MyPrintEventHandler, trace[agentCounter] ) );
	}

	pKernel->RegisterForUpdateEvent( sml::smlEVENT_AFTER_ALL_GENERATED_OUTPUT, MultiAgentTest::MyUpdateEventHandler, NULL ) ;

	// Run for a first set of output, so we can see whether that worked
	pKernel->RunAllTilOutput() ;

	// Print out some information
	reportAgentStatus( pKernel, numberAgents, trace ) ;

	// Now get serious about a decent run
	const int kFirstRun = 5 ;
	for (int i = 0 ; i < kFirstRun ; i++)
	{
		// Run for a bit
		pKernel->RunAllTilOutput() ;
	}

	reportAgentStatus(pKernel, numberAgents, trace) ;

	// Toss in an init-soar and then go on a bit further
	initAll(pKernel) ;

	// Second run
	const int kSecondRun = 5 ;
	for (int i = 0 ; i < kSecondRun ; i++)
	{
		// Run for a bit
		pKernel->RunAllTilOutput() ;
	}

	reportAgentStatus(pKernel, numberAgents, trace) ;

	for ( std::vector< std::stringstream* >::iterator iter = trace.begin(); iter != trace.end(); ++iter )
	{
		delete *iter;
	}

	//cout << "Calling shutdown on the kernel now" << endl ;
	pKernel->Shutdown() ;
	//cout << "Shutdown completed now" << endl ;

	// Delete the kernel.  If this is an embedded connection this destroys the kernel.
	// If it's a remote connection we just disconnect.
	delete pKernel ;
}
开发者ID:amininger,项目名称:Soar,代码行数:85,代码来源:multiagenttest.cpp

示例6: CPPUNIT_ASSERT_MESSAGE

void TestMapModel::testSetMapOrientation_validOrientation_updateMapOrientation() {
	this->mapModel->setMapOrientation(Orthogonal);
	Orientation orientation = this->mapModel->getMapOrientation();
	CPPUNIT_ASSERT_MESSAGE("Map orientation is not updated", orientation == Orthogonal);
}
开发者ID:Ghuillaume,项目名称:IroverMBT,代码行数:5,代码来源:TestMapModel.cpp

示例7: setUp

 void setUp() override
 {
   m_ContourNormalsFilter = mitk::ComputeContourSetNormalsFilter::New();
   CPPUNIT_ASSERT_MESSAGE("Failed to initialize ReduceContourSetFilter", m_ContourNormalsFilter.IsNotNull());
 }
开发者ID:pollen-metrology,项目名称:MITK,代码行数:5,代码来源:mitkComputeContourSetNormalsFilterTest.cpp

示例8: TestRemoveLayer

  void TestRemoveLayer()
  {
    // Cache active layer
    mitk::LabelSet::ConstPointer activeLayer = m_LabelSetImage->GetActiveLabelSet();

    // Add new layers
    m_LabelSetImage->AddLayer();

    mitk::LabelSet::Pointer newlayer = mitk::LabelSet::New();
    mitk::Label::Pointer label1 = mitk::Label::New();
    label1->SetName("Label1");
    label1->SetValue(1);

    mitk::Label::Pointer label2 = mitk::Label::New();
    label2->SetName("Label2");
    label2->SetValue(200);

    newlayer->AddLabel(label1);
    newlayer->AddLabel(label2);
    newlayer->SetActiveLabel(200);

    m_LabelSetImage->AddLayer(newlayer);

    CPPUNIT_ASSERT_MESSAGE("Wrong active labelset returned",
                           mitk::Equal(*newlayer, *m_LabelSetImage->GetActiveLabelSet(), 0.00001, true));

    m_LabelSetImage->RemoveLayer();
    CPPUNIT_ASSERT_MESSAGE("Wrong number of layers, after a layer was removed",
                           m_LabelSetImage->GetNumberOfLayers() == 2);
    CPPUNIT_ASSERT_MESSAGE("Check for existing layer failed", m_LabelSetImage->ExistLabelSet(2) == false);
    CPPUNIT_ASSERT_MESSAGE("Check for existing layer failed", m_LabelSetImage->ExistLabelSet(1) == true);
    CPPUNIT_ASSERT_MESSAGE("Check for existing layer failed", m_LabelSetImage->ExistLabelSet(0) == true);

    m_LabelSetImage->RemoveLayer();
    CPPUNIT_ASSERT_MESSAGE("Wrong number of layers, after a layer was removed",
                           m_LabelSetImage->GetNumberOfLayers() == 1);
    CPPUNIT_ASSERT_MESSAGE("Check for existing layer failed", m_LabelSetImage->ExistLabelSet(1) == false);
    CPPUNIT_ASSERT_MESSAGE("Check for existing layer failed", m_LabelSetImage->ExistLabelSet(0) == true);
    CPPUNIT_ASSERT_MESSAGE("Wrong active layer",
                           mitk::Equal(*activeLayer, *m_LabelSetImage->GetActiveLabelSet(), 0.00001, true));

    m_LabelSetImage->RemoveLayer();
    CPPUNIT_ASSERT_MESSAGE("Wrong number of layers, after a layer was removed",
                           m_LabelSetImage->GetNumberOfLayers() == 0);
    CPPUNIT_ASSERT_MESSAGE("Check for existing layer failed", m_LabelSetImage->ExistLabelSet(0) == false);
    CPPUNIT_ASSERT_MESSAGE("Active layers is not nullptr although all layer have been removed",
                           m_LabelSetImage->GetActiveLabelSet() == 0);
  }
开发者ID:junaidnaseer,项目名称:MITK,代码行数:48,代码来源:mitkLabelSetImageTest.cpp

示例9: Throttle

void
ThrottleTest::testRequest()
{
    auto_ptr<Throttle> throttle;

    throttle.reset(new Throttle(10,4096));

    boost::posix_time::ptime begin =
            boost::posix_time::microsec_clock::local_time();
    CPPUNIT_ASSERT( true == throttle->Request(8192) );
    boost::posix_time::ptime end =
            boost::posix_time::microsec_clock::local_time();
    int duration = (end - begin).total_milliseconds();
    CPPUNIT_ASSERT( duration <= 1 );
    begin = end;

    CPPUNIT_ASSERT( true == throttle->Request(0) );
    end = boost::posix_time::microsec_clock::local_time();
    duration = (end - begin).total_milliseconds();
    CPPUNIT_ASSERT( duration <= 1 );
    begin = end;

    CPPUNIT_ASSERT( true == throttle->Request(1024) );
    end = boost::posix_time::microsec_clock::local_time();
    duration = (end - begin).total_milliseconds();
    CPPUNIT_ASSERT_MESSAGE( boost::lexical_cast<string>(duration),
            duration >= 9 && duration <= 11 );
    begin = end;

    CPPUNIT_ASSERT( true == throttle->Request(1024) );
    end = boost::posix_time::microsec_clock::local_time();
    duration = (end - begin).total_milliseconds();
    CPPUNIT_ASSERT_MESSAGE( boost::lexical_cast<string>(duration),
            duration >= 2 && duration <= 3 );
    begin = end;

    boost::this_thread::sleep(
            boost::posix_time::milliseconds(10) );

    begin = boost::posix_time::microsec_clock::local_time();
    CPPUNIT_ASSERT( true == throttle->Request(1024) );
    end = boost::posix_time::microsec_clock::local_time();
    duration = (end - begin).total_milliseconds();
    CPPUNIT_ASSERT( duration <= 1 );
    begin = end;

    CPPUNIT_ASSERT( true == throttle->Request(1024) );
    end = boost::posix_time::microsec_clock::local_time();
    duration = (end - begin).total_milliseconds();
    CPPUNIT_ASSERT( duration <= 1 );
    begin = end;

    CPPUNIT_ASSERT( true == throttle->Request(1024) );
    end = boost::posix_time::microsec_clock::local_time();
    duration = (end - begin).total_milliseconds();
    CPPUNIT_ASSERT( duration <= 1 );
    begin = end;

    CPPUNIT_ASSERT( true == throttle->Request(1024) );
    end = boost::posix_time::microsec_clock::local_time();
    duration = (end - begin).total_milliseconds();
    CPPUNIT_ASSERT_MESSAGE( boost::lexical_cast<string>(duration),
            duration <= 1 );
    begin = end;

    CPPUNIT_ASSERT( true == throttle->Request(1024) );
    end = boost::posix_time::microsec_clock::local_time();
    duration = (end - begin).total_milliseconds();
    CPPUNIT_ASSERT_MESSAGE( boost::lexical_cast<string>(duration),
            duration >= 2 && duration <= 3 );
    begin = end;

    CPPUNIT_ASSERT( true == throttle->Reset(10,4096) );
    CPPUNIT_ASSERT( true == throttle->Request(1024) );
    end = boost::posix_time::microsec_clock::local_time();
    duration = (end - begin).total_milliseconds();
    CPPUNIT_ASSERT( duration <= 1 );
}
开发者ID:BDT-GER,项目名称:SWIFT-TLC,代码行数:78,代码来源:ThrottleTest.cpp

示例10: fn

void FileNameTestCase::TestConstruction()
{
    for ( size_t n = 0; n < WXSIZEOF(filenames); n++ )
    {
        const TestFileNameInfo& fni = filenames[n];

        wxFileName fn(fni.fullname, fni.format);

        // the original full name could contain consecutive [back]slashes,
        // squeeze them except for the double backslash in the beginning in
        // Windows filenames where it has special meaning
        wxString fullnameOrig;
        if ( fni.format == wxPATH_DOS )
        {
            // copy the backslashes at beginning unchanged
            const char *p = fni.fullname;
            while ( *p == '\\' )
                fullnameOrig += *p++;

            // replace consecutive slashes with single ones in the rest
            for ( char chPrev = '\0'; *p; p++ )
            {
                if ( *p == '\\' && chPrev == '\\' )
                    continue;

                chPrev = *p;
                fullnameOrig += chPrev;
            }
        }
        else // !wxPATH_DOS
        {
            fullnameOrig = fni.fullname;
        }

        fullnameOrig.Replace("//", "/");


        wxString fullname = fn.GetFullPath(fni.format);
        CPPUNIT_ASSERT_EQUAL( fullnameOrig, fullname );

        // notice that we use a dummy working directory to ensure that paths
        // with "../.." in them could be normalized, otherwise this would fail
        // if the test is run from root directory or its direct subdirectory
        CPPUNIT_ASSERT_MESSAGE
        (
            (const char *)wxString::Format("Normalize(%s) failed", fni.fullname).mb_str(),
            fn.Normalize(wxPATH_NORM_ALL, "/foo/bar/baz", fni.format)
        );

        if ( *fni.volume && *fni.path )
        {
            // check that specifying the volume separately or as part of the
            // path doesn't make any difference
            wxString pathWithVolume = fni.volume;
            pathWithVolume += wxFileName::GetVolumeSeparator(fni.format);
            pathWithVolume += fni.path;

            CPPUNIT_ASSERT_EQUAL( wxFileName(pathWithVolume,
                                             fni.name,
                                             fni.ext,
                                             fni.format), fn );
        }
    }

    wxFileName fn;

    // empty strings
    fn.AssignDir(wxEmptyString);
    CPPUNIT_ASSERT( !fn.IsOk() );

    fn.Assign(wxEmptyString);
    CPPUNIT_ASSERT( !fn.IsOk() );

    fn.Assign(wxEmptyString, wxEmptyString);
    CPPUNIT_ASSERT( !fn.IsOk() );

    fn.Assign(wxEmptyString, wxEmptyString, wxEmptyString);
    CPPUNIT_ASSERT( !fn.IsOk() );

    fn.Assign(wxEmptyString, wxEmptyString, wxEmptyString, wxEmptyString);
    CPPUNIT_ASSERT( !fn.IsOk() );
}
开发者ID:slunski,项目名称:wxWidgets,代码行数:82,代码来源:filenametest.cpp

示例11: tmpdir

// Tests for functions that are changed by ShouldFollowLink()
void FileNameTestCase::TestSymlinks()
{
    const wxString tmpdir(wxStandardPaths::Get().GetTempDir());

    wxFileName tmpfn(wxFileName::DirName(tmpdir));

    // Create a temporary directory
#ifdef __VMS
    wxString name = tmpdir + ".filenametestXXXXXX]";
    mkdir( name.char_str() , 0222 );
    wxString tempdir = name;
#else
    wxString name = tmpdir + "/filenametestXXXXXX";
    wxString tempdir = wxString::From8BitData(mkdtemp(name.char_str()));
    tempdir << wxFileName::GetPathSeparator();
#endif
    wxFileName tempdirfn(wxFileName::DirName(tempdir));
    CPPUNIT_ASSERT(tempdirfn.DirExists());

    // Create a regular file in that dir, to act as a symlink target
    wxFileName targetfn(wxFileName::CreateTempFileName(tempdir));
    CPPUNIT_ASSERT(targetfn.FileExists());

    // Create a symlink to that file
    wxFileName linktofile(tempdir, "linktofile");
    CPPUNIT_ASSERT_EQUAL(0, symlink(targetfn.GetFullPath().c_str(),
                                        linktofile.GetFullPath().c_str()));

    // ... and another to the temporary directory
    const wxString linktodirName(tempdir + "/linktodir");
    wxFileName linktodir(wxFileName::DirName(linktodirName));
    CPPUNIT_ASSERT_EQUAL(0, symlink(tmpfn.GetFullPath().c_str(),
                                        linktodirName.c_str()));

    // And symlinks to both of those symlinks
    wxFileName linktofilelnk(tempdir, "linktofilelnk");
    CPPUNIT_ASSERT_EQUAL(0, symlink(linktofile.GetFullPath().c_str(),
                                    linktofilelnk.GetFullPath().c_str()));
    wxFileName linktodirlnk(tempdir, "linktodirlnk");
    CPPUNIT_ASSERT_EQUAL(0, symlink(linktodir.GetFullPath().c_str(),
                                    linktodirlnk.GetFullPath().c_str()));

    // Run the tests twice: once in the default symlink following mode and the
    // second time without following symlinks.
    bool deref = true;
    for ( int n = 0; n < 2; ++n, deref = !deref )
    {
        const std::string msg(deref ? " failed for the link target"
                                    : " failed for the path itself");

        if ( !deref )
        {
            linktofile.DontFollowLink();
            linktodir.DontFollowLink();
            linktofilelnk.DontFollowLink();
            linktodirlnk.DontFollowLink();
        }

        // Test SameAs()
        CPPUNIT_ASSERT_EQUAL_MESSAGE
        (
            "Comparison with file" + msg,
            deref, linktofile.SameAs(targetfn)
        );

        CPPUNIT_ASSERT_EQUAL_MESSAGE
        (
            "Comparison with directory" + msg,
            deref, linktodir.SameAs(tmpfn)
        );

        // A link-to-a-link should dereference through to the final target
        CPPUNIT_ASSERT_EQUAL_MESSAGE
        (
            "Comparison with link to a file" + msg,
            deref,
            linktofilelnk.SameAs(targetfn)
        );
        CPPUNIT_ASSERT_EQUAL_MESSAGE
        (
            "Comparison with link to a directory" + msg,
            deref,
            linktodirlnk.SameAs(tmpfn)
        );

        // Test GetTimes()
        wxDateTime dtAccess, dtMod, dtCreate;
        CPPUNIT_ASSERT_MESSAGE
        (
            "Getting times of a directory" + msg,
            linktodir.GetTimes(&dtAccess, &dtMod, &dtCreate)
        );

        // Test (File|Dir)Exists()
        CPPUNIT_ASSERT_EQUAL_MESSAGE
        (
            "Testing file existence" + msg,
            deref,
            linktofile.FileExists()
//.........这里部分代码省略.........
开发者ID:slunski,项目名称:wxWidgets,代码行数:101,代码来源:filenametest.cpp

示例12: ls1

void 
GeometricHelperTest::LineSegmentRayIntersectionTest() {
    {
        LineSegment ls1(Vertex(0, 1), Vertex(1, 1));
        Ray ray(Vertex(0, 0), Vertex(1, 2));

        // segment/ray intersect
        boost::optional<Vertex> intersection_point_opt = GeometricHelper::intersect(ls1, ray);
        CPPUNIT_ASSERT_MESSAGE("Intersection point expected", bool(intersection_point_opt));

        Vertex intersection_point = *intersection_point_opt;
        CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Intersection point error", 0.5, intersection_point.x(), 1E-10);
        CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Intersection point error", 1.0, intersection_point.y(), 1E-10);
    }

    {
        LineSegment ls1(Vertex(0, 3), Vertex(1, 3));
        Ray ray(Vertex(0, 0), Vertex(0.25, 1));

        // segment/ray intersect
        boost::optional<Vertex> intersection_point_opt = GeometricHelper::intersect(ls1, ray);
        CPPUNIT_ASSERT_MESSAGE("Intersection point expected", bool(intersection_point_opt));

        Vertex intersection_point = *intersection_point_opt;
        CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Intersection point error", 0.75, intersection_point.x(), 1E-10);
        CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Intersection point error", 3.0, intersection_point.y(), 1E-10);
    }


    {
        LineSegment ls1(Vertex(0, 1), Vertex(1, 1));
        Ray ray(Vertex(0.25, 2), Vertex(1, 4));

        // segment/ray do not intersect
        boost::optional<Vertex> intersection_point_opt = GeometricHelper::intersect(ls1, ray);
        CPPUNIT_ASSERT_MESSAGE("No intersection point expected", !bool(intersection_point_opt));
    }

    {
        LineSegment ls(Vertex(0, 1), Vertex(1, 1));
        Ray ray(Vertex(0, 0), Vertex(2, 1));

        // segments do not intersect
        boost::optional<Vertex> intersection_point_opt = GeometricHelper::intersect(ls, ray);
        CPPUNIT_ASSERT_MESSAGE("No intersection point expected", !bool(intersection_point_opt));
    }

    {
        LineSegment ls(Vertex(0, 1), Vertex(1, 1));
        Ray ray(Vertex(0.5, 1), Vertex(2, 1));

        // segment/ray overlap
        boost::optional<Vertex> intersection_point_opt = GeometricHelper::intersect(ls, ray);
        CPPUNIT_ASSERT_MESSAGE("No intersection point expected", !bool(intersection_point_opt));
    }

    {
        LineSegment ls(Vertex(0.5, 1), Vertex(1, 1));
        Ray ray(Vertex(0, 1), Vertex(2, 1));

        // segment contained in ray
        boost::optional<Vertex> intersection_point_opt = GeometricHelper::intersect(ls, ray);
        CPPUNIT_ASSERT_MESSAGE("No intersection point expected", !bool(intersection_point_opt));
    }

    {
        LineSegment ls(Vertex(0, 1), Vertex(1, 1));
        Ray ray(Vertex(1.5, 1), Vertex(2, 1));

        // segment and ray parallel
        boost::optional<Vertex> intersection_point_opt = GeometricHelper::intersect(ls, ray);
        CPPUNIT_ASSERT_MESSAGE("No intersection point expected", !bool(intersection_point_opt));
    }
}
开发者ID:svenschmidt75,项目名称:FiniteVolume2D,代码行数:74,代码来源:GeometricHelperTest.cpp

示例13: ls

void 
GeometricHelperTest::LineSegmentLineIntersectionTest() {
    {
        LineSegment ls(Vertex(0, 1), Vertex(1, 1));
        Line line(Vertex(0, 0), Vertex(1, 2));

        // segment/line intersect
        boost::optional<Vertex> intersection_point_opt = GeometricHelper::intersect(ls, line);
        CPPUNIT_ASSERT_MESSAGE("Intersection point expected", bool(intersection_point_opt));

        Vertex intersection_point = *intersection_point_opt;
        CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Intersection point error", 0.5, intersection_point.x(), 1E-10);
        CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Intersection point error", 1.0, intersection_point.y(), 1E-10);
    }

    {
        LineSegment ls(Vertex(0, 3), Vertex(1, 3));
        Line line(Vertex(0, 0), Vertex(0.25, 1));

        // segment/line intersect
        boost::optional<Vertex> intersection_point_opt = GeometricHelper::intersect(ls, line);
        CPPUNIT_ASSERT_MESSAGE("Intersection point expected", bool(intersection_point_opt));

        Vertex intersection_point = *intersection_point_opt;
        CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Intersection point error", 0.75, intersection_point.x(), 1E-10);
        CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Intersection point error", 3.0, intersection_point.y(), 1E-10);
    }


    {
        LineSegment ls(Vertex(0, 1), Vertex(1, 1));
        Line line(Vertex(0.25, 2), Vertex(1, 4));

        // segment/line do not intersect
        boost::optional<Vertex> intersection_point_opt = GeometricHelper::intersect(ls, line);
        CPPUNIT_ASSERT_MESSAGE("No intersection point expected", !bool(intersection_point_opt));
    }

    {
        LineSegment ls(Vertex(0, 1), Vertex(1, 1));
        Line line(Vertex(0, 0), Vertex(2, 1));

        // segments do not intersect
        boost::optional<Vertex> intersection_point_opt = GeometricHelper::intersect(ls, line);
        CPPUNIT_ASSERT_MESSAGE("No intersection point expected", !bool(intersection_point_opt));
    }

    {
        LineSegment ls(Vertex(0, 1), Vertex(1, 1));
        Line line(Vertex(0.5, 1), Vertex(2, 1));

        // segment/line overlap
        boost::optional<Vertex> intersection_point_opt = GeometricHelper::intersect(ls, line);
        CPPUNIT_ASSERT_MESSAGE("No intersection point expected", !bool(intersection_point_opt));
    }

    {
        LineSegment ls(Vertex(0.5, 1), Vertex(1, 1));
        Line line(Vertex(0, 1), Vertex(2, 1));

        // segment contained in line
        boost::optional<Vertex> intersection_point_opt = GeometricHelper::intersect(ls, line);
        CPPUNIT_ASSERT_MESSAGE("No intersection point expected", !bool(intersection_point_opt));
    }

    {
        LineSegment ls(Vertex(0, 1), Vertex(1, 1));
        Line line(Vertex(1.5, 1), Vertex(2, 1));

        // segment and line parallel
        boost::optional<Vertex> intersection_point_opt = GeometricHelper::intersect(ls, line);
        CPPUNIT_ASSERT_MESSAGE("No intersection point expected", !bool(intersection_point_opt));
    }

    {
        LineSegment ls(Vertex(0, 1), Vertex(1, 1));
        Line line(Vertex(1.5, 2), Vertex(2, 2));

        // segment and line parallel, but not collinear
        boost::optional<Vertex> intersection_point_opt = GeometricHelper::intersect(ls, line);
        CPPUNIT_ASSERT_MESSAGE("No intersection point expected", !bool(intersection_point_opt));
    }
}
开发者ID:svenschmidt75,项目名称:FiniteVolume2D,代码行数:83,代码来源:GeometricHelperTest.cpp

示例14: CPPUNIT_ASSERT_MESSAGE

void AcsAlarmTestCase::verifyUserPropertiesElement(DOMDocument * doc)
{
	// Verify the user-properties element
	DOMNodeList * userPropertiesNodes = doc->getElementsByTagName(USER_PROPERTIES_TAG_NAME);
	CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; no user-properties element found",
		(NULL != userPropertiesNodes && userPropertiesNodes->getLength() == 1));

	// check for 3 property sub-element(s)
	DOMNodeList * propertyNodes = doc->getElementsByTagName(PROPERTY_TAG_NAME);
	CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; did not find 3 property elements",
		(NULL != propertyNodes && propertyNodes->getLength() == 3));

	// verify for each property element that it has the expected attributes
	for(XMLSize_t i = 0; i < propertyNodes->getLength(); i++)
	{
		DOMNamedNodeMap * attributesMap = propertyNodes->item(i)->getAttributes();
		CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; property element does not contain 2 attributes",
			(NULL!= attributesMap && attributesMap->getLength() == 2));

		// check that the property element has a "name" attribute
		DOMNode * familyNode = attributesMap->getNamedItem(NAME_TAG_NAME);
		CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; property element does not contain 'name' attribute",
			(NULL!= familyNode));

		// check that the property element has a "value" attribute
		DOMNode * valueNode = attributesMap->getNamedItem(VALUE_TAG_NAME);
		CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; property element does not contain 'value' attribute",
			(NULL!= valueNode));
	}

	// for each property, check the 'name' attribute
	DOMNamedNodeMap * firstPropAttrMap = propertyNodes->item(0)->getAttributes();
	DOMNode * prefixNameNode = firstPropAttrMap->getNamedItem(NAME_TAG_NAME);
	const XMLCh * prefixNameNodeValue = prefixNameNode->getNodeValue();
	CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; 1st property element, 'name' attribute value is not correct",
		(NULL!= prefixNameNodeValue && XMLString::equals(prefixNameNodeValue, PREFIX_NAME_VALUE_XMLCH)));

	DOMNamedNodeMap * secondPropAttrMap = propertyNodes->item(1)->getAttributes();
	DOMNode * suffixNameNode = secondPropAttrMap->getNamedItem(NAME_TAG_NAME);
	const XMLCh * suffixNameNodeValue = suffixNameNode->getNodeValue();
	CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; 2nd property element, 'name' attribute value is not correct",
		(NULL!= suffixNameNodeValue && XMLString::equals(suffixNameNodeValue, SUFFIX_NAME_VALUE_XMLCH)));

	DOMNamedNodeMap * thirdPropAttrMap = propertyNodes->item(2)->getAttributes();
	DOMNode * testPropNameNode = thirdPropAttrMap->getNamedItem(NAME_TAG_NAME);
	const XMLCh * testPropNameNodeValue = testPropNameNode->getNodeValue();
	CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; 3rd property element, 'name' attribute value is not correct",
		(NULL!= testPropNameNodeValue && XMLString::equals(testPropNameNodeValue, TEST_NAME_VALUE_XMLCH)));

	// for each property, check the 'value' attribute
	DOMNamedNodeMap * firstAttrMap = propertyNodes->item(0)->getAttributes();
	DOMNode * prefixValueNode = firstAttrMap->getNamedItem(VALUE_TAG_NAME);
	const XMLCh * prefixValueNodeValue = prefixValueNode->getNodeValue();
	CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; 1st property element, 'value' attribute value is not correct",
		(NULL!= prefixValueNodeValue && XMLString::equals(prefixValueNodeValue, PREFIX_VALUE_VALUE_XMLCH)));

	DOMNamedNodeMap * secondAttrMap = propertyNodes->item(1)->getAttributes();
	DOMNode * suffixValueNode = secondAttrMap->getNamedItem(VALUE_TAG_NAME);
	const XMLCh * suffixValueNodeValue = suffixValueNode->getNodeValue();
	CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; 2nd property element, 'value' attribute value is not correct",
		(NULL!= suffixValueNodeValue && XMLString::equals(suffixValueNodeValue, SUFFIX_VALUE_VALUE_XMLCH)));

	DOMNamedNodeMap * thirdAttrMap = propertyNodes->item(2)->getAttributes();
	DOMNode * testValueNode = thirdAttrMap->getNamedItem(VALUE_TAG_NAME);
	const XMLCh * testValueNodeValue = testValueNode->getNodeValue();
	CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; 3rd property element, 'value' attribute value is not correct",
		(NULL!= testValueNodeValue && XMLString::equals(testValueNodeValue, TEST_VALUE_VALUE_XMLCH)));
}
开发者ID:ACS-Community,项目名称:ACS,代码行数:68,代码来源:testXML.cpp

示例15: request

void HTTPWSTest::testReloadWhileDisconnecting()
{
    const std::string documentPath = Util::getTempFilePath(TDOC, "hello.odt");
    const std::string documentURL = "file://" + Poco::Path(documentPath).makeAbsolute().toString();

    int kitcount = -1;
    try
    {
        // Load a document and get its status.
        Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, documentURL);
        Poco::Net::WebSocket socket = *connectLOKit(request, _response);

        sendTextFrame(socket, "load url=" + documentURL);
        CPPUNIT_ASSERT_MESSAGE("cannot load the document " + documentURL, isDocumentLoaded(socket));

        sendTextFrame(socket, "uno .uno:SelectAll");
        sendTextFrame(socket, "uno .uno:Delete");
        sendTextFrame(socket, "paste mimetype=text/plain;charset=utf-8\naaa bbb ccc");

        kitcount = countLoolKitProcesses();

        // Shutdown abruptly.
        socket.shutdown();
    }
    catch (const Poco::Exception& exc)
    {
        CPPUNIT_FAIL(exc.displayText());
    }

    std::cout << "Loading again." << std::endl;
    try
    {
        // Load the same document and check that the last changes (pasted text) is saved.
        Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, documentURL);
        Poco::Net::WebSocket socket = *connectLOKit(request, _response);

        sendTextFrame(socket, "load url=" + documentURL);
        sendTextFrame(socket, "status");
        CPPUNIT_ASSERT_MESSAGE("cannot load the document " + documentURL, isDocumentLoaded(socket));

        // Should have no new instances.
        CPPUNIT_ASSERT_EQUAL(kitcount, countLoolKitProcesses());

        // Check if the document contains the pasted text.
        sendTextFrame(socket, "uno .uno:SelectAll");
        sendTextFrame(socket, "gettextselection mimetype=text/plain;charset=utf-8");
        std::string selection;
        int flags;
        int n;
        do
        {
            char buffer[READ_BUFFER_SIZE];
            n = socket.receiveFrame(buffer, sizeof(buffer), flags);
            std::cout << "Got " << n << " bytes, flags: " << std::hex << flags << std::dec << '\n';
            if (n > 0 && (flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) != Poco::Net::WebSocket::FRAME_OP_CLOSE)
            {
                std::cout << "Received message: " << LOOLProtocol::getAbbreviatedMessage(buffer, n) << '\n';
                const std::string line = LOOLProtocol::getFirstLine(buffer, n);
                if (line.find("editlock: ") == 0)
                {
                    // We must have the editlock, otherwise we aren't alone.
                    CPPUNIT_ASSERT_EQUAL(std::string("editlock: 1"), line);
                }

                const std::string prefix = "textselectioncontent: ";
                if (line.find(prefix) == 0)
                {
                    selection = line.substr(prefix.length());
                    break;
                }
            }
        }
        while (n > 0 && (flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) != Poco::Net::WebSocket::FRAME_OP_CLOSE);
        socket.shutdown();
        Util::removeFile(documentPath);
        CPPUNIT_ASSERT_EQUAL(std::string("aaa bbb ccc"), selection);
    }
    catch (const Poco::Exception& exc)
    {
        CPPUNIT_FAIL(exc.displayText());
    }
}
开发者ID:pranavk,项目名称:online,代码行数:82,代码来源:httpwstest.cpp


注:本文中的CPPUNIT_ASSERT_MESSAGE函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。