Exemple #1
0
 void MatrixWrapperTest::testAt()
 {
     MatrixImpl matrix(3, 2, Matrix::INT_32);
     
     CPPUNIT_ASSERT_NO_THROW(matrix.at<int32_t>(0, 1) = 42);
     CPPUNIT_ASSERT_EQUAL((int32_t)(42), const_cast<const MatrixImpl &>(matrix).at<int32_t>(0,1));
 }
void newtestclass::testAplusb_out_of_range_NO_THROW_03() {
    int a = 100;
    int b = 1;
    APlusB aPlusB;

    CPPUNIT_ASSERT_NO_THROW(aPlusB.aplusb(a, b));
}
Exemple #3
0
    void
    StamperTest::stamp()
    {
	// test if stamping works
	StamperTestCommand stamp;
	stamp.magic.postPaid = false;
	stamper->setStamp(stamp);
	wns::ldk::CompoundPtr compound;
	CPPUNIT_ASSERT_NO_THROW(compound = sendCompound(newFakeCompound()));
	CPPUNIT_ASSERT_EQUAL((unsigned int)1, compoundsSent());
	StamperTestCommand* command = stamper->getCommand(compound->getCommandPool());
	CPPUNIT_ASSERT(!command->magic.postPaid);

	// test if Stamper uses its own instance to stamp
	stamp.magic.postPaid = true;
	compound = sendCompound(newFakeCompound());
	CPPUNIT_ASSERT_EQUAL((unsigned int)2, compoundsSent());
	command = stamper->getCommand(compound->getCommandPool());
	CPPUNIT_ASSERT(!command->magic.postPaid);

	// test if updating the stamp works
	stamper->setStamp(stamp);
	compound = sendCompound(newFakeCompound());
	CPPUNIT_ASSERT_EQUAL((unsigned int)3, compoundsSent());
	command = stamper->getCommand(compound->getCommandPool());
	CPPUNIT_ASSERT(command->magic.postPaid);
    }
void xRinexEphemerisStore :: BCESfindNearTest (void)
{
	ofstream DumpData;
	DumpData.open ("Logs/findNearTest.txt");

	gpstk::Rinex3EphemerisStore Store;
        int nr;
	nr = Store.loadFile("TestRinex06.031");

        std::list<gpstk::Rinex3NavData> R3NList;
        gpstk::GPSEphemerisStore GStore;
        list<gpstk::Rinex3NavData>::const_iterator it;
        Store.addToList(R3NList);
        for (it = R3NList.begin(); it != R3NList.end(); ++it)
          GStore.addEphemeris(gpstk::EngEphemeris(*it));

	gpstk::CivilTime Time(2006,1,31,13,0,1,2);
        const gpstk::CommonTime ComTime = (gpstk::CommonTime)Time;

	short PRN0 = 0;
	short PRN1 = 1;
	short PRN15 = 15;
	short PRN32 = 32;
	short PRN33 = 33;
   gpstk::SatID sid0(PRN0,gpstk::SatID::systemGPS);
   gpstk::SatID sid1(PRN1,gpstk::SatID::systemGPS);
   gpstk::SatID sid15(PRN15,gpstk::SatID::systemGPS);
   gpstk::SatID sid32(PRN32,gpstk::SatID::systemGPS);
   gpstk::SatID sid33(PRN33,gpstk::SatID::systemGPS);

	try
	{
		CPPUNIT_ASSERT_THROW(GStore.findNearEphemeris(sid0,ComTime),gpstk::InvalidRequest);
		CPPUNIT_ASSERT_THROW(GStore.findNearEphemeris(sid33,ComTime),gpstk::InvalidRequest);
		CPPUNIT_ASSERT_THROW(GStore.findNearEphemeris(sid1,gpstk::CommonTime::END_OF_TIME),
					gpstk::InvalidRequest);

		CPPUNIT_ASSERT_NO_THROW(GStore.findNearEphemeris(sid1, ComTime));

		const gpstk::EngEphemeris Eph1 = GStore.findNearEphemeris(sid1, ComTime);
		const gpstk::EngEphemeris Eph15 = GStore.findNearEphemeris(sid15, ComTime);
		const gpstk::EngEphemeris Eph32 = GStore.findNearEphemeris(sid32, ComTime);

		GStore.clear();

		GStore.addEphemeris(Eph1);
		GStore.addEphemeris(Eph15);
		GStore.addEphemeris(Eph32);

		GStore.dump(DumpData,1);

	}
	catch (gpstk::Exception& e)
	{
                e.addLocation(FILE_LOCATION);
		cout << e;
	}
	CPPUNIT_ASSERT(fileEqualTest((char*)"Logs/findNearTest.txt",(char*)"Checks/findNearTest.chk"));
}
/**
 * @details
 * Try to create a PipelineApplication with a configuration file name.
 * Expect no exceptions.
 */
