Esempio n. 1
0
 /**
  * Basic ctor.
  */
 void testBasicCtor()
   {
   TS_TRACE("Brush basic ctor");
   Brush b;
   TS_ASSERT_EQUALS(b.IsDefined(), false);
   TS_ASSERT_EQUALS(b.IsHollow(), true);
   }
Esempio n. 2
0
TestObject::~TestObject()
{
    constructed_ = false;
    --objectCount_;
    TS_TRACE((std::string("Destructing object, count = ") +
        std::to_string(objectCount_)).c_str());
}
Esempio n. 3
0
 /**
  * Basic ctor.
  */
 void testBasicCtor()
   {
   int argc = 0;
   TS_TRACE("Font basic ctor");
   QApplication app(argc, (char **)nullptr, 0); // Necessary to run up a Font.
   Font f;
   TS_ASSERT_EQUALS(f.IsDefined(), false);
   }
Esempio n. 4
0
 /**
  * Basic ctor.
  */
 void testBasicCtor()
   {
   TS_TRACE("Pen basic ctor");
   Pen p;
   TS_ASSERT_EQUALS(p.GetWidth(), 1);
   TS_ASSERT_EQUALS(p.GetColor().Red(), 0);
   TS_ASSERT_EQUALS(p.GetColor().Green(), 0);
   TS_ASSERT_EQUALS(p.GetColor().Blue(), 0);
   TS_ASSERT_EQUALS(p.GetStyle(), Pen::SOLID);
   }
Esempio n. 5
0
 /**
  * Basic ctor.
  */
 void testBasicCtor()
   {
   int argc = 0;
   TS_TRACE("Canvas basic ctor");
   QApplication app(argc, (char **)nullptr, 0); // Necessary to run up a Canvas.
   Canvas c;
   TS_ASSERT_EQUALS(c.IsDefined(), true);
   TS_ASSERT_EQUALS(c.GetWidth(), 0);
   TS_ASSERT_EQUALS(c.GetHeight(), 0);
   }
Esempio n. 6
0
	void testSize() {
		TS_TRACE(std::string("sizeof(float) is ") + std::to_string(sizeof(float)));
		TS_TRACE(std::string("sizeof(vec2) is ") + std::to_string(sizeof(glam::vec2)));
		TS_TRACE(std::string("sizeof(vec4) is ") + std::to_string(sizeof(glam::vec4)));
		TS_TRACE(std::string("sizeof(bool) is ") + std::to_string(sizeof(bool)));
		TS_TRACE(std::string("sizeof(bvec4) is ") + std::to_string(sizeof(glam::bvec4)));
		TS_TRACE(std::string("sizeof(int) is ") + std::to_string(sizeof(int)));
		TS_TRACE(std::string("sizeof(ivec2) is ") + std::to_string(sizeof(glam::ivec2)));
		TS_TRACE(std::string("sizeof(double) is ") + std::to_string(sizeof(double)));
		TS_TRACE(std::string("sizeof(dvec3) is ") + std::to_string(sizeof(glam::dvec3)));
		// A vectorized implementation may pad to up to 4 vector elements to improve SIMD performance, but not more
		TS_ASSERT_LESS_THAN_EQUALS(sizeof(glam::Vector<float, 4>), sizeof(float) * 4);
		TS_ASSERT_LESS_THAN_EQUALS(sizeof(glam::Vector<double, 2>), sizeof(double) * 4);
		TS_ASSERT_LESS_THAN_EQUALS(sizeof(glam::Vector<bool, 4>), sizeof(bool) * 4);
		TS_ASSERT_LESS_THAN_EQUALS(sizeof(glam::Vector<int, 256>), sizeof(int) * 256);
	}
 void TestBi3dSmall() throw(Exception)
 {
     if (PetscTools::GetNumProcs() > 3u)
     {
         TS_TRACE("This test is not suitable for more than 3 processes.");
         return;
     }
    CardiacSimulation simulation("heart/test/data/xml/bidomain3d_small.xml");
     //Check that archive which has just been produced can be read
     CardiacSimulation simulation2("heart/test/data/xml/bidomain3d_resume.xml");
 }
 void TestMonoStimUsingEllipsoids() throw(Exception)
 {
     if (PetscTools::GetNumProcs() > 3u)
     {
         TS_TRACE("This test is not suitable for more than 3 processes.");
         return;
     }
     // Fox2002BackwardEuler cell model
     CardiacSimulation simulation("heart/test/data/xml/monodomain1d_stim_using_ellipsoid.xml", true);
     TS_ASSERT( CompareFilesViaHdf5DataReader("heart/test/data/cardiac_simulations", "monodomain1d_stim_using_ellipsoid", false,
                                              "Mono1DStimUsingEllipsoid", "SimulationResults", true, 1e-6));
 }
