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)); }
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()); } }
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(); }
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()); } }
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"); } }
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()); }
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() ); } }
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) }
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); }
void testEraseAll() { //unused: int i; uint16_t addr = 0x1F; getReady(); // Enable write writeOpAddr(EWEN_OPCODE, EWEN_OPCODE_BITS, 0, EWEN_ADDR_BITS); standby(); // Fill all memory writeOpAddr(WRITE_OPCODE, WRITE_OPCODE_BITS, addr, WRITE_ADDR_BITS); writeData(0); standby(); if (waitForCompletion()) { stop(); getReady(); // Write successful -- verify random location CPPUNIT_ASSERT_EQUAL((uint16_t)0, readAt(addr)); stop(); getReady(); writeOpAddr(ERAL_OPCODE, ERAL_OPCODE_BITS, addr, ERAL_ADDR_BITS); standby(); if (!waitForCompletion()) { CPPUNIT_FAIL("EEPROM erase was not completed"); stop(); return; } standby(); writeOpAddr(EWDS_OPCODE, EWDS_OPCODE_BITS, 0, EWDS_ADDR_BITS); stop(); getReady(); for ( addr=0; addr < EEPROM93C46::SIZE; addr++ ) { CPPUNIT_ASSERT_EQUAL((uint16_t)0xFFFF, readAt(addr)); } } else { CPPUNIT_FAIL("EEPROM write was not completed"); } stop(); }
/** * 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
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()); }
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."); } }
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"))); }
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); } }
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()); } } } }
void CInfiniteMediatorTest::testProcessSome() { tearDown(); int nToProcess=11; std::string proto("file://"); std::string infname("./run-0000-00.evt"); std::string outfname("./copy-run-0000-00.evt"); try { URL uri(proto+infname); m_source = new CFileDataSource(uri, std::vector<uint16_t>()); m_sink = new CFileDataSink(outfname); m_filter = new CTestFilter; m_mediator = new CInfiniteMediator(0,0,0); m_mediator->setDataSource(m_source); m_mediator->setDataSink(m_sink); m_mediator->setFilter(m_filter); m_mediator->setProcessCount(nToProcess); m_mediator->mainLoop(); CPPUNIT_ASSERT_EQUAL(nToProcess, static_cast<CTestFilter*>(m_filter)->getNProcessed()); // 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()); } remove(outfname.c_str()); }
void GridGeometryTest::testGetGeometryHirlam10() { std::ostringstream exp; double x0 = 5.75 * DEG_TO_RAD; double y0 = -13.25 * DEG_TO_RAD; double x1 = (5.75+(247*0.1)) * DEG_TO_RAD; double y1 = -13.25 * DEG_TO_RAD; double x2 = (5.75+(247*0.1)) * DEG_TO_RAD; double y2 = (-13.25+(399*0.1)) * DEG_TO_RAD; double x3 = 5.75 * DEG_TO_RAD; double y3 = (-13.25+(399*0.1)) * DEG_TO_RAD; int error = pj_transform( hirlam10Proj, targetProj, 1, 0, &x0, &y0, NULL ); if ( error ) { std::ostringstream msg; msg << "Error during reprojection: " << pj_strerrno(error) << "."; CPPUNIT_FAIL( msg.str() ); } error = pj_transform( hirlam10Proj, targetProj, 1, 0, &x1, &y1, NULL ); if ( error ) { std::ostringstream msg; msg << "Error during reprojection: " << pj_strerrno(error) << "."; CPPUNIT_FAIL( msg.str() ); } error = pj_transform( hirlam10Proj, targetProj, 1, 0, &x2, &y2, NULL ); if ( error ) { std::ostringstream msg; msg << "Error during reprojection: " << pj_strerrno(error) << "."; CPPUNIT_FAIL( msg.str() ); } error = pj_transform( hirlam10Proj, targetProj, 1, 0, &x3, &y3, NULL ); if ( error ) { std::ostringstream msg; msg << "Error during reprojection: " << pj_strerrno(error) << "."; CPPUNIT_FAIL( msg.str() ); } exp << "POLYGON(("; exp << wdb::round(x0 * RAD_TO_DEG, 4) << " " << wdb::round (y0 * RAD_TO_DEG, 4) << ","; exp << wdb::round(x1 * RAD_TO_DEG, 4) << " " << wdb::round (y1 * RAD_TO_DEG, 4) << ","; exp << wdb::round(x2 * RAD_TO_DEG, 4) << " " << wdb::round (y2 * RAD_TO_DEG, 4) << ","; exp << wdb::round(x3 * RAD_TO_DEG, 4) << " " << wdb::round (y3 * RAD_TO_DEG, 4) << ","; exp << wdb::round(x0 * RAD_TO_DEG, 4) << " " << wdb::round (y0 * RAD_TO_DEG, 4) << "))"; const std::string expected = exp.str(); std::string geometry = grid->wktRepresentation(); CPPUNIT_ASSERT_EQUAL( expected, geometry); }
/*! * @brief tests for get_loaded_modules() * * * */ void test_get_loaded_modules() { ::RTM::ManagerServant *pman = new ::RTM::ManagerServant(); ::RTC::ReturnCode_t ret; try { ret = pman->load_module(".libs/DummyModule1.so","DummyModule1Init"); CPPUNIT_ASSERT_EQUAL(::RTC::RTC_OK, ret); CPPUNIT_ASSERT(isFound(pman->get_loaded_modules(), ".//.libs/DummyModule1.so")); } catch(...) { CPPUNIT_FAIL("Exception thrown."); } try { ret = pman->load_module(".libs/DummyModule2.so","DummyModule2Init"); CPPUNIT_ASSERT_EQUAL(::RTC::RTC_OK, ret); CPPUNIT_ASSERT(isFound(pman->get_loaded_modules(), ".//.libs/DummyModule2.so")); } catch(...) { CPPUNIT_FAIL("Exception thrown."); } //Execute the function ::RTM::ModuleProfileList* list; list = pman->get_loaded_modules(); ::RTM::ModuleProfileList modlist(*list); delete list; //Check returns(ModuleProfileList). CPPUNIT_ASSERT_EQUAL((::CORBA::ULong)2, modlist.length()); CPPUNIT_ASSERT_EQUAL(::std::string("file_path"), ::std::string(modlist[0].properties[0].name)); const char* ch; if( modlist[0].properties[0].value >>= ch ) { CPPUNIT_ASSERT_EQUAL(::std::string(".//.libs/DummyModule1.so"), ::std::string(ch)); } else {
void ConfigTest::testConfigCharThrowInvalidArgument(void) { try { Config config('\"'); CPPUNIT_FAIL("std::invalid_argument must be throw."); } catch (std::invalid_argument&) { CPPUNIT_ASSERT(true); } }
void CSomeTests::test2() { int var1 = 99; int var2 = 99; if (var1 == var2) { CPPUNIT_FAIL("var1 and var2 matched - should not be equal in this case!!"); } }
/* * Test should fail because an exception was expected, but none occurred. The failure message * will also include the action that was underway (and should have caused an exception). */ void failTestMissingException(const char *expectedException, const char* action) { char buffer[4096]; sprintf(buffer, "(missingException) Expected an exception (%s) while %s", expectedException, action); CPPUNIT_FAIL(buffer); }
FdoInt32 UnitTestUtil::CompareFiles( const char* file1Name, const char* file2Name ) { char buffer[500]; char buffer1[5000]; char buffer2[5000]; FdoInt32 retcode = -1; FILE* fp1 = fopen( file1Name, "r" ); FILE* fp2 = fopen( file2Name, "r" ); if ( fp1 == NULL ) { sprintf( buffer, "UnitTestUtil::CompareFiles: failed to open file %s", file1Name ); CPPUNIT_FAIL (buffer); } if ( fp2 == NULL ) { fclose(fp1); sprintf( buffer, "UnitTestUtil::CompareFiles: failed to open file %s", file2Name ); CPPUNIT_FAIL (buffer); } while ( fgets( buffer1, sizeof(buffer1-1), fp1 ) != NULL ) { if ( !fgets( buffer2, sizeof(buffer2-1), fp2 ) ) // different: file2 has fewer lines. goto the_exit; if ( strcmp( buffer1, buffer2 ) ) // different: a line is different goto the_exit; } if ( fgets( buffer2, sizeof(buffer2-1), fp2 ) ) // different: file2 has more lines. goto the_exit; retcode = 0; the_exit: fclose(fp1); fclose(fp2); return( retcode ); }
/* Test insert/update/select (but not setting/getting any lock info) on a table that supports locking. */ void BasicUpdateTests::update_on_lock_enabled_table () { if (CreateSchemaOnly()) return; try { mConnection = ArcSDETests::GetConnection (); mConnection->SetConnectionString (ArcSDETestConfig::ConnStringMetadcov()); mConnection->Open (); // Clean up previous tests: CleanUpClass(mConnection, ArcSDETestConfig::ClassSchemaSample(), ArcSDETestConfig::ClassNameSample(), true); FdoPtr<FdoIInsert> insert = (FdoIInsert*)mConnection->CreateCommand (FdoCommandType_Insert); insert->SetFeatureClassName (ArcSDETestConfig::QClassNameSample()); FdoPtr<FdoPropertyValueCollection> values = insert->GetPropertyValues (); FdoPtr<FdoStringValue> expression = FdoStringValue::Create (L"Zozo"); FdoPtr<FdoPropertyValue> value = FdoPropertyValue::Create (AdjustRdbmsName(L"LockProperty"), expression); values->Add (value); FdoPtr<FdoIFeatureReader> reader = insert->Execute (); FdoInt32 newId = 0; if (reader->ReadNext()) newId = reader->GetInt32(AdjustRdbmsName(L"Id")); FdoPtr<FdoIUpdate> update = (FdoIUpdate*)mConnection->CreateCommand (FdoCommandType_Update); update->SetFeatureClassName (ArcSDETestConfig::QClassNameSample()); wchar_t filter[1024]; FdoCommonOSUtil::swprintf(filter, ELEMENTS(filter), L"%ls = %d", AdjustRdbmsName(L"Id"), newId); update->SetFilter (FdoPtr<FdoFilter>(FdoFilter::Parse (filter))); values = update->GetPropertyValues (); value = FdoPropertyValue::Create (); value->SetName (AdjustRdbmsName(L"LockProperty")); value->SetValue (L"'All mimsy were the borogoves'"); values->Add (value); if (1 != update->Execute ()) CPPUNIT_FAIL ("update execute failed"); // check by doing a select FdoPtr<FdoISelect> select = (FdoISelect*)mConnection->CreateCommand (FdoCommandType_Select); select->SetFeatureClassName (ArcSDETestConfig::QClassNameSample()); reader = select->Execute (); while (reader->ReadNext ()) { CPPUNIT_ASSERT_MESSAGE ("incorrect value", 0 == wcscmp (L"All mimsy were the borogoves", reader->GetString (AdjustRdbmsName(L"LockProperty")))); } reader->Close(); // Clean up after test: CleanUpClass(mConnection, ArcSDETestConfig::ClassSchemaTestClassSimple(), ArcSDETestConfig::ClassNameSample(), true); mConnection->Close(); } catch (FdoException* ge) { fail (ge); } }
void requestPing(const std::wstring& /*message*/) { switch(mMode) { case CMultiPingPongTest::DoubleResponse: responsePong(L"Hi"); responsePong(L"Hi"); break; case CMultiPingPongTest::DoubleResponseError: sendError(PingPongTest::UPD_ID_responsePong); sendError(PingPongTest::UPD_ID_responsePong); break; case CMultiPingPongTest::DoubleRequestError: sendError(PingPongTest::UPD_ID_requestPing); sendError(PingPongTest::UPD_ID_requestPing); break; case CMultiPingPongTest::ResponseAndResponseError: responsePong(L"Hi"); sendError(PingPongTest::UPD_ID_responsePong); break; case CMultiPingPongTest::ResponseErrorAndResponse: sendError(PingPongTest::UPD_ID_responsePong); responsePong(L"Hi"); break; case CMultiPingPongTest::ResponseAndRequestError: responsePong(L"Hi"); sendError(PingPongTest::UPD_ID_requestPing); break; case CMultiPingPongTest::RequestErrorAndResponse: sendError(PingPongTest::UPD_ID_requestPing); responsePong(L"Hi"); break; case CMultiPingPongTest::ResponseErrorAndRequestError: sendError(PingPongTest::UPD_ID_responsePong); sendError(PingPongTest::UPD_ID_requestPing); break; case CMultiPingPongTest::RequestErrorAndResponseError: sendError(PingPongTest::UPD_ID_requestPing); sendError(PingPongTest::UPD_ID_responsePong); break; default: CPPUNIT_FAIL("Unknown mode"); break; } engine()->remove(*this); }
void TestThreadExceptionHaveCorrectThreadID() { SCXCoreLib::SCXHandle<SCXCoreLib::SCXThread> thread = GivenARunningThread(); try { thread->Start(SCXThreadTest::SimpleThreadBodyTerminate); CPPUNIT_FAIL("Expected exception not thrown: SCXThreadStartException"); } catch (SCXCoreLib::SCXThreadStartException& e) { CPPUNIT_ASSERT_EQUAL(SCXCoreLib::SCXThread::GetCurrentThreadID(), e.GetThreadID()); } }
void TestMoXie::CompareFrameElement(const Vector3& expected, const Vector3& actual, const char* message, Int32 frame, Int32 dimension, double precision) { if (fabs(actual[dimension]-expected[dimension]) > precision) { char failmessage[256]; sprintf(failmessage, "%s frame %u dimension %u: expected %lf got %lf (precision required %lf)", message, frame, dimension, expected[dimension], actual[dimension], precision); CPPUNIT_FAIL(failmessage); } }
void CInfiniteMediatorTest::testSkipNone() { tearDown(); // This should have no effect on any default behavior // We will simply test this as the TransparentMainLoop m_mediator = new CInfiniteMediator(0,0,0); m_mediator->setSkipCount(0); std::string proto("file://"); std::string infname("./run-0000-00.evt"); std::string outfname("./copy-run-0000-00.evt"); try { URL uri(proto+infname); m_source = new CFileDataSource(uri, std::vector<uint16_t>()); m_sink = new CFileDataSink(outfname); m_mediator->setDataSource(m_source); m_mediator->setDataSink(m_sink); m_mediator->setFilter(new CTransparentFilter); 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()); } CPPUNIT_ASSERT( filesEqual(infname,outfname) ); remove(outfname.c_str()); }
virtual void Stat( const SCXCoreLib::SCXFilePath & path, SCXCoreLib::SCXFileSystem::SCXStatStruct * pStat) { // warnings as errors, so deal with the unused params (void) path; (void) pStat; CPPUNIT_FAIL("The SCXLVMUtils external dependency Stat is not implemented for this test."); }
/** * Create a new instance of ServoControllerDummy and * set it to the private variable */ void dashee::test::ServoUART::setUp() { this->fd = open("/dev/ttyAMA0", O_RDWR | O_NOCTTY); if (this->fd == -1) CPPUNIT_FAIL("Cannot open file!"); struct termios options; tcgetattr(this->fd, &options); cfsetispeed(&options, B230400); cfsetospeed(&options, B230400); options.c_cflag &= ~PARENB; options.c_cflag &= ~CSTOPB; options.c_cflag &= ~CSIZE; options.c_cflag |= CS8; // no flow control options.c_cflag &= ~CRTSCTS; options.c_cflag |= CREAD | CLOCAL; // turn on READ & ignore ctrl lines options.c_iflag &= ~(IXON | IXOFF | IXANY); // turn off s/w flow ctrl options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); // make raw options.c_oflag &= ~OPOST; // make raw // see: http://unixwiz.net/techtips/termios-vmin-vtime.html options.c_cc[VMIN] = 0; options.c_cc[VTIME] = 10; if (tcsetattr(this->fd, TCSANOW, &options) < 0) CPPUNIT_FAIL("Initilizing UART failed"); // Reset the GPIO pin dashee::GPIO gpio(18, dashee::GPIO::OUT); gpio.low(); gpio.high(); // Important dashee::sleep(10000); this->servo = new dashee::ServoUART(&this->fd, 2); }