void PipelineApplicationTest::test_commandLine_config()
{
    int argc = 2;
    char *argv[] = {(char*)"pelican", (char*)"--config=settings.xml"};

    QCoreApplication app(argc, argv);
    CPPUNIT_ASSERT_NO_THROW(PipelineApplication(argc, argv));
}
/**
 * @details
 * Try to create a PipelineApplication with --help on the command line.
 * Expect no exceptions.
 */
void PipelineApplicationTest::test_commandLine_help()
{
    int argc = 2;
    char *argv[] = {(char*)"pelican", (char*)"--help"};

    QCoreApplication app(argc, argv);
    CPPUNIT_ASSERT_NO_THROW(PipelineApplication(argc, argv));
}
/**
 * @details
 * Try to create a PipelineApplication after a QCoreApplication.
 * Expect no exceptions.
 */
void PipelineApplicationTest::test_create_afterQCoreApplication()
{
    int argc = 1;
    char *argv[] = {(char*)"pelican"};

    QCoreApplication app(argc, argv);
    CPPUNIT_ASSERT_NO_THROW(PipelineApplication(argc, argv));
}
 void callConstantMethodInBaseClass_usesConstantInstance_noException()
 {
     DerivesToUseConstMethod instance;
     DerivesToUseConstMethod const* const_instance = &instance;
     OOLUA::register_class<DerivesToUseConstMethod>(*m_lua);
     m_lua->run_chunk("return function(obj) obj:cpp_func_const() end");
     CPPUNIT_ASSERT_NO_THROW(m_lua->call(1, const_instance));
 }
void TriangleTestFixture::predicateTesting()
{
	// Shouldn't throw an error, unless <= predicate was flipped
	CPPUNIT_ASSERT_NO_THROW(predicate1 = std::make_unique<Triangle>(3, 4, 5));

	// Should throw an error, unless an || was flipped
	CPPUNIT_ASSERT_THROW(predicate2 = std::make_unique<Triangle>(1, 1, 3), NotTriangleException);
}
Exemple #10
0
void 
TestAssertTest::testAssertNoThrow()
{
   int x;
   CPPUNIT_ASSERT_NO_THROW( x = 1234 );
   (void)x;

   try
   {
      CPPUNIT_ASSERT_NO_THROW( throw std::exception() );
   }
   catch ( CPPUNIT_NS::Exception & )
   {
      return;
   }
   throw std::exception();
}
void ImageReaderWriterTest::testImageWriterExtension()
{
    // Data to write
    const size_t dim = 3;
    ::fwTools::Type type("uint8");
    ::fwData::Image::SizeType sizeExpected(dim);
    sizeExpected[0] = 10;
    sizeExpected[1] = 20;
    sizeExpected[2] = 30;
    ::fwData::Image::SpacingType spacingExpected(dim);
    spacingExpected[0] = 0.24;
    spacingExpected[1] = 1.07;
    spacingExpected[2] = 2.21;
    ::fwData::Image::OriginType originExpected(dim);
    originExpected[0] = -05.6;
    originExpected[1] = 15.16;
    originExpected[2] = 11.11;

    ::fwData::Image::sptr image = ::fwData::Image::New();
    ::fwTest::generator::Image::generateImage(image, sizeExpected, spacingExpected, originExpected, type);

    // Write to vtk image.
    const ::boost::filesystem::path file = ::fwTools::System::getTemporaryFolder()/ "temporaryFile.xxx";


    {
        const std::string srvtype("::io::IWriter");
        const std::string srvname("::ioVTK::ImageWriterService");


        ::fwServices::IService::sptr srv;
        srv = ::fwServices::registry::ServiceFactory::getDefault()->create( srvtype, srvname );

        CPPUNIT_ASSERT_MESSAGE(std::string("Failed to create service ") + srvname, srv);

        ::fwServices::OSR::registerService( image , srv );

        CPPUNIT_ASSERT_NO_THROW( srv->setConfiguration(getIOConfiguration(file)) );
        CPPUNIT_ASSERT_NO_THROW( srv->configure() );
        CPPUNIT_ASSERT_NO_THROW( srv->start() );
        CPPUNIT_ASSERT_THROW( srv->update(), ::fwTools::Failed);
        CPPUNIT_ASSERT_NO_THROW( srv->stop() );
        ::fwServices::OSR::unregisterService( srv );
    }
}
  void GetImageStatisticsNoRules() {
    auto statisticsNode = mitk::CreateImageStatisticsNode(m_statisticsContainer, "testStatistics");
    auto standaloneDataStorage = mitk::StandaloneDataStorage::New();
    standaloneDataStorage->Add(statisticsNode);

    //no rules + 1 image --> test return nullptr
    mitk::ImageStatisticsContainer::ConstPointer emptyStatistic;
    CPPUNIT_ASSERT_NO_THROW(emptyStatistic = mitk::ImageStatisticsContainerManager::GetImageStatistics(standaloneDataStorage.GetPointer(), m_image.GetPointer()));
    CPPUNIT_ASSERT_EQUAL(emptyStatistic.IsNull(), true);

    //no rules + 1 image + 1 mask --> test return nullptr
    CPPUNIT_ASSERT_NO_THROW(emptyStatistic = mitk::ImageStatisticsContainerManager::GetImageStatistics(standaloneDataStorage.GetPointer(), m_image.GetPointer(), m_mask.GetPointer()));
    CPPUNIT_ASSERT_EQUAL(emptyStatistic.IsNull(), true);

    //no rules + 1 image + 1 planarFigure --> test return nullptr
    CPPUNIT_ASSERT_NO_THROW(emptyStatistic = mitk::ImageStatisticsContainerManager::GetImageStatistics(standaloneDataStorage.GetPointer(), m_image.GetPointer(), m_planarFigure.GetPointer()));
    CPPUNIT_ASSERT_EQUAL(emptyStatistic.IsNull(), true);
  }