Esempio n. 9
0
 /**
  * Test a keyhole.
  */
 void notestKeyhole()
   {
   TS_TRACE("Canvas DrawKeyhole");
   int argc = 0;
   QApplication app(argc, (char **)nullptr, 0);
   Canvas c;
   Pen(Pen::SOLID, 1, Color(0, 0, 0));
   Brush(Color(128, 128, 0));
   c.DrawKeyhole(0, 0, 10, 20, Angle::Degrees(-10), Angle::Degrees(10));
   c.show();
   app.exec();
   }
Esempio n. 10
0
TestObject::TestObject()
    : byte_(static_cast<std::uint8_t>(rand())),
      dword_(static_cast<std::uint32_t>(rand())),
      word_(static_cast<std::int16_t>(rand())),
      long_(static_cast<std::int64_t>(rand()) * rand()),
      floatPart_(new FloatPart),
      constructed_(true)
{
    ++objectCount_;
    TS_TRACE((std::string("Created new object, count = ") +
        std::to_string(objectCount_)).c_str());
}
Esempio n. 11
0
TestObject::TestObject(const TestObject& obj)
    : byte_(obj.byte_),
      dword_(obj.dword_),
      word_(obj.word_),
      long_(obj.long_),
      floatPart_(new FloatPart(*obj.floatPart_)),
      constructed_(true)
{
    assert(obj.constructed_);
    ++copyConstructCount_;
    ++objectCount_;
    TS_TRACE((std::string("Copy constructing object, count = ") +
        std::to_string(objectCount_)).c_str());
}
Esempio n. 12
0
TestObject::TestObject(TestObject&& obj)
    : byte_(obj.byte_),
      dword_(obj.dword_),
      word_(obj.word_),
      long_(obj.long_),
      floatPart_(std::move(obj.floatPart_)),
      constructed_(true)
{
    assert(obj.constructed_);
    ++moveConstructCount_;
    ++objectCount_;
    TS_TRACE((std::string("Move constructing object, count = ") +
        std::to_string(objectCount_)).c_str());
}
 void TestBi1dSmall() throw(Exception)
 {
     if (PetscTools::GetNumProcs() > 3u)
     {
         TS_TRACE("This test is not suitable for more than 3 processes.");
         return;
     }
     { CardiacSimulation simulation("heart/test/data/xml/bidomain1d_small.xml"); }
     { CardiacSimulation simulation2("heart/test/data/xml/bidomain1d_resume.xml"); }
     {
         // The default resume file specifies a simulation duration of zero.
         // In reality the user should edit the file to specify something sensible...
         FileFinder resume_xml("SaveBi1D_checkpoints/0.1ms/ResumeParameters.xml", RelativeTo::ChasteTestOutput);
         TS_ASSERT_THROWS_THIS(CardiacSimulation simulation(resume_xml.GetAbsolutePath()),
                               "The simulation duration must be positive, not -0.1");
     }
 }
    void TestMono2dSmall() throw(Exception)
    {
        if (PetscTools::GetNumProcs() > 3u)
        {
            TS_TRACE("This test is not suitable for more than 3 processes.");
            return;
        }
        //Clear any warnings from previous tests
        Warnings::QuietDestroy();
        {
            CardiacSimulation simulation("heart/test/data/xml/monodomain2d_small.xml", false, true);
            boost::shared_ptr<AbstractUntemplatedCardiacProblem> p_problem = simulation.GetSavedProblem();
            TS_ASSERT(p_problem);
            MonodomainProblem<2,2>* p_mono_problem = dynamic_cast<MonodomainProblem<2,2>*>(p_problem.get());
            TS_ASSERT(p_mono_problem != NULL);
            DistributedVectorFactory* p_vector_factory = p_mono_problem->rGetMesh().GetDistributedVectorFactory();
            for (unsigned node_global_index = p_vector_factory->GetLow();
                 node_global_index < p_vector_factory->GetHigh();
                 node_global_index++)
            {
                AbstractCardiacCellInterface* p_cell = p_mono_problem->GetTissue()->GetCardiacCell(node_global_index);
                TS_ASSERT_DELTA(p_cell->GetParameter("membrane_fast_sodium_current_conductance"), 23 * 0.99937539038101175, 1e-6);
                TS_ASSERT_DELTA(p_cell->GetParameter("membrane_rapid_delayed_rectifier_potassium_current_conductance"), 0.282/3.0, 1e-6);
            }

            if (p_vector_factory->GetLocalOwnership() > 0)
            {
                TS_ASSERT_EQUALS(Warnings::Instance()->GetNumWarnings(), p_vector_factory->GetLocalOwnership());
                std::stringstream msg;
                msg << "Cannot apply drug to cell at node " << p_vector_factory->GetLow() << " as it has no parameter named 'not_a_current_conductance'.";
                TS_ASSERT_EQUALS(Warnings::Instance()->GetNextWarningMessage(), msg.str());
            }
            else
            {
                //There is now a warning on the top processes about the fact that no cells were assigned
                TS_ASSERT_EQUALS(Warnings::Instance()->GetNumWarnings(), 1u);
                std::stringstream msg;
                msg << "No cells were assigned to process "<< PetscTools::GetMyRank();
                msg << " in AbstractCardiacTissue constructor. Advice: Make total number of processors no greater than number of nodes in the mesh";
                TS_ASSERT_EQUALS(Warnings::Instance()->GetNextWarningMessage(), msg.str());
            }
        }
        //Check that archive which has just been produced can be read
        CardiacSimulation simulation2("heart/test/data/xml/monodomain2d_resume.xml");
        Warnings::QuietDestroy();
    }