Exemple #13
0
    void TestAssign(void)
    {
        SCXCoreLib::SCXFilePath fp = *m_path;

        // Check may assign to itself.
        CPPUNIT_ASSERT_NO_THROW(*m_path = *m_path);
        // Check content after assign operation is equal.
        CPPUNIT_ASSERT(fp.Get() == m_path->Get());
    }
 void TestNoConsumers()
 {
     SCXCoreLib::SCXLogMediatorSimple mediator;
     CPPUNIT_ASSERT_NO_THROW(mediator.LogThisItem(SCXCoreLib::SCXLogItem(L"scxcore.something",
                                                                         SCXCoreLib::eHysterical,
                                                                         L"cowabunga",
                                                                         SCXSRCLOCATION,
                                                                         0)));
 }
 void ImageWrapperTest::testResizeLength()
 {
     m_image = new ImageImpl();
     CPPUNIT_ASSERT_NO_THROW(m_image->resize(300, 200, runtime::Image::BGR_24));
     CPPUNIT_ASSERT_EQUAL((unsigned int)(300), m_image->width());
     CPPUNIT_ASSERT_EQUAL((unsigned int)(200), m_image->height());
     CPPUNIT_ASSERT_EQUAL(runtime::Image::BGR_24, m_image->pixelType());
     CPPUNIT_ASSERT_EQUAL(runtime::Variant::BGR_24_IMAGE, m_image->variant());
 }
  void GetImageStatisticsWithImageConnected()
  {
    //create rules connection
    auto statisticsNode = mitk::CreateImageStatisticsNode(m_statisticsContainer, "testStatistics");
    CreateNodeRelationImage(m_statisticsContainer.GetPointer(), m_image.GetPointer());
    auto standaloneDataStorage = mitk::StandaloneDataStorage::New();
    standaloneDataStorage->Add(statisticsNode);

    //rule: (image-->statistics), 1 connected image --> test return image statistics
    mitk::ImageStatisticsContainer::ConstPointer statisticsWithImage;
    CPPUNIT_ASSERT_NO_THROW(statisticsWithImage = mitk::ImageStatisticsContainerManager::GetImageStatistics(standaloneDataStorage.GetPointer(), m_image.GetPointer()));
    CPPUNIT_ASSERT_EQUAL(statisticsWithImage->GetUID(), m_statisticsContainer->GetUID());

    //new rule: (image2-->statistics2 AND mask --> statistics2)
    CreateNodeRelationImage(m_statisticsContainer2.GetPointer(), m_image2.GetPointer());
    CreateNodeRelationMask(m_statisticsContainer2.GetPointer(), m_mask.GetPointer());

    auto statisticsNode2 = mitk::CreateImageStatisticsNode(m_statisticsContainer2, "testStatistics2");
    standaloneDataStorage->Add(statisticsNode2);

    //--> test return (still) image statistics (!= statistics2)
    mitk::ImageStatisticsContainer::ConstPointer statisticsWithImageAgain;
    CPPUNIT_ASSERT_NO_THROW(statisticsWithImageAgain = mitk::ImageStatisticsContainerManager::GetImageStatistics(standaloneDataStorage.GetPointer(), m_image.GetPointer()));
    CPPUNIT_ASSERT_EQUAL(statisticsWithImageAgain->GetUID(), m_statisticsContainer->GetUID());
    CPPUNIT_ASSERT_EQUAL(statisticsWithImageAgain->GetUID() != m_statisticsContainer2->GetUID(), true);

    //--> test return image statistics 2
    CPPUNIT_ASSERT_NO_THROW(statisticsWithImageAgain = mitk::ImageStatisticsContainerManager::GetImageStatistics(standaloneDataStorage.GetPointer(), m_image2.GetPointer(), m_mask.GetPointer()));
    CPPUNIT_ASSERT_EQUAL(statisticsWithImageAgain->GetUID(), m_statisticsContainer2->GetUID());
    CPPUNIT_ASSERT_EQUAL(statisticsWithImageAgain->GetUID() != m_statisticsContainer->GetUID(), true);

    //add another newer statistic: should return this newer one
    auto statisticsContainerNew = mitk::ImageStatisticsContainer::New();
    CreateNodeRelationImage(statisticsContainerNew.GetPointer(), m_image.GetPointer());

    auto statisticsNodeNew = mitk::CreateImageStatisticsNode(statisticsContainerNew, "testStatisticsNew");
    standaloneDataStorage->Add(statisticsNodeNew);
    statisticsContainerNew->Modified();

    mitk::ImageStatisticsContainer::ConstPointer statisticsWithImageNew;
    CPPUNIT_ASSERT_NO_THROW(statisticsWithImageNew = mitk::ImageStatisticsContainerManager::GetImageStatistics(standaloneDataStorage.GetPointer(), m_image.GetPointer()));
    CPPUNIT_ASSERT_EQUAL(statisticsWithImageNew->GetUID(), statisticsContainerNew->GetUID());
    CPPUNIT_ASSERT_EQUAL(statisticsWithImageNew->GetUID() != m_statisticsContainer->GetUID(), true);
  }
void RecTestCase::TestContactList()
{
    recContactList record1;
    record1.FSetID( 0 );
    record1.FSetIndID( 3 );  // Doesn't exist so will cause an exception on Save()
#if ALLOW_SQL_MEMORY_LEAK
    // id = 0 so create new record and set id to new value.
    CPPUNIT_ASSERT_THROW( record1.Save(), wxSQLite3Exception );
#endif
    recIndividual ind(0);
    ind.FSetID(3);
    CPPUNIT_ASSERT_NO_THROW( ind.Save() );
    CPPUNIT_ASSERT_NO_THROW( record1.Save() );
    idt id = record1.FGetID();
    CPPUNIT_ASSERT( id > 0 );

    recContactList record2;
    record2.FSetID( record1.FGetID() );
    CPPUNIT_ASSERT_NO_THROW( record2.Read() );
    CPPUNIT_ASSERT( record1 == record2 );

    record1.FSetIndID( 0 );
    // id exists, so amend record leaving id to old value.
    CPPUNIT_ASSERT_NO_THROW( record1.Save() );
    CPPUNIT_ASSERT( record1.f_id == id );
    CPPUNIT_ASSERT_NO_THROW( record2.Read() );
    CPPUNIT_ASSERT( record1 == record2 );

    record1.FSetID( 999 );
    record1.FSetIndID( 3 );
    // id = 999 which doesn't exists, so create new record with no change to id.
    CPPUNIT_ASSERT_NO_THROW( record1.Save() );
    CPPUNIT_ASSERT( record1.FGetID() == 999 );
    record2.FSetID( record1.FGetID() );
    CPPUNIT_ASSERT_NO_THROW( record2.Read() );
    CPPUNIT_ASSERT( record1 == record2 );

    record1.FSetID( 0 );
    record1.FSetIndID( 0 );
    CPPUNIT_ASSERT_NO_THROW( record1.Save() );
    CPPUNIT_ASSERT( record1.FGetID() != 0 );
    CPPUNIT_ASSERT( record1.Exists() == true );
    CPPUNIT_ASSERT_NO_THROW( record1.Delete() );
    CPPUNIT_ASSERT( record1.Exists() == false );

    CPPUNIT_ASSERT( recContactList::Exists( 999 ) == true );
    recContactList::Delete( 999 );
    CPPUNIT_ASSERT( recContactList::Exists( 999 ) == false );
}
Exemple #18
0
void SerialTest::SetDataBits() {
	Serial *serial = NULL;
	unsigned int data_bits[] = { 5, 6, 7, 8, 0};

	// create serial object
	CPPUNIT_ASSERT_NO_THROW(serial = new Serial("/dev/ttyS1"));

	// perform data bit setting tests
	for (unsigned int i=0; data_bits[i]!=0; i++) {
		CPPUNIT_ASSERT_NO_THROW(serial->SetDataBits(data_bits[i]));
		CPPUNIT_ASSERT_EQUAL(data_bits[i], serial->DataBits());
	}

	CPPUNIT_ASSERT_THROW(serial->SetDataBits(100), std::runtime_error);

	// destroy serial object
	delete serial;
	CPPUNIT_ASSERT(signal_catcher.StringSignalsReceived(0));
}
void IWAFieldTest::testRepeated()
{
  IWAUInt64Field field;
  CPPUNIT_ASSERT_NO_THROW(field.parse(makeStream(BYTES("\x1\x4\x8")), 3));
  const uint64_t expected[] = {1, 4, 8};
  const std::deque<uint64_t> &values = field.repeated();
  CPPUNIT_ASSERT_EQUAL(ETONYEK_NUM_ELEMENTS(expected), values.size());
  CPPUNIT_ASSERT(std::equal(values.begin(), values.end(), expected));
  CPPUNIT_ASSERT(std::equal(field.begin(), field.end(), expected));
}
 void ImageWrapperTest::testResizeDimension()
 {
     m_image = new ImageImpl();
     CPPUNIT_ASSERT_NO_THROW(m_image->resize(1024));
     CPPUNIT_ASSERT_EQUAL((unsigned int)(1024), m_image->bufferSize());
     CPPUNIT_ASSERT_EQUAL((unsigned int)(1024), m_image->width());
     CPPUNIT_ASSERT_EQUAL((unsigned int)(1), m_image->height());
     CPPUNIT_ASSERT_EQUAL(runtime::Image::NONE, m_image->pixelType());
     CPPUNIT_ASSERT_EQUAL(runtime::Variant::IMAGE, m_image->variant());
 }       