Esempio n. 15
0
void msgHandler(IEC61162::Alarm msg,void *param) {
    AISAlarm_Test *caller = static_cast<AISAlarm_Test *>(param);
    if (caller) {
        // check the decoded message's content against the references data
        const struct AISAlarm_Data *test_data = caller->currentMsg;
        char buffer[255];
        sprintf(buffer,"checking message %s...\n",test_data->rawMsg);
        TS_TRACE(buffer);
        const time_t ref = getTime(test_data->hour,test_data->minutes,test_data->seconds);
        TS_ASSERT_EQUALS(msg->get_timeOfAlarmCondictionChange(),ref);
        TS_ASSERT_EQUALS(msg->get_id(),test_data->id);
        TS_ASSERT_EQUALS(msg->get_condition(),test_data->condition);
        TS_ASSERT_EQUALS(msg->get_state(),test_data->state);
        TS_ASSERT_EQUALS(msg->get_description(),test_data->description);
    } else {
        TS_FAIL("caller parameter is NULL");
    }
}
    void TestMono1dSmall() throw(Exception)
    {
        if (PetscTools::GetNumProcs() > 3u)
        {
            TS_TRACE("This test is not suitable for more than 3 processes.");
            return;
        }
        // Fox2002BackwardEuler cell model
        CardiacSimulation simulation("heart/test/data/xml/monodomain1d_small.xml", true);
        TS_ASSERT( CompareFilesViaHdf5DataReader("heart/test/data/cardiac_simulations", "mono_1d_small", false,
                                                 "SaveMono1D", "SimulationResults", true, 1e-6));

        /* If the above fails, and you are happy the new results are correct, uncomment the following line,
         * run the test, and then do
         cp /tmp/$USER/testoutput/SaveMono1D/SimulationResults.h5 heart/test/data/cardiac_simulations/mono_1d_small.h5
         */
        //assert(0);

        CardiacSimulation simulation2("heart/test/data/xml/monodomain1d_resume.xml", true);
    }