Exemple #21
0
/*
****Test to assess the quality of the SigmaYX member of the TwoSampleStats
****class which is designed to return the conditional uncertainty of y given x
*/
void xStats :: sigmayxTest (void)
{
	gpstk::TwoSampleStats<double> sigmayxTest;
	CPPUNIT_ASSERT_NO_THROW(sigmayxTest.SigmaYX());
	CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,sigmayxTest.SigmaYX(),1e-6);
	sigmayxTest.Add(0.,0.);
	sigmayxTest.Add(10.,10.);
	sigmayxTest.Add(20.,20.);
	CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,sigmayxTest.SigmaYX(),1e-6);
}
Exemple #22
0
/*
****Test to assess the quality of the Correlation member of the TwoSampleStats
****class which is designed to return the correlation between X and Y
*/
void xStats :: correlationTest (void)
{
	gpstk::TwoSampleStats<double> correlationTest;
	CPPUNIT_ASSERT_NO_THROW(correlationTest.Correlation());
	CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,correlationTest.Correlation(),1e-6);
	correlationTest.Add(0.,0.);
	correlationTest.Add(10.,10.);
	correlationTest.Add(20.,20.);
	CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,correlationTest.Correlation(),1e-6);
}
Exemple #23
0
        void MatrixWrapperTest::testSerializeEmpty()
        {
            m_matrix = new MatrixImpl(0, 100, Matrix::INT_8);

            runtime::DirectoryFileOutput output(".");
            output.initialize("MatrixTest_testSerializeEmpty");
            
            CPPUNIT_ASSERT_NO_THROW(m_matrix->serialize(output));
            CPPUNIT_ASSERT_EQUAL(std::string(""), output.getText());
        }
Exemple #24
0
 void MatrixWrapperTest::testResizeLength()
 {
     m_matrix = new MatrixImpl();
     CPPUNIT_ASSERT_NO_THROW(m_matrix->resize(300, 200, runtime::Matrix::FLOAT_32));
     CPPUNIT_ASSERT_EQUAL((unsigned int)(300), m_matrix->rows());
     CPPUNIT_ASSERT_EQUAL((unsigned int)(200), m_matrix->cols());
     CPPUNIT_ASSERT(m_matrix->data());
     CPPUNIT_ASSERT_EQUAL(runtime::Matrix::FLOAT_32, m_matrix->valueType());
     CPPUNIT_ASSERT_EQUAL(runtime::Variant::FLOAT_32_MATRIX, m_matrix->variant());
 }
Exemple #25
0
void Point3DTest::testComplexMultiplications() {
    Point3D resultPoint;
    resultPoint = (*point111) * (maxCoordValue);
    CPPUNIT_ASSERT_DOUBLES_EQUAL(maxCoordValue, resultPoint.getX(), maxTolerance);
    CPPUNIT_ASSERT_DOUBLES_EQUAL(maxCoordValue, resultPoint.getY(), maxTolerance);
    CPPUNIT_ASSERT_DOUBLES_EQUAL(maxCoordValue, resultPoint.getZ(), maxTolerance);

    resultPoint = (*point111) * (minCoordValue);
    CPPUNIT_ASSERT_DOUBLES_EQUAL(minCoordValue, resultPoint.getX(), maxTolerance);
    CPPUNIT_ASSERT_DOUBLES_EQUAL(minCoordValue, resultPoint.getY(), maxTolerance);
    CPPUNIT_ASSERT_DOUBLES_EQUAL(minCoordValue, resultPoint.getZ(), maxTolerance);

    /* check limits */
    CPPUNIT_ASSERT_NO_THROW((resultPoint = (*pointMax) * (1.0) ));
    CPPUNIT_ASSERT_NO_THROW((resultPoint = (*pointMin) * (1.0) ));
    CPPUNIT_ASSERT_THROW((resultPoint = (*pointMax) * (2.0) ), runtime_error);
    CPPUNIT_ASSERT_THROW((resultPoint = (*pointMin) * (2.0) ), runtime_error);

}
Exemple #26
0
        void MatrixWrapperTest::testSerializeUInt8()
        {
            m_matrix = new MatrixImpl(20, 10, Matrix::UINT_8);
            memset(m_matrix->data(), 0, m_matrix->rows() * m_matrix->stride());

            runtime::DirectoryFileOutput output(".");
            output.initialize("MatrixTest_testSerializeUInt8");
            
            CPPUNIT_ASSERT_NO_THROW(m_matrix->serialize(output));
            CPPUNIT_ASSERT_EQUAL(std::string(""), output.getText());
        }
Exemple #27
0
 void Id2DataMapTest::testSet()
 {
     DataContainer in(new UInt8());
     m_inputMap->set(0, in);
     
     DataContainer out;
     CPPUNIT_ASSERT_NO_THROW(out = m_inputMap->get(0));
     CPPUNIT_ASSERT_EQUAL(in, out);
     
     CPPUNIT_ASSERT_THROW(m_inputMap->set(10, in), WrongId);
 }
Exemple #28
0
	void cppMethodCall_passTwoInstancesTwice_noException()
	{
		m_lua->run_chunk(\
				"foo = function(o1,o2,o3,o4)\n"
					"o3:a()\n"
					"o4:b()\n"
				"end");
		A a;
		B b;
		CPPUNIT_ASSERT_NO_THROW( m_lua->call("foo",&a,&b,&a,&b) );
	}
Exemple #29
0
 void MatrixWrapperTest::testDeserializeEmpty()
 {
     m_matrix = new MatrixImpl();
     
     runtime::DirectoryFileInput input(".");
     input.initialize("", "empty_float_matrix.npy");
     CPPUNIT_ASSERT_NO_THROW(m_matrix->deserialize(input, VERSION));
     CPPUNIT_ASSERT_EQUAL((unsigned int)(100), m_matrix->rows());
     CPPUNIT_ASSERT_EQUAL((unsigned int)(0), m_matrix->cols());
     CPPUNIT_ASSERT_EQUAL(Matrix::FLOAT_32, m_matrix->valueType());
 }