Esempio n. 17
0
    // Solve with a space step of 0.5mm.
    //
    // Note that this space step ought to be too big!
    //
    // NOTE: This test uses NON-PHYSIOLOGICAL parameters values (conductivities,
    // surface-area-to-volume ratio, capacitance, stimulus amplitude). Essentially,
    // the equations have been divided through by the surface-area-to-volume ratio.
    // (Historical reasons...)
    void TestMonodomainFailing()
    {
        if (PetscTools::GetNumProcs() > 3u)
        {
            TS_TRACE("This test is not suitable for more than 3 processes.");
            return;
        }
        HeartConfig::Instance()->SetIntracellularConductivities(Create_c_vector(0.0005));
        HeartConfig::Instance()->SetSimulationDuration(1); //ms
//        HeartConfig::Instance()->SetMeshFileName("mesh/test/data/1D_0_to_1_20_elements");
//        HeartConfig::Instance()->SetSpaceDimension(1);
//        HeartConfig::Instance()->SetFibreLength(1.0, 1.0/20.0);
        HeartConfig::Instance()->SetSpaceDimension(3);
        HeartConfig::Instance()->SetSlabDimensions(0.2, 0.1, 0.1, 0.05);
        HeartConfig::Instance()->SetOutputDirectory("MonoFailing");
        HeartConfig::Instance()->SetOutputFilenamePrefix("MonodomainLR91_SVI");
        HeartConfig::Instance()->SetUseStateVariableInterpolation(true);

        PlaneStimulusCellFactory<CellLuoRudy1991FromCellML, 3> cell_factory;
        MonodomainProblem<3> monodomain_problem(&cell_factory);

        monodomain_problem.Initialise();

        HeartConfig::Instance()->SetSurfaceAreaToVolumeRatio(1.0);
//        HeartConfig::Instance()->SetCapacitance(1.0);

        // the mesh is too coarse, and this simulation will result in cell gating
        // variables going out of range. An exception should be thrown in the
        // EvaluateYDerivatives() method of the cell model


        TS_ASSERT_THROWS_CONTAINS(monodomain_problem.Solve(),
#ifndef NDEBUG
            // VerifyStateVariables is only called when debug is on
            "State variable fast_sodium_current_m_gate__m has gone out of range. "
            "Check numerical parameters, for example time and space stepsizes");
#else
            // This test hits a later assert(!isnan) if we do a ndebug build.
            "Assertion tripped: !std::isnan(i_ionic)");
#endif // NDEBUG
    }
Esempio n. 18
0
 /**
  * Basic set / get.
  */
 void testBasicSetGet()
   {
   TS_TRACE("Pen basic set get");
   Pen p;
   
   for (int i = 0; i < 10000; i++)
     {
     Pen::Style penmap[3] = {Pen::SOLID, Pen::DASH, Pen::BLANK};
     uint8_t refr, refg, refb;
     refr = rand();
     refg = rand();
     refb = rand();
     Color refc(refr, refg, refb);
     unsigned refw = lrand48();
     Pen::Style refs = penmap[rand() % sizeof(penmap)];
     Pen p(refs, refw, refc);
     TS_ASSERT_EQUALS(p.GetWidth(), refw);
     Color rc = p.GetColor();
     TS_ASSERT_EQUALS(rc.Red(), refr);
     TS_ASSERT_EQUALS(rc.Green(), refg);
     TS_ASSERT_EQUALS(rc.Blue(), refb);
     TS_ASSERT_EQUALS(p.GetStyle(), refs);
     }
   }