Exemple #30
0
void V2ToV3Test::applyPatchTest()
{
    ::fwAtoms::Object::sptr camObjV2 = ::fwAtoms::Object::New();
    ::fwAtoms::Object::sptr camObjV3;

    ::fwAtomsPatch::helper::setClassname(camObjV2, "::arData::Camera");
    ::fwAtomsPatch::helper::setVersion(camObjV2, "2");

    ::fwAtomsPatch::helper::Object helper(camObjV2);

    helper.addAttribute("camera_id", ::fwAtoms::String::New("file"));
    helper.addAttribute("description", ::fwAtoms::String::New("Videos/myVideo.mp4"));
    ::fwAtoms::Sequence::sptr intrinsicParam = ::fwAtoms::Sequence::New();
    intrinsicParam->push_back(::fwAtoms::Numeric::New(2596.78));
    intrinsicParam->push_back(::fwAtoms::Numeric::New(2554.72));
    intrinsicParam->push_back(::fwAtoms::Numeric::New(1020.74));
    intrinsicParam->push_back(::fwAtoms::Numeric::New(500.189));
    helper.addAttribute("intrinsic", intrinsicParam);
    helper.addAttribute("width", ::fwAtoms::Numeric::New(1920));
    helper.addAttribute("height", ::fwAtoms::Numeric::New(1080));
    helper.addAttribute("camera_source", ::fwAtoms::String::New("FILE"));
    helper.addAttribute("video_file", ::fwAtoms::String::New("Videos/myVideo.mp4"));
    helper.addAttribute("stream_url", ::fwAtoms::String::New(""));
    helper.addAttribute("max_framerate", ::fwAtoms::String::New("30"));
    helper.addAttribute("pixel_format", ::fwAtoms::String::New("RGBA32"));

    camObjV3 = ::fwAtoms::Object::dynamicCast(camObjV2->clone());

    ::fwAtomsPatch::IPatch::NewVersionsType newVersions;
    newVersions[camObjV2] = camObjV3;

    auto patch = ::arStructuralPatch::arData::Camera::V2ToV3::New();
    CPPUNIT_ASSERT_NO_THROW(patch->apply(camObjV2, camObjV3, newVersions));

    CPPUNIT_ASSERT(camObjV3);
    CPPUNIT_ASSERT(camObjV3->getAttribute("width"));
    ::fwAtoms::Sequence::sptr intrinsicParam2 = ::fwAtoms::Sequence::dynamicCast(camObjV2->getAttribute("intrinsic"));
    CPPUNIT_ASSERT_EQUAL(size_t(4), intrinsicParam2->size());
    CPPUNIT_ASSERT_EQUAL(std::string("1920"), camObjV3->getAttribute("width")->getString());
    CPPUNIT_ASSERT(camObjV3->getAttribute("height"));
    CPPUNIT_ASSERT_EQUAL(std::string("1080"), camObjV3->getAttribute("height")->getString());
    CPPUNIT_ASSERT(camObjV3->getAttribute("max_framerate"));
    CPPUNIT_ASSERT_EQUAL(std::string("30"), camObjV3->getAttribute("max_framerate")->getString());
    CPPUNIT_ASSERT(camObjV3->getAttribute("video_file"));
    CPPUNIT_ASSERT_EQUAL(std::string("Videos/myVideo.mp4"), camObjV3->getAttribute("video_file")->getString());
    CPPUNIT_ASSERT(camObjV3->getAttribute("stream_url"));
    CPPUNIT_ASSERT(camObjV3->getAttribute("stream_url")->getString().empty());
    CPPUNIT_ASSERT(camObjV3->getAttribute("camera_source"));
    CPPUNIT_ASSERT_EQUAL(std::string("FILE"), camObjV3->getAttribute("camera_source")->getString());
    CPPUNIT_ASSERT(camObjV3->getAttribute("pixel_format"));
    CPPUNIT_ASSERT_EQUAL(std::string("RGBA32"), camObjV3->getAttribute("pixel_format")->getString());
    CPPUNIT_ASSERT(camObjV3->getAttribute("scale"));
    CPPUNIT_ASSERT_EQUAL(std::string("1"), camObjV3->getAttribute("scale")->getString());
}