COPASI API  4.16.103
Public Member Functions | Static Protected Attributes | Private Member Functions | List of all members
test000064 Class Reference

#include <test000064.h>

Inheritance diagram for test000064:
Inheritance graph
[legend]
Collaboration diagram for test000064:
Collaboration graph
[legend]

Public Member Functions

void setUp ()
 
void tearDown ()
 
void test_export_event_assignment_expression_and_hasOnlySubstanceUnits_1 ()
 
void test_export_event_assignment_expression_and_hasOnlySubstanceUnits_2 ()
 
void test_export_event_assignment_expression_and_hasOnlySubstanceUnits_3 ()
 
void test_export_event_assignment_expression_and_hasOnlySubstanceUnits_4 ()
 
void test_export_event_assignment_expression_and_hasOnlySubstanceUnits_5 ()
 
void test_export_event_assignment_expression_and_hasOnlySubstanceUnits_6 ()
 
void test_export_event_assignment_expression_and_hasOnlySubstanceUnits_7 ()
 
void test_export_event_assignment_expression_and_hasOnlySubstanceUnits_8 ()
 
void test_export_rule_expression_and_hasOnlySubstanceUnits_1 ()
 
void test_export_rule_expression_and_hasOnlySubstanceUnits_2 ()
 
void test_export_rule_expression_and_hasOnlySubstanceUnits_3 ()
 
void test_export_rule_expression_and_hasOnlySubstanceUnits_4 ()
 
void test_export_rule_expression_and_hasOnlySubstanceUnits_5 ()
 
void test_export_rule_expression_and_hasOnlySubstanceUnits_6 ()
 
void test_export_rule_expression_and_hasOnlySubstanceUnits_7 ()
 
void test_export_rule_expression_and_hasOnlySubstanceUnits_8 ()
 
void test_import_event_assignment_expression_and_hasOnlySubstanceUnits_1 ()
 
void test_import_event_assignment_expression_and_hasOnlySubstanceUnits_2 ()
 
void test_import_event_assignment_expression_and_hasOnlySubstanceUnits_3 ()
 
void test_import_event_assignment_expression_and_hasOnlySubstanceUnits_4 ()
 
void test_import_event_assignment_expression_and_hasOnlySubstanceUnits_5 ()
 
void test_import_event_assignment_expression_and_hasOnlySubstanceUnits_6 ()
 
void test_import_event_assignment_expression_and_hasOnlySubstanceUnits_7 ()
 
void test_import_event_assignment_expression_and_hasOnlySubstanceUnits_8 ()
 
void test_import_rule_expression_and_hasOnlySubstanceUnits_1 ()
 
void test_import_rule_expression_and_hasOnlySubstanceUnits_2 ()
 
void test_import_rule_expression_and_hasOnlySubstanceUnits_3 ()
 
void test_import_rule_expression_and_hasOnlySubstanceUnits_4 ()
 
void test_import_rule_expression_and_hasOnlySubstanceUnits_5 ()
 
void test_import_rule_expression_and_hasOnlySubstanceUnits_6 ()
 
void test_import_rule_expression_and_hasOnlySubstanceUnits_7 ()
 
void test_import_rule_expression_and_hasOnlySubstanceUnits_8 ()
 

Static Protected Attributes

static const char * MODEL_STRING1
 
static const char * MODEL_STRING10
 
static const char * MODEL_STRING101
 
static const char * MODEL_STRING102
 
static const char * MODEL_STRING103
 
static const char * MODEL_STRING104
 
static const char * MODEL_STRING105
 
static const char * MODEL_STRING106
 
static const char * MODEL_STRING107
 
static const char * MODEL_STRING108
 
static const char * MODEL_STRING109
 
static const char * MODEL_STRING11
 
static const char * MODEL_STRING110
 
static const char * MODEL_STRING111
 
static const char * MODEL_STRING112
 
static const char * MODEL_STRING113
 
static const char * MODEL_STRING114
 
static const char * MODEL_STRING115
 
static const char * MODEL_STRING116
 
static const char * MODEL_STRING12
 
static const char * MODEL_STRING13
 
static const char * MODEL_STRING14
 
static const char * MODEL_STRING15
 
static const char * MODEL_STRING16
 
static const char * MODEL_STRING2
 
static const char * MODEL_STRING3
 
static const char * MODEL_STRING4
 
static const char * MODEL_STRING5
 
static const char * MODEL_STRING6
 
static const char * MODEL_STRING7
 
static const char * MODEL_STRING8
 
static const char * MODEL_STRING9
 
static CCopasiDataModelpCOPASIDATAMODEL = NULL
 

Private Member Functions

 CPPUNIT_TEST (test_import_rule_expression_and_hasOnlySubstanceUnits_1)
 
 CPPUNIT_TEST (test_import_rule_expression_and_hasOnlySubstanceUnits_2)
 
 CPPUNIT_TEST (test_import_rule_expression_and_hasOnlySubstanceUnits_3)
 
 CPPUNIT_TEST (test_import_rule_expression_and_hasOnlySubstanceUnits_4)
 
 CPPUNIT_TEST (test_import_rule_expression_and_hasOnlySubstanceUnits_5)
 
 CPPUNIT_TEST (test_import_rule_expression_and_hasOnlySubstanceUnits_6)
 
 CPPUNIT_TEST (test_import_rule_expression_and_hasOnlySubstanceUnits_7)
 
 CPPUNIT_TEST (test_import_rule_expression_and_hasOnlySubstanceUnits_8)
 
 CPPUNIT_TEST (test_import_event_assignment_expression_and_hasOnlySubstanceUnits_1)
 
 CPPUNIT_TEST (test_import_event_assignment_expression_and_hasOnlySubstanceUnits_2)
 
 CPPUNIT_TEST (test_import_event_assignment_expression_and_hasOnlySubstanceUnits_3)
 
 CPPUNIT_TEST (test_import_event_assignment_expression_and_hasOnlySubstanceUnits_4)
 
 CPPUNIT_TEST (test_import_event_assignment_expression_and_hasOnlySubstanceUnits_5)
 
 CPPUNIT_TEST (test_import_event_assignment_expression_and_hasOnlySubstanceUnits_6)
 
 CPPUNIT_TEST (test_import_event_assignment_expression_and_hasOnlySubstanceUnits_7)
 
 CPPUNIT_TEST (test_import_event_assignment_expression_and_hasOnlySubstanceUnits_8)
 
 CPPUNIT_TEST (test_export_rule_expression_and_hasOnlySubstanceUnits_1)
 
 CPPUNIT_TEST (test_export_rule_expression_and_hasOnlySubstanceUnits_2)
 
 CPPUNIT_TEST (test_export_rule_expression_and_hasOnlySubstanceUnits_3)
 
 CPPUNIT_TEST (test_export_rule_expression_and_hasOnlySubstanceUnits_4)
 
 CPPUNIT_TEST (test_export_rule_expression_and_hasOnlySubstanceUnits_5)
 
 CPPUNIT_TEST (test_export_rule_expression_and_hasOnlySubstanceUnits_6)
 
 CPPUNIT_TEST (test_export_rule_expression_and_hasOnlySubstanceUnits_7)
 
 CPPUNIT_TEST (test_export_rule_expression_and_hasOnlySubstanceUnits_8)
 
 CPPUNIT_TEST (test_export_event_assignment_expression_and_hasOnlySubstanceUnits_1)
 
 CPPUNIT_TEST (test_export_event_assignment_expression_and_hasOnlySubstanceUnits_2)
 
 CPPUNIT_TEST (test_export_event_assignment_expression_and_hasOnlySubstanceUnits_3)
 
 CPPUNIT_TEST (test_export_event_assignment_expression_and_hasOnlySubstanceUnits_4)
 
 CPPUNIT_TEST (test_export_event_assignment_expression_and_hasOnlySubstanceUnits_5)
 
 CPPUNIT_TEST (test_export_event_assignment_expression_and_hasOnlySubstanceUnits_6)
 
 CPPUNIT_TEST (test_export_event_assignment_expression_and_hasOnlySubstanceUnits_7)
 
 CPPUNIT_TEST (test_export_event_assignment_expression_and_hasOnlySubstanceUnits_8)
 
 CPPUNIT_TEST_SUITE (test000064)
 
 CPPUNIT_TEST_SUITE_END ()
 

Detailed Description

Definition at line 24 of file test000064.h.

Member Function Documentation

test000064::CPPUNIT_TEST ( test_import_rule_expression_and_hasOnlySubstanceUnits_1  )
private
test000064::CPPUNIT_TEST ( test_import_rule_expression_and_hasOnlySubstanceUnits_2  )
private
test000064::CPPUNIT_TEST ( test_import_rule_expression_and_hasOnlySubstanceUnits_3  )
private
test000064::CPPUNIT_TEST ( test_import_rule_expression_and_hasOnlySubstanceUnits_4  )
private
test000064::CPPUNIT_TEST ( test_import_rule_expression_and_hasOnlySubstanceUnits_5  )
private
test000064::CPPUNIT_TEST ( test_import_rule_expression_and_hasOnlySubstanceUnits_6  )
private
test000064::CPPUNIT_TEST ( test_import_rule_expression_and_hasOnlySubstanceUnits_7  )
private
test000064::CPPUNIT_TEST ( test_import_rule_expression_and_hasOnlySubstanceUnits_8  )
private
test000064::CPPUNIT_TEST ( test_export_rule_expression_and_hasOnlySubstanceUnits_1  )
private
test000064::CPPUNIT_TEST ( test_export_rule_expression_and_hasOnlySubstanceUnits_2  )
private
test000064::CPPUNIT_TEST ( test_export_rule_expression_and_hasOnlySubstanceUnits_3  )
private
test000064::CPPUNIT_TEST ( test_export_rule_expression_and_hasOnlySubstanceUnits_4  )
private
test000064::CPPUNIT_TEST ( test_export_rule_expression_and_hasOnlySubstanceUnits_5  )
private
test000064::CPPUNIT_TEST ( test_export_rule_expression_and_hasOnlySubstanceUnits_6  )
private
test000064::CPPUNIT_TEST ( test_export_rule_expression_and_hasOnlySubstanceUnits_7  )
private
test000064::CPPUNIT_TEST ( test_export_rule_expression_and_hasOnlySubstanceUnits_8  )
private
test000064::CPPUNIT_TEST_SUITE ( test000064  )
private
test000064::CPPUNIT_TEST_SUITE_END ( )
private
void test000064::setUp ( )

Definition at line 56 of file test000064.cpp.

References CCopasiRootContainer::addDatamodel(), CCopasiRootContainer::init(), and pCOPASIDATAMODEL.

57 {
58  // Create the root container.
59  CCopasiRootContainer::init(0, NULL, false);
60  // Create the global data model.
62 }
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000064.h:98
static CCopasiDataModel * addDatamodel()
static void init(int argc, char *argv[], const bool &withGui=false)
void test000064::tearDown ( )

Definition at line 64 of file test000064.cpp.

References CCopasiRootContainer::destroy().

void test000064::test_export_event_assignment_expression_and_hasOnlySubstanceUnits_1 ( )

Definition at line 3108 of file test000064.cpp.

References CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CCopasiDataModel::getModel(), load_cps_model_from_stream(), MODEL_STRING109, and pCOPASIDATAMODEL.

3109 {
3110  // load the CPS file
3111  // export to SBML
3112  // check the resulting SBML model
3113  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
3114  std::istringstream iss(test000064::MODEL_STRING109);
3115  bool result = load_cps_model_from_stream(iss, *pDataModel);
3116  CPPUNIT_ASSERT(result == true);
3117  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
3118  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 3).empty() == false);
3119  SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
3120  CPPUNIT_ASSERT(pDocument != NULL);
3121  Model* pModel = pDocument->getModel();
3122  CPPUNIT_ASSERT(pModel != NULL);
3123  // check the units
3124  UnitDefinition* pUDef = pModel->getUnitDefinition("time");
3125  Unit* pUnit = NULL;
3126 
3127  // since second is the default time unit, it does not have to be exported and
3128  // might be NULL
3129  if (pUDef != NULL)
3130  {
3131  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
3132  pUnit = pUDef->getUnit(0);
3133  CPPUNIT_ASSERT(pUnit != NULL);
3134  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_SECOND);
3135  CPPUNIT_ASSERT(pUnit->getScale() == 0);
3136  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
3137  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
3138  }
3139 
3140  pUDef = pModel->getUnitDefinition("substance");
3141  CPPUNIT_ASSERT(pUDef != NULL);
3142  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
3143  pUnit = pUDef->getUnit(0);
3144  CPPUNIT_ASSERT(pUnit != NULL);
3145  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_MOLE);
3146  CPPUNIT_ASSERT(pUnit->getScale() == -3);
3147  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
3148  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
3149  pUDef = pModel->getUnitDefinition("volume");
3150  CPPUNIT_ASSERT(pUDef != NULL);
3151  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
3152  pUnit = pUDef->getUnit(0);
3153  CPPUNIT_ASSERT(pUnit != NULL);
3154  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_LITRE);
3155  CPPUNIT_ASSERT(pUnit->getScale() == -3);
3156  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
3157  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
3158  // assert that there is only one compartment and
3159  // assert the compartment is constant
3160  CPPUNIT_ASSERT(pModel->getNumCompartments() == 1);
3161  Compartment* pCompartment = pModel->getCompartment(0);
3162  CPPUNIT_ASSERT(pCompartment->getConstant() == true);
3163  CPPUNIT_ASSERT(pModel->getNumParameters() == 1);
3164  Parameter* pParameter1 = pModel->getParameter(0);
3165  CPPUNIT_ASSERT(pParameter1 != NULL);
3166  CPPUNIT_ASSERT(pParameter1->getName() == "K");
3167  CPPUNIT_ASSERT(pModel->getNumSpecies() == 2);
3168  Species* pSpecies1 = pModel->getSpecies(0);
3169  CPPUNIT_ASSERT(pSpecies1->getHasOnlySubstanceUnits() == false);
3170  CPPUNIT_ASSERT(pSpecies1->getName() == "A");
3171  Species* pSpecies2 = pModel->getSpecies(1);
3172  CPPUNIT_ASSERT(pSpecies2->getHasOnlySubstanceUnits() == false);
3173  CPPUNIT_ASSERT(pSpecies2->getName() == "B");
3174  CPPUNIT_ASSERT(pModel->getNumRules() == 0);
3175  CPPUNIT_ASSERT(pModel->getNumReactions() == 0);
3176  CPPUNIT_ASSERT(pModel->getNumEvents() == 1);
3177  Event* pEvent = pModel->getEvent(0);
3178  CPPUNIT_ASSERT(pEvent != NULL);
3179  // check the trigger
3180  CPPUNIT_ASSERT(pEvent->isSetTrigger());
3181  Trigger* pTrigger = pEvent->getTrigger();
3182  CPPUNIT_ASSERT(pTrigger != NULL);
3183  CPPUNIT_ASSERT(pTrigger->isSetMath());
3184  const ASTNode* pMath = pTrigger->getMath();
3185  CPPUNIT_ASSERT(pMath != NULL);
3186  CPPUNIT_ASSERT(pMath->getType() == AST_RELATIONAL_GT);
3187  CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
3188  const ASTNode* pChild = pMath->getChild(0);
3189  CPPUNIT_ASSERT(pChild != NULL);
3190  CPPUNIT_ASSERT(pChild->getType() == AST_NAME_TIME);
3191  pChild = pMath->getChild(1);
3192  CPPUNIT_ASSERT(pChild != NULL);
3193  CPPUNIT_ASSERT(pChild->getType() == AST_REAL);
3194  CPPUNIT_ASSERT(fabs((pChild->getReal() - 2.0) / 2.0) < 1e-6);
3195  // check the delay
3196  CPPUNIT_ASSERT(pEvent->isSetDelay());
3197  Delay* pDelay = pEvent->getDelay();
3198  CPPUNIT_ASSERT(pDelay != NULL);
3199  CPPUNIT_ASSERT(pDelay->isSetMath());
3200  pMath = pDelay->getMath();
3201  CPPUNIT_ASSERT(pMath != NULL);
3202  CPPUNIT_ASSERT(pMath->getType() == AST_REAL);
3203  CPPUNIT_ASSERT(fabs((pMath->getReal() - 4.0) / 4.0) < 1e-6);
3204  // check the event asssignment
3205  CPPUNIT_ASSERT(pEvent->getNumEventAssignments() == 1);
3206  EventAssignment* pEA = pEvent->getEventAssignment(0);
3207  CPPUNIT_ASSERT(pEA != NULL);
3208  CPPUNIT_ASSERT(pEA->getVariable() == pSpecies1->getId());
3209  pMath = pEA->getMath();
3210  CPPUNIT_ASSERT(pMath != NULL);
3211  // make sure the mathematical expression contains only one node that is a
3212  // reference to the global parameter
3213  CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
3214  CPPUNIT_ASSERT(pMath->getName() == pParameter1->getId());
3215 }
SBMLDocument * getCurrentSBMLDocument()
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
static const char * MODEL_STRING109
Definition: test000064.h:89
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000064.h:98
void test000064::test_export_event_assignment_expression_and_hasOnlySubstanceUnits_2 ( )

Definition at line 3274 of file test000064.cpp.

References CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CCopasiDataModel::getModel(), load_cps_model_from_stream(), MODEL_STRING110, and pCOPASIDATAMODEL.

3275 {
3276  // load the CPS file
3277  // export to SBML
3278  // check the resulting SBML model
3279  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
3280  std::istringstream iss(test000064::MODEL_STRING110);
3281  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
3282  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
3283  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 3).empty() == false);
3284  SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
3285  CPPUNIT_ASSERT(pDocument != NULL);
3286  Model* pModel = pDocument->getModel();
3287  CPPUNIT_ASSERT(pModel != NULL);
3288  // check the units
3289  UnitDefinition* pUDef = pModel->getUnitDefinition("time");
3290  Unit* pUnit = NULL;
3291 
3292  // since second is the default time unit, it does not have to be exported and
3293  // might be NULL
3294  if (pUDef != NULL)
3295  {
3296  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
3297  pUnit = pUDef->getUnit(0);
3298  CPPUNIT_ASSERT(pUnit != NULL);
3299  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_SECOND);
3300  CPPUNIT_ASSERT(pUnit->getScale() == 0);
3301  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
3302  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
3303  }
3304 
3305  pUDef = pModel->getUnitDefinition("substance");
3306  CPPUNIT_ASSERT(pUDef != NULL);
3307  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
3308  pUnit = pUDef->getUnit(0);
3309  CPPUNIT_ASSERT(pUnit != NULL);
3310  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_MOLE);
3311  CPPUNIT_ASSERT(pUnit->getScale() == -3);
3312  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
3313  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
3314  pUDef = pModel->getUnitDefinition("volume");
3315  CPPUNIT_ASSERT(pUDef != NULL);
3316  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
3317  pUnit = pUDef->getUnit(0);
3318  CPPUNIT_ASSERT(pUnit != NULL);
3319  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_LITRE);
3320  CPPUNIT_ASSERT(pUnit->getScale() == -3);
3321  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
3322  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
3323  // assert that there is only one compartment and
3324  // assert the compartment is constant
3325  CPPUNIT_ASSERT(pModel->getNumCompartments() == 1);
3326  Compartment* pCompartment = pModel->getCompartment(0);
3327  CPPUNIT_ASSERT(pCompartment->getConstant() == false);
3328  CPPUNIT_ASSERT(pModel->getNumParameters() == 2);
3329  Parameter* pParameter1 = pModel->getParameter(0);
3330  CPPUNIT_ASSERT(pParameter1 != NULL);
3331  Parameter* pParameter2 = NULL;
3332 
3333  if (pParameter1->getName() == "K")
3334  {
3335  pParameter2 = pModel->getParameter(1);
3336  }
3337  else
3338  {
3339  pParameter2 = pParameter1;
3340  pParameter1 = pModel->getParameter(1);
3341  }
3342 
3343  CPPUNIT_ASSERT(pParameter2 != NULL);
3344  CPPUNIT_ASSERT(pParameter1->getName() == "K");
3345  CPPUNIT_ASSERT(pParameter2->getName() == "P");
3346  CPPUNIT_ASSERT(pModel->getNumSpecies() == 2);
3347  Species* pSpecies1 = pModel->getSpecies(0);
3348  CPPUNIT_ASSERT(pSpecies1->getHasOnlySubstanceUnits() == true);
3349  std::string idSpeciesA = pSpecies1->getId();
3350  Species* pSpecies2 = pModel->getSpecies(1);
3351  CPPUNIT_ASSERT(pSpecies2->getHasOnlySubstanceUnits() == true);
3352  CPPUNIT_ASSERT(pModel->getNumRules() == 1);
3353  Rule* pRule = pModel->getRule(0);
3354  CPPUNIT_ASSERT(pRule != NULL);
3355  CPPUNIT_ASSERT(pRule->getVariable() == pCompartment->getId());
3356  CPPUNIT_ASSERT(pRule->isSetMath() == true);
3357  const ASTNode* pMath = pRule->getMath();
3358  CPPUNIT_ASSERT(pMath != NULL);
3359  CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
3360  CPPUNIT_ASSERT(pMath->getName() == pParameter2->getId());
3361  CPPUNIT_ASSERT(pModel->getNumReactions() == 0);
3362  CPPUNIT_ASSERT(pModel->getNumEvents() == 1);
3363  Event* pEvent = pModel->getEvent(0);
3364  CPPUNIT_ASSERT(pEvent != NULL);
3365  // check the trigger
3366  CPPUNIT_ASSERT(pEvent->isSetTrigger());
3367  Trigger* pTrigger = pEvent->getTrigger();
3368  CPPUNIT_ASSERT(pTrigger != NULL);
3369  CPPUNIT_ASSERT(pTrigger->isSetMath());
3370  pMath = pTrigger->getMath();
3371  CPPUNIT_ASSERT(pMath != NULL);
3372  CPPUNIT_ASSERT(pMath->getType() == AST_RELATIONAL_GT);
3373  CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
3374  ASTNode* pChild = pMath->getChild(0);
3375  CPPUNIT_ASSERT(pChild != NULL);
3376  CPPUNIT_ASSERT(pChild->getType() == AST_NAME_TIME);
3377  pChild = pMath->getChild(1);
3378  CPPUNIT_ASSERT(pChild != NULL);
3379  CPPUNIT_ASSERT(pChild->getType() == AST_REAL);
3380  CPPUNIT_ASSERT(fabs((pChild->getReal() - 2.0) / 2.0) < 1e-6);
3381  // check the delay
3382  CPPUNIT_ASSERT(pEvent->isSetDelay());
3383  Delay* pDelay = pEvent->getDelay();
3384  CPPUNIT_ASSERT(pDelay != NULL);
3385  CPPUNIT_ASSERT(pDelay->isSetMath());
3386  pMath = pDelay->getMath();
3387  CPPUNIT_ASSERT(pMath != NULL);
3388  CPPUNIT_ASSERT(pMath->getType() == AST_REAL);
3389  CPPUNIT_ASSERT(fabs((pMath->getReal() - 4.0) / 4.0) < 1e-6);
3390  // check the event asssignment
3391  CPPUNIT_ASSERT(pEvent->getNumEventAssignments() == 1);
3392  EventAssignment* pEA = pEvent->getEventAssignment(0);
3393  CPPUNIT_ASSERT(pEA != NULL);
3394  CPPUNIT_ASSERT(pEA->getVariable() == pSpecies1->getId());
3395  pMath = pEA->getMath();
3396  CPPUNIT_ASSERT(pMath != NULL);
3397  // make sure the mathematical expression contains only one node that is a
3398  // reference to the global parameter multiplied by the compartment volume
3399  CPPUNIT_ASSERT(pMath->getType() == AST_TIMES);
3400  CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
3401  ASTNode* pChild1 = pMath->getChild(0);
3402  CPPUNIT_ASSERT(pChild1 != NULL);
3403  CPPUNIT_ASSERT(pChild1->getType() == AST_NAME);
3404  ASTNode* pChild2 = pMath->getChild(1);
3405  CPPUNIT_ASSERT(pChild2 != NULL);
3406  CPPUNIT_ASSERT(pChild2->getType() == AST_NAME);
3407  CPPUNIT_ASSERT(pChild1->getName() == pParameter1->getId() || pChild2->getName() == pParameter1->getId());
3408  CPPUNIT_ASSERT(pChild1->getName() == pCompartment->getId() || pChild2->getName() == pCompartment->getId());
3409 }
SBMLDocument * getCurrentSBMLDocument()
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000064.h:98
static const char * MODEL_STRING110
Definition: test000064.h:90
void test000064::test_export_event_assignment_expression_and_hasOnlySubstanceUnits_3 ( )

Definition at line 3473 of file test000064.cpp.

References CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CCopasiDataModel::getModel(), load_cps_model_from_stream(), MODEL_STRING111, and pCOPASIDATAMODEL.

3474 {
3475  // load the CPS file
3476  // export to SBML
3477  // check the resulting SBML model
3478  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
3479  std::istringstream iss(test000064::MODEL_STRING111);
3480  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
3481  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
3482  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 3).empty() == false);
3483  SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
3484  CPPUNIT_ASSERT(pDocument != NULL);
3485  Model* pModel = pDocument->getModel();
3486  CPPUNIT_ASSERT(pModel != NULL);
3487  // check the units
3488  UnitDefinition* pUDef = pModel->getUnitDefinition("time");
3489  Unit* pUnit = NULL;
3490 
3491  // since second is the default time unit, it does not have to be exported and
3492  // might be NULL
3493  if (pUDef != NULL)
3494  {
3495  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
3496  pUnit = pUDef->getUnit(0);
3497  CPPUNIT_ASSERT(pUnit != NULL);
3498  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_SECOND);
3499  CPPUNIT_ASSERT(pUnit->getScale() == 0);
3500  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
3501  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
3502  }
3503 
3504  pUDef = pModel->getUnitDefinition("substance");
3505  CPPUNIT_ASSERT(pUDef != NULL);
3506  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
3507  pUnit = pUDef->getUnit(0);
3508  CPPUNIT_ASSERT(pUnit != NULL);
3509  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_ITEM);
3510  CPPUNIT_ASSERT(pUnit->getScale() == 0);
3511  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
3512  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
3513  pUDef = pModel->getUnitDefinition("volume");
3514  CPPUNIT_ASSERT(pUDef != NULL);
3515  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
3516  pUnit = pUDef->getUnit(0);
3517  CPPUNIT_ASSERT(pUnit != NULL);
3518  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_LITRE);
3519  CPPUNIT_ASSERT(pUnit->getScale() == -3);
3520  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
3521  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
3522  // assert that there is only one compartment and
3523  // assert the compartment is constant
3524  CPPUNIT_ASSERT(pModel->getNumCompartments() == 1);
3525  Compartment* pCompartment = pModel->getCompartment(0);
3526  CPPUNIT_ASSERT(pCompartment->getConstant() == true);
3527  CPPUNIT_ASSERT(pModel->getNumParameters() == 1);
3528  Parameter* pParameter1 = pModel->getParameter(0);
3529  CPPUNIT_ASSERT(pParameter1 != NULL);
3530  CPPUNIT_ASSERT(pParameter1->getName() == "K");
3531  CPPUNIT_ASSERT(pModel->getNumSpecies() == 2);
3532  Species* pSpecies1 = pModel->getSpecies(0);
3533  CPPUNIT_ASSERT(pSpecies1->getHasOnlySubstanceUnits() == false);
3534  std::string idSpeciesA = pSpecies1->getId();
3535  Species* pSpecies2 = pModel->getSpecies(1);
3536  CPPUNIT_ASSERT(pSpecies2->getHasOnlySubstanceUnits() == false);
3537  CPPUNIT_ASSERT(pModel->getNumRules() == 0);
3538  CPPUNIT_ASSERT(pModel->getNumReactions() == 0);
3539  CPPUNIT_ASSERT(pModel->getNumEvents() == 1);
3540  Event* pEvent = pModel->getEvent(0);
3541  CPPUNIT_ASSERT(pEvent != NULL);
3542  // check the trigger
3543  CPPUNIT_ASSERT(pEvent->isSetTrigger());
3544  Trigger* pTrigger = pEvent->getTrigger();
3545  CPPUNIT_ASSERT(pTrigger != NULL);
3546  CPPUNIT_ASSERT(pTrigger->isSetMath());
3547  const ASTNode* pMath = pTrigger->getMath();
3548  CPPUNIT_ASSERT(pMath != NULL);
3549  CPPUNIT_ASSERT(pMath->getType() == AST_RELATIONAL_GT);
3550  CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
3551  const ASTNode* pChild = pMath->getChild(0);
3552  CPPUNIT_ASSERT(pChild != NULL);
3553  CPPUNIT_ASSERT(pChild->getType() == AST_NAME_TIME);
3554  pChild = pMath->getChild(1);
3555  CPPUNIT_ASSERT(pChild != NULL);
3556  CPPUNIT_ASSERT(pChild->getType() == AST_REAL);
3557  CPPUNIT_ASSERT(fabs((pChild->getReal() - 2.0) / 2.0) < 1e-6);
3558  // check the delay
3559  CPPUNIT_ASSERT(pEvent->isSetDelay());
3560  Delay* pDelay = pEvent->getDelay();
3561  CPPUNIT_ASSERT(pDelay != NULL);
3562  CPPUNIT_ASSERT(pDelay->isSetMath());
3563  pMath = pDelay->getMath();
3564  CPPUNIT_ASSERT(pMath != NULL);
3565  CPPUNIT_ASSERT(pMath->getType() == AST_REAL);
3566  CPPUNIT_ASSERT(fabs((pMath->getReal() - 4.0) / 4.0) < 1e-6);
3567  // check the event asssignment
3568  CPPUNIT_ASSERT(pEvent->getNumEventAssignments() == 1);
3569  EventAssignment* pEA = pEvent->getEventAssignment(0);
3570  CPPUNIT_ASSERT(pEA != NULL);
3571  CPPUNIT_ASSERT(pEA->getVariable() == pSpecies1->getId());
3572  pMath = pEA->getMath();
3573  CPPUNIT_ASSERT(pMath != NULL);
3574  // make sure the mathematical expression contains only one node that is a
3575  // reference to the global parameter
3576  CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
3577  CPPUNIT_ASSERT(pMath->getName() == pParameter1->getId());
3578 }
SBMLDocument * getCurrentSBMLDocument()
static const char * MODEL_STRING111
Definition: test000064.h:91
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000064.h:98
void test000064::test_export_event_assignment_expression_and_hasOnlySubstanceUnits_4 ( )

Definition at line 3637 of file test000064.cpp.

References CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CCopasiDataModel::getModel(), load_cps_model_from_stream(), MODEL_STRING112, and pCOPASIDATAMODEL.

3638 {
3639  // load the CPS file
3640  // export to SBML
3641  // check the resulting SBML model
3642  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
3643  std::istringstream iss(test000064::MODEL_STRING112);
3644  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
3645  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
3646  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 3).empty() == false);
3647  SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
3648  CPPUNIT_ASSERT(pDocument != NULL);
3649  Model* pModel = pDocument->getModel();
3650  CPPUNIT_ASSERT(pModel != NULL);
3651  // check the units
3652  UnitDefinition* pUDef = pModel->getUnitDefinition("time");
3653  Unit* pUnit = NULL;
3654 
3655  // since second is the default time unit, it does not have to be exported and
3656  // might be NULL
3657  if (pUDef != NULL)
3658  {
3659  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
3660  pUnit = pUDef->getUnit(0);
3661  CPPUNIT_ASSERT(pUnit != NULL);
3662  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_SECOND);
3663  CPPUNIT_ASSERT(pUnit->getScale() == 0);
3664  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
3665  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
3666  }
3667 
3668  pUDef = pModel->getUnitDefinition("substance");
3669  CPPUNIT_ASSERT(pUDef != NULL);
3670  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
3671  pUnit = pUDef->getUnit(0);
3672  CPPUNIT_ASSERT(pUnit != NULL);
3673  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_ITEM);
3674  CPPUNIT_ASSERT(pUnit->getScale() == 0);
3675  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
3676  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
3677  pUDef = pModel->getUnitDefinition("volume");
3678  CPPUNIT_ASSERT(pUDef != NULL);
3679  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
3680  pUnit = pUDef->getUnit(0);
3681  CPPUNIT_ASSERT(pUnit != NULL);
3682  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_LITRE);
3683  CPPUNIT_ASSERT(pUnit->getScale() == -3);
3684  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
3685  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
3686  // assert that there is only one compartment and
3687  // assert the compartment is constant
3688  CPPUNIT_ASSERT(pModel->getNumCompartments() == 1);
3689  Compartment* pCompartment = pModel->getCompartment(0);
3690  CPPUNIT_ASSERT(pCompartment->getConstant() == false);
3691  CPPUNIT_ASSERT(pModel->getNumParameters() == 2);
3692  Parameter* pParameter1 = pModel->getParameter(0);
3693  CPPUNIT_ASSERT(pParameter1 != NULL);
3694  Parameter* pParameter2 = NULL;
3695 
3696  if (pParameter1->getName() == "K")
3697  {
3698  pParameter2 = pModel->getParameter(1);
3699  }
3700  else
3701  {
3702  pParameter2 = pParameter1;
3703  pParameter1 = pModel->getParameter(1);
3704  }
3705 
3706  CPPUNIT_ASSERT(pParameter2 != NULL);
3707  CPPUNIT_ASSERT(pParameter1->getName() == "K");
3708  CPPUNIT_ASSERT(pParameter2->getName() == "P");
3709  CPPUNIT_ASSERT(pModel->getNumSpecies() == 2);
3710  Species* pSpecies1 = pModel->getSpecies(0);
3711  CPPUNIT_ASSERT(pSpecies1->getHasOnlySubstanceUnits() == true);
3712  std::string idSpeciesA = pSpecies1->getId();
3713  Species* pSpecies2 = pModel->getSpecies(1);
3714  CPPUNIT_ASSERT(pSpecies2->getHasOnlySubstanceUnits() == true);
3715  CPPUNIT_ASSERT(pModel->getNumRules() == 1);
3716  Rule* pRule = pModel->getRule(0);
3717  CPPUNIT_ASSERT(pRule != NULL);
3718  CPPUNIT_ASSERT(pRule->getVariable() == pCompartment->getId());
3719  CPPUNIT_ASSERT(pRule->isSetMath() == true);
3720  const ASTNode* pMath = pRule->getMath();
3721  CPPUNIT_ASSERT(pMath != NULL);
3722  CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
3723  CPPUNIT_ASSERT(pMath->getName() == pParameter2->getId());
3724  CPPUNIT_ASSERT(pModel->getNumReactions() == 0);
3725  CPPUNIT_ASSERT(pModel->getNumEvents() == 1);
3726  Event* pEvent = pModel->getEvent(0);
3727  CPPUNIT_ASSERT(pEvent != NULL);
3728  // check the trigger
3729  CPPUNIT_ASSERT(pEvent->isSetTrigger());
3730  Trigger* pTrigger = pEvent->getTrigger();
3731  CPPUNIT_ASSERT(pTrigger != NULL);
3732  CPPUNIT_ASSERT(pTrigger->isSetMath());
3733  pMath = pTrigger->getMath();
3734  CPPUNIT_ASSERT(pMath != NULL);
3735  CPPUNIT_ASSERT(pMath->getType() == AST_RELATIONAL_GT);
3736  CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
3737  const ASTNode* pChild = pMath->getChild(0);
3738  CPPUNIT_ASSERT(pChild != NULL);
3739  CPPUNIT_ASSERT(pChild->getType() == AST_NAME_TIME);
3740  pChild = pMath->getChild(1);
3741  CPPUNIT_ASSERT(pChild != NULL);
3742  CPPUNIT_ASSERT(pChild->getType() == AST_REAL);
3743  CPPUNIT_ASSERT(fabs((pChild->getReal() - 2.0) / 2.0) < 1e-6);
3744  // check the delay
3745  CPPUNIT_ASSERT(pEvent->isSetDelay());
3746  Delay* pDelay = pEvent->getDelay();
3747  CPPUNIT_ASSERT(pDelay != NULL);
3748  CPPUNIT_ASSERT(pDelay->isSetMath());
3749  pMath = pDelay->getMath();
3750  CPPUNIT_ASSERT(pMath != NULL);
3751  CPPUNIT_ASSERT(pMath->getType() == AST_REAL);
3752  CPPUNIT_ASSERT(fabs((pMath->getReal() - 4.0) / 4.0) < 1e-6);
3753  // check the event asssignment
3754  CPPUNIT_ASSERT(pEvent->getNumEventAssignments() == 1);
3755  EventAssignment* pEA = pEvent->getEventAssignment(0);
3756  CPPUNIT_ASSERT(pEA != NULL);
3757  CPPUNIT_ASSERT(pEA->getVariable() == pSpecies1->getId());
3758  pMath = pEA->getMath();
3759  CPPUNIT_ASSERT(pMath != NULL);
3760  // make sure the mathematical expression contains only one node that is a
3761  // reference to the global parameter multiplied by the compartment volume
3762  CPPUNIT_ASSERT(pMath->getType() == AST_TIMES);
3763  CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
3764  const ASTNode* pChild1 = pMath->getChild(0);
3765  CPPUNIT_ASSERT(pChild1 != NULL);
3766  CPPUNIT_ASSERT(pChild1->getType() == AST_NAME);
3767  const ASTNode* pChild2 = pMath->getChild(1);
3768  CPPUNIT_ASSERT(pChild2 != NULL);
3769  CPPUNIT_ASSERT(pChild2->getType() == AST_NAME);
3770  CPPUNIT_ASSERT(pChild1->getName() == pParameter1->getId() || pChild2->getName() == pParameter1->getId());
3771  CPPUNIT_ASSERT(pChild1->getName() == pCompartment->getId() || pChild2->getName() == pCompartment->getId());
3772 }
SBMLDocument * getCurrentSBMLDocument()
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
static const char * MODEL_STRING112
Definition: test000064.h:92
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000064.h:98
void test000064::test_export_event_assignment_expression_and_hasOnlySubstanceUnits_5 ( )

Definition at line 3836 of file test000064.cpp.

References CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CCopasiDataModel::getModel(), load_cps_model_from_stream(), MODEL_STRING113, and pCOPASIDATAMODEL.

3837 {
3838  // load the CPS file
3839  // export to SBML
3840  // check the resulting SBML model
3841  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
3842  std::istringstream iss(test000064::MODEL_STRING113);
3843  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
3844  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
3845  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 3).empty() == false);
3846  SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
3847  CPPUNIT_ASSERT(pDocument != NULL);
3848  Model* pModel = pDocument->getModel();
3849  CPPUNIT_ASSERT(pModel != NULL);
3850  // check the units
3851  UnitDefinition* pUDef = pModel->getUnitDefinition("time");
3852  Unit* pUnit = NULL;
3853 
3854  // since second is the default time unit, it does not have to be exported and
3855  // might be NULL
3856  if (pUDef != NULL)
3857  {
3858  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
3859  pUnit = pUDef->getUnit(0);
3860  CPPUNIT_ASSERT(pUnit != NULL);
3861  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_SECOND);
3862  CPPUNIT_ASSERT(pUnit->getScale() == 0);
3863  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
3864  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
3865  }
3866 
3867  pUDef = pModel->getUnitDefinition("substance");
3868  CPPUNIT_ASSERT(pUDef != NULL);
3869  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
3870  pUnit = pUDef->getUnit(0);
3871  CPPUNIT_ASSERT(pUnit != NULL);
3872  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_MOLE);
3873  CPPUNIT_ASSERT(pUnit->getScale() == -3);
3874  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
3875  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
3876  pUDef = pModel->getUnitDefinition("volume");
3877  CPPUNIT_ASSERT(pUDef != NULL);
3878  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
3879  pUnit = pUDef->getUnit(0);
3880  CPPUNIT_ASSERT(pUnit != NULL);
3881  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_LITRE);
3882  CPPUNIT_ASSERT(pUnit->getScale() == -3);
3883  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
3884  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
3885  // assert that there is only one compartment and
3886  // assert the compartment is constant
3887  CPPUNIT_ASSERT(pModel->getNumCompartments() == 1);
3888  Compartment* pCompartment = pModel->getCompartment(0);
3889  CPPUNIT_ASSERT(pCompartment->getConstant() == true);
3890  CPPUNIT_ASSERT(pModel->getNumParameters() == 1);
3891  Parameter* pParameter1 = pModel->getParameter(0);
3892  CPPUNIT_ASSERT(pParameter1 != NULL);
3893  CPPUNIT_ASSERT(pParameter1->getName() == "K");
3894  CPPUNIT_ASSERT(pModel->getNumSpecies() == 2);
3895  Species* pSpecies1 = pModel->getSpecies(0);
3896  CPPUNIT_ASSERT(pSpecies1->getHasOnlySubstanceUnits() == false);
3897  std::string idSpeciesA = pSpecies1->getId();
3898  Species* pSpecies2 = pModel->getSpecies(1);
3899  CPPUNIT_ASSERT(pSpecies2->getHasOnlySubstanceUnits() == false);
3900  CPPUNIT_ASSERT(pModel->getNumRules() == 0);
3901  CPPUNIT_ASSERT(pModel->getNumReactions() == 0);
3902  CPPUNIT_ASSERT(pModel->getNumEvents() == 1);
3903  Event* pEvent = pModel->getEvent(0);
3904  CPPUNIT_ASSERT(pEvent != NULL);
3905  // check the trigger
3906  CPPUNIT_ASSERT(pEvent->isSetTrigger());
3907  Trigger* pTrigger = pEvent->getTrigger();
3908  CPPUNIT_ASSERT(pTrigger != NULL);
3909  CPPUNIT_ASSERT(pTrigger->isSetMath());
3910  const ASTNode* pMath = pTrigger->getMath();
3911  CPPUNIT_ASSERT(pMath != NULL);
3912  CPPUNIT_ASSERT(pMath->getType() == AST_RELATIONAL_GT);
3913  CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
3914  const ASTNode* pChild = pMath->getChild(0);
3915  CPPUNIT_ASSERT(pChild != NULL);
3916  CPPUNIT_ASSERT(pChild->getType() == AST_NAME_TIME);
3917  pChild = pMath->getChild(1);
3918  CPPUNIT_ASSERT(pChild != NULL);
3919  CPPUNIT_ASSERT(pChild->getType() == AST_REAL);
3920  CPPUNIT_ASSERT(fabs((pChild->getReal() - 2.0) / 2.0) < 1e-6);
3921  // check the delay
3922  CPPUNIT_ASSERT(pEvent->isSetDelay());
3923  Delay* pDelay = pEvent->getDelay();
3924  CPPUNIT_ASSERT(pDelay != NULL);
3925  CPPUNIT_ASSERT(pDelay->isSetMath());
3926  pMath = pDelay->getMath();
3927  CPPUNIT_ASSERT(pMath != NULL);
3928  CPPUNIT_ASSERT(pMath->getType() == AST_REAL);
3929  CPPUNIT_ASSERT(fabs((pMath->getReal() - 4.0) / 4.0) < 1e-6);
3930  // check the event asssignment
3931  CPPUNIT_ASSERT(pEvent->getNumEventAssignments() == 1);
3932  EventAssignment* pEA = pEvent->getEventAssignment(0);
3933  CPPUNIT_ASSERT(pEA != NULL);
3934  CPPUNIT_ASSERT(pEA->getVariable() == pSpecies1->getId());
3935  pMath = pEA->getMath();
3936  CPPUNIT_ASSERT(pMath != NULL);
3937  // make sure the mathematical expression contains only one node that is a
3938  // reference to the global parameter
3939  CPPUNIT_ASSERT(pMath->getType() == AST_DIVIDE);
3940  CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
3941  pChild = pMath->getChild(0);
3942  CPPUNIT_ASSERT(pChild != NULL);
3943  CPPUNIT_ASSERT(pChild->getType() == AST_NAME);
3944  CPPUNIT_ASSERT(pChild->getName() == pParameter1->getId());
3945  pChild = pMath->getChild(1);
3946  CPPUNIT_ASSERT(pChild != NULL);
3947  CPPUNIT_ASSERT(pChild->getType() == AST_NAME);
3948  CPPUNIT_ASSERT(pChild->getName() == pCompartment->getId());
3949 }
SBMLDocument * getCurrentSBMLDocument()
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
static const char * MODEL_STRING113
Definition: test000064.h:93
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000064.h:98
void test000064::test_export_event_assignment_expression_and_hasOnlySubstanceUnits_6 ( )

Definition at line 4008 of file test000064.cpp.

References CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CCopasiDataModel::getModel(), load_cps_model_from_stream(), MODEL_STRING114, and pCOPASIDATAMODEL.

4009 {
4010  // load the CPS file
4011  // export to SBML
4012  // check the resulting SBML model
4013  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
4014  std::istringstream iss(test000064::MODEL_STRING114);
4015  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
4016  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
4017  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 3).empty() == false);
4018  SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
4019  CPPUNIT_ASSERT(pDocument != NULL);
4020  Model* pModel = pDocument->getModel();
4021  CPPUNIT_ASSERT(pModel != NULL);
4022  // check the units
4023  UnitDefinition* pUDef = pModel->getUnitDefinition("time");
4024  Unit* pUnit = NULL;
4025 
4026  // since second is the default time unit, it does not have to be exported and
4027  // might be NULL
4028  if (pUDef != NULL)
4029  {
4030  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
4031  pUnit = pUDef->getUnit(0);
4032  CPPUNIT_ASSERT(pUnit != NULL);
4033  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_SECOND);
4034  CPPUNIT_ASSERT(pUnit->getScale() == 0);
4035  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
4036  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
4037  }
4038 
4039  pUDef = pModel->getUnitDefinition("substance");
4040  CPPUNIT_ASSERT(pUDef != NULL);
4041  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
4042  pUnit = pUDef->getUnit(0);
4043  CPPUNIT_ASSERT(pUnit != NULL);
4044  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_MOLE);
4045  CPPUNIT_ASSERT(pUnit->getScale() == -3);
4046  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
4047  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
4048  pUDef = pModel->getUnitDefinition("volume");
4049  CPPUNIT_ASSERT(pUDef != NULL);
4050  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
4051  pUnit = pUDef->getUnit(0);
4052  CPPUNIT_ASSERT(pUnit != NULL);
4053  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_LITRE);
4054  CPPUNIT_ASSERT(pUnit->getScale() == -3);
4055  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
4056  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
4057  // assert that there is only one compartment and
4058  // assert the compartment is constant
4059  CPPUNIT_ASSERT(pModel->getNumCompartments() == 1);
4060  Compartment* pCompartment = pModel->getCompartment(0);
4061  CPPUNIT_ASSERT(pCompartment->getConstant() == false);
4062  CPPUNIT_ASSERT(pModel->getNumParameters() == 2);
4063  Parameter* pParameter1 = pModel->getParameter(0);
4064  CPPUNIT_ASSERT(pParameter1 != NULL);
4065  Parameter* pParameter2 = NULL;
4066 
4067  if (pParameter1->getName() == "K")
4068  {
4069  pParameter2 = pModel->getParameter(1);
4070  }
4071  else
4072  {
4073  pParameter2 = pParameter1;
4074  pParameter1 = pModel->getParameter(1);
4075  }
4076 
4077  CPPUNIT_ASSERT(pParameter2 != NULL);
4078  CPPUNIT_ASSERT(pParameter1->getName() == "K");
4079  CPPUNIT_ASSERT(pParameter2->getName() == "P");
4080  CPPUNIT_ASSERT(pModel->getNumSpecies() == 2);
4081  Species* pSpecies1 = pModel->getSpecies(0);
4082  CPPUNIT_ASSERT(pSpecies1->getHasOnlySubstanceUnits() == true);
4083  std::string idSpeciesA = pSpecies1->getId();
4084  Species* pSpecies2 = pModel->getSpecies(1);
4085  CPPUNIT_ASSERT(pSpecies2->getHasOnlySubstanceUnits() == true);
4086  CPPUNIT_ASSERT(pModel->getNumRules() == 1);
4087  Rule* pRule = pModel->getRule(0);
4088  CPPUNIT_ASSERT(pRule != NULL);
4089  CPPUNIT_ASSERT(pRule->getVariable() == pCompartment->getId());
4090  CPPUNIT_ASSERT(pRule->isSetMath() == true);
4091  const ASTNode* pMath = pRule->getMath();
4092  CPPUNIT_ASSERT(pMath != NULL);
4093  CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
4094  CPPUNIT_ASSERT(pMath->getName() == pParameter2->getId());
4095  CPPUNIT_ASSERT(pModel->getNumReactions() == 0);
4096  CPPUNIT_ASSERT(pModel->getNumEvents() == 1);
4097  Event* pEvent = pModel->getEvent(0);
4098  CPPUNIT_ASSERT(pEvent != NULL);
4099  // check the trigger
4100  CPPUNIT_ASSERT(pEvent->isSetTrigger());
4101  Trigger* pTrigger = pEvent->getTrigger();
4102  CPPUNIT_ASSERT(pTrigger != NULL);
4103  CPPUNIT_ASSERT(pTrigger->isSetMath());
4104  pMath = pTrigger->getMath();
4105  CPPUNIT_ASSERT(pMath != NULL);
4106  CPPUNIT_ASSERT(pMath->getType() == AST_RELATIONAL_GT);
4107  CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
4108  const ASTNode* pChild = pMath->getChild(0);
4109  CPPUNIT_ASSERT(pChild != NULL);
4110  CPPUNIT_ASSERT(pChild->getType() == AST_NAME_TIME);
4111  pChild = pMath->getChild(1);
4112  CPPUNIT_ASSERT(pChild != NULL);
4113  CPPUNIT_ASSERT(pChild->getType() == AST_REAL);
4114  CPPUNIT_ASSERT(fabs((pChild->getReal() - 2.0) / 2.0) < 1e-6);
4115  // check the delay
4116  CPPUNIT_ASSERT(pEvent->isSetDelay());
4117  Delay* pDelay = pEvent->getDelay();
4118  CPPUNIT_ASSERT(pDelay != NULL);
4119  CPPUNIT_ASSERT(pDelay->isSetMath());
4120  pMath = pDelay->getMath();
4121  CPPUNIT_ASSERT(pMath != NULL);
4122  CPPUNIT_ASSERT(pMath->getType() == AST_REAL);
4123  CPPUNIT_ASSERT(fabs((pMath->getReal() - 4.0) / 4.0) < 1e-6);
4124  // check the event asssignment
4125  CPPUNIT_ASSERT(pEvent->getNumEventAssignments() == 1);
4126  EventAssignment* pEA = pEvent->getEventAssignment(0);
4127  CPPUNIT_ASSERT(pEA != NULL);
4128  CPPUNIT_ASSERT(pEA->getVariable() == pSpecies1->getId());
4129  pMath = pEA->getMath();
4130  CPPUNIT_ASSERT(pMath != NULL);
4131  // make sure the mathematical expression contains only one node that is a
4132  // reference to the global parameter
4133  CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
4134  CPPUNIT_ASSERT(pMath->getName() == pParameter1->getId());
4135 }
SBMLDocument * getCurrentSBMLDocument()
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
static const char * MODEL_STRING114
Definition: test000064.h:94
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000064.h:98
void test000064::test_export_event_assignment_expression_and_hasOnlySubstanceUnits_7 ( )

Definition at line 4199 of file test000064.cpp.

References CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CCopasiDataModel::getModel(), load_cps_model_from_stream(), MODEL_STRING115, and pCOPASIDATAMODEL.

4200 {
4201  // load the CPS file
4202  // export to SBML
4203  // check the resulting SBML model
4204  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
4205  std::istringstream iss(test000064::MODEL_STRING115);
4206  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
4207  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
4208  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 3).empty() == false);
4209  SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
4210  CPPUNIT_ASSERT(pDocument != NULL);
4211  Model* pModel = pDocument->getModel();
4212  CPPUNIT_ASSERT(pModel != NULL);
4213  // check the units
4214  UnitDefinition* pUDef = pModel->getUnitDefinition("time");
4215  Unit* pUnit = NULL;
4216 
4217  // since second is the default time unit, it does not have to be exported and
4218  // might be NULL
4219  if (pUDef != NULL)
4220  {
4221  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
4222  pUnit = pUDef->getUnit(0);
4223  CPPUNIT_ASSERT(pUnit != NULL);
4224  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_SECOND);
4225  CPPUNIT_ASSERT(pUnit->getScale() == 0);
4226  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
4227  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
4228  }
4229 
4230  pUDef = pModel->getUnitDefinition("substance");
4231  CPPUNIT_ASSERT(pUDef != NULL);
4232  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
4233  pUnit = pUDef->getUnit(0);
4234  CPPUNIT_ASSERT(pUnit != NULL);
4235  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_ITEM);
4236  CPPUNIT_ASSERT(pUnit->getScale() == 0);
4237  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
4238  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
4239  pUDef = pModel->getUnitDefinition("volume");
4240  CPPUNIT_ASSERT(pUDef != NULL);
4241  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
4242  pUnit = pUDef->getUnit(0);
4243  CPPUNIT_ASSERT(pUnit != NULL);
4244  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_LITRE);
4245  CPPUNIT_ASSERT(pUnit->getScale() == -3);
4246  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
4247  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
4248  // assert that there is only one compartment and
4249  // assert the compartment is constant
4250  CPPUNIT_ASSERT(pModel->getNumCompartments() == 1);
4251  Compartment* pCompartment = pModel->getCompartment(0);
4252  CPPUNIT_ASSERT(pCompartment->getConstant() == true);
4253  CPPUNIT_ASSERT(pModel->getNumParameters() == 1);
4254  Parameter* pParameter1 = pModel->getParameter(0);
4255  CPPUNIT_ASSERT(pParameter1 != NULL);
4256  CPPUNIT_ASSERT(pParameter1->getName() == "K");
4257  CPPUNIT_ASSERT(pModel->getNumSpecies() == 2);
4258  Species* pSpecies1 = pModel->getSpecies(0);
4259  CPPUNIT_ASSERT(pSpecies1->getHasOnlySubstanceUnits() == false);
4260  std::string idSpeciesA = pSpecies1->getId();
4261  Species* pSpecies2 = pModel->getSpecies(1);
4262  CPPUNIT_ASSERT(pSpecies2->getHasOnlySubstanceUnits() == false);
4263  CPPUNIT_ASSERT(pModel->getNumRules() == 0);
4264  CPPUNIT_ASSERT(pModel->getNumReactions() == 0);
4265  CPPUNIT_ASSERT(pModel->getNumEvents() == 1);
4266  Event* pEvent = pModel->getEvent(0);
4267  CPPUNIT_ASSERT(pEvent != NULL);
4268  // check the trigger
4269  CPPUNIT_ASSERT(pEvent->isSetTrigger());
4270  Trigger* pTrigger = pEvent->getTrigger();
4271  CPPUNIT_ASSERT(pTrigger != NULL);
4272  CPPUNIT_ASSERT(pTrigger->isSetMath());
4273  const ASTNode* pMath = pTrigger->getMath();
4274  CPPUNIT_ASSERT(pMath != NULL);
4275  CPPUNIT_ASSERT(pMath->getType() == AST_RELATIONAL_GT);
4276  CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
4277  const ASTNode* pChild = pMath->getChild(0);
4278  CPPUNIT_ASSERT(pChild != NULL);
4279  CPPUNIT_ASSERT(pChild->getType() == AST_NAME_TIME);
4280  pChild = pMath->getChild(1);
4281  CPPUNIT_ASSERT(pChild != NULL);
4282  CPPUNIT_ASSERT(pChild->getType() == AST_REAL);
4283  CPPUNIT_ASSERT(fabs((pChild->getReal() - 2.0) / 2.0) < 1e-6);
4284  // check the delay
4285  CPPUNIT_ASSERT(pEvent->isSetDelay());
4286  Delay* pDelay = pEvent->getDelay();
4287  CPPUNIT_ASSERT(pDelay != NULL);
4288  CPPUNIT_ASSERT(pDelay->isSetMath());
4289  pMath = pDelay->getMath();
4290  CPPUNIT_ASSERT(pMath != NULL);
4291  CPPUNIT_ASSERT(pMath->getType() == AST_REAL);
4292  CPPUNIT_ASSERT(fabs((pMath->getReal() - 4.0) / 4.0) < 1e-6);
4293  // check the event asssignment
4294  CPPUNIT_ASSERT(pEvent->getNumEventAssignments() == 1);
4295  EventAssignment* pEA = pEvent->getEventAssignment(0);
4296  CPPUNIT_ASSERT(pEA != NULL);
4297  CPPUNIT_ASSERT(pEA->getVariable() == pSpecies1->getId());
4298  pMath = pEA->getMath();
4299  CPPUNIT_ASSERT(pMath != NULL);
4300  // make sure the mathematical expression contains only one node that is a
4301  // reference to the global parameter
4302  CPPUNIT_ASSERT(pMath->getType() == AST_DIVIDE);
4303  CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
4304  ASTNode* pChild1 = pMath->getChild(0);
4305  CPPUNIT_ASSERT(pChild1 != NULL);
4306  CPPUNIT_ASSERT(pChild1->getType() == AST_NAME);
4307  ASTNode* pChild2 = pMath->getChild(1);
4308  CPPUNIT_ASSERT(pChild2 != NULL);
4309  CPPUNIT_ASSERT(pChild2->getType() == AST_NAME);
4310  CPPUNIT_ASSERT(pChild1->getName() == pParameter1->getId() || pChild2->getName() == pParameter1->getId());
4311  CPPUNIT_ASSERT(pChild1->getName() == pCompartment->getId() || pChild2->getName() == pCompartment->getId());
4312 }
SBMLDocument * getCurrentSBMLDocument()
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000064.h:98
static const char * MODEL_STRING115
Definition: test000064.h:95
void test000064::test_export_event_assignment_expression_and_hasOnlySubstanceUnits_8 ( )

Definition at line 4371 of file test000064.cpp.

References CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CCopasiDataModel::getModel(), load_cps_model_from_stream(), MODEL_STRING116, and pCOPASIDATAMODEL.

4372 {
4373  // load the CPS file
4374  // export to SBML
4375  // check the resulting SBML model
4376  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
4377  std::istringstream iss(test000064::MODEL_STRING116);
4378  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
4379  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
4380  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 3).empty() == false);
4381  SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
4382  CPPUNIT_ASSERT(pDocument != NULL);
4383  Model* pModel = pDocument->getModel();
4384  CPPUNIT_ASSERT(pModel != NULL);
4385  // check the units
4386  UnitDefinition* pUDef = pModel->getUnitDefinition("time");
4387  Unit* pUnit = NULL;
4388 
4389  // since second is the default time unit, it does not have to be exported and
4390  // might be NULL
4391  if (pUDef != NULL)
4392  {
4393  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
4394  pUnit = pUDef->getUnit(0);
4395  CPPUNIT_ASSERT(pUnit != NULL);
4396  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_SECOND);
4397  CPPUNIT_ASSERT(pUnit->getScale() == 0);
4398  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
4399  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
4400  }
4401 
4402  pUDef = pModel->getUnitDefinition("substance");
4403  CPPUNIT_ASSERT(pUDef != NULL);
4404  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
4405  pUnit = pUDef->getUnit(0);
4406  CPPUNIT_ASSERT(pUnit != NULL);
4407  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_ITEM);
4408  CPPUNIT_ASSERT(pUnit->getScale() == 0);
4409  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
4410  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
4411  pUDef = pModel->getUnitDefinition("volume");
4412  CPPUNIT_ASSERT(pUDef != NULL);
4413  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
4414  pUnit = pUDef->getUnit(0);
4415  CPPUNIT_ASSERT(pUnit != NULL);
4416  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_LITRE);
4417  CPPUNIT_ASSERT(pUnit->getScale() == -3);
4418  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
4419  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
4420  // assert that there is only one compartment and
4421  // assert the compartment is constant
4422  CPPUNIT_ASSERT(pModel->getNumCompartments() == 1);
4423  Compartment* pCompartment = pModel->getCompartment(0);
4424  CPPUNIT_ASSERT(pCompartment->getConstant() == false);
4425  CPPUNIT_ASSERT(pModel->getNumParameters() == 2);
4426  Parameter* pParameter1 = pModel->getParameter(0);
4427  CPPUNIT_ASSERT(pParameter1 != NULL);
4428  Parameter* pParameter2 = NULL;
4429 
4430  if (pParameter1->getName() == "K")
4431  {
4432  pParameter2 = pModel->getParameter(1);
4433  }
4434  else
4435  {
4436  pParameter2 = pParameter1;
4437  pParameter1 = pModel->getParameter(1);
4438  }
4439 
4440  CPPUNIT_ASSERT(pParameter2 != NULL);
4441  CPPUNIT_ASSERT(pParameter1->getName() == "K");
4442  CPPUNIT_ASSERT(pParameter2->getName() == "P");
4443  CPPUNIT_ASSERT(pModel->getNumSpecies() == 2);
4444  Species* pSpecies1 = pModel->getSpecies(0);
4445  CPPUNIT_ASSERT(pSpecies1->getHasOnlySubstanceUnits() == true);
4446  std::string idSpeciesA = pSpecies1->getId();
4447  Species* pSpecies2 = pModel->getSpecies(1);
4448  CPPUNIT_ASSERT(pSpecies2->getHasOnlySubstanceUnits() == true);
4449  CPPUNIT_ASSERT(pModel->getNumRules() == 1);
4450  Rule* pRule = pModel->getRule(0);
4451  CPPUNIT_ASSERT(pRule != NULL);
4452  CPPUNIT_ASSERT(pRule->getVariable() == pCompartment->getId());
4453  CPPUNIT_ASSERT(pRule->isSetMath() == true);
4454  const ASTNode* pMath = pRule->getMath();
4455  CPPUNIT_ASSERT(pMath != NULL);
4456  CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
4457  CPPUNIT_ASSERT(pMath->getName() == pParameter2->getId());
4458  CPPUNIT_ASSERT(pModel->getNumReactions() == 0);
4459  CPPUNIT_ASSERT(pModel->getNumEvents() == 1);
4460  Event* pEvent = pModel->getEvent(0);
4461  CPPUNIT_ASSERT(pEvent != NULL);
4462  // check the trigger
4463  CPPUNIT_ASSERT(pEvent->isSetTrigger());
4464  Trigger* pTrigger = pEvent->getTrigger();
4465  CPPUNIT_ASSERT(pTrigger != NULL);
4466  CPPUNIT_ASSERT(pTrigger->isSetMath());
4467  pMath = pTrigger->getMath();
4468  CPPUNIT_ASSERT(pMath != NULL);
4469  CPPUNIT_ASSERT(pMath->getType() == AST_RELATIONAL_GT);
4470  CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
4471  const ASTNode* pChild = pMath->getChild(0);
4472  CPPUNIT_ASSERT(pChild != NULL);
4473  CPPUNIT_ASSERT(pChild->getType() == AST_NAME_TIME);
4474  pChild = pMath->getChild(1);
4475  CPPUNIT_ASSERT(pChild != NULL);
4476  CPPUNIT_ASSERT(pChild->getType() == AST_REAL);
4477  CPPUNIT_ASSERT(fabs((pChild->getReal() - 2.0) / 2.0) < 1e-6);
4478  // check the delay
4479  CPPUNIT_ASSERT(pEvent->isSetDelay());
4480  Delay* pDelay = pEvent->getDelay();
4481  CPPUNIT_ASSERT(pDelay != NULL);
4482  CPPUNIT_ASSERT(pDelay->isSetMath());
4483  pMath = pDelay->getMath();
4484  CPPUNIT_ASSERT(pMath != NULL);
4485  CPPUNIT_ASSERT(pMath->getType() == AST_REAL);
4486  CPPUNIT_ASSERT(fabs((pMath->getReal() - 4.0) / 4.0) < 1e-6);
4487  // check the event asssignment
4488  CPPUNIT_ASSERT(pEvent->getNumEventAssignments() == 1);
4489  EventAssignment* pEA = pEvent->getEventAssignment(0);
4490  CPPUNIT_ASSERT(pEA != NULL);
4491  CPPUNIT_ASSERT(pEA->getVariable() == pSpecies1->getId());
4492  pMath = pEA->getMath();
4493  CPPUNIT_ASSERT(pMath != NULL);
4494  // make sure the mathematical expression contains only one node that is a
4495  // reference to the global parameter multiplied by the compartment volume
4496  CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
4497  CPPUNIT_ASSERT(pMath->getName() == pParameter1->getId());
4498 }
SBMLDocument * getCurrentSBMLDocument()
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000064.h:98
static const char * MODEL_STRING116
Definition: test000064.h:96
void test000064::test_export_rule_expression_and_hasOnlySubstanceUnits_1 ( )

Definition at line 1973 of file test000064.cpp.

References CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CCopasiDataModel::getModel(), load_cps_model_from_stream(), MODEL_STRING101, and pCOPASIDATAMODEL.

1974 {
1975  // load the CPS file
1976  // export to SBML
1977  // check the resulting SBML model
1978  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
1979  std::istringstream iss(test000064::MODEL_STRING101);
1980  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
1981  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
1982  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 3).empty() == false);
1983  SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
1984  CPPUNIT_ASSERT(pDocument != NULL);
1985  Model* pModel = pDocument->getModel();
1986  CPPUNIT_ASSERT(pModel != NULL);
1987  // check the units
1988  UnitDefinition* pUDef = pModel->getUnitDefinition("time");
1989  Unit* pUnit = NULL;
1990 
1991  // since second is the default time unit, it does not have to be exported and
1992  // might be NULL
1993  if (pUDef != NULL)
1994  {
1995  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
1996  pUnit = pUDef->getUnit(0);
1997  CPPUNIT_ASSERT(pUnit != NULL);
1998  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_SECOND);
1999  CPPUNIT_ASSERT(pUnit->getScale() == 0);
2000  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
2001  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
2002  }
2003 
2004  pUDef = pModel->getUnitDefinition("substance");
2005  CPPUNIT_ASSERT(pUDef != NULL);
2006  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
2007  pUnit = pUDef->getUnit(0);
2008  CPPUNIT_ASSERT(pUnit != NULL);
2009  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_MOLE);
2010  CPPUNIT_ASSERT(pUnit->getScale() == -3);
2011  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
2012  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
2013  pUDef = pModel->getUnitDefinition("volume");
2014  CPPUNIT_ASSERT(pUDef != NULL);
2015  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
2016  pUnit = pUDef->getUnit(0);
2017  CPPUNIT_ASSERT(pUnit != NULL);
2018  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_LITRE);
2019  CPPUNIT_ASSERT(pUnit->getScale() == -3);
2020  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
2021  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
2022  // assert that there is only one compartment and
2023  // assert the compartment is constant
2024  CPPUNIT_ASSERT(pModel->getNumCompartments() == 1);
2025  Compartment* pCompartment = pModel->getCompartment(0);
2026  CPPUNIT_ASSERT(pCompartment->getConstant() == true);
2027  CPPUNIT_ASSERT(pModel->getNumParameters() == 1);
2028  Parameter* pParameter = pModel->getParameter(0);
2029  CPPUNIT_ASSERT(pParameter != NULL);
2030  CPPUNIT_ASSERT(pModel->getNumSpecies() == 2);
2031  Species* pSpecies1 = pModel->getSpecies(0);
2032  CPPUNIT_ASSERT(pSpecies1->getHasOnlySubstanceUnits() == false);
2033  std::string idSpeciesA = pSpecies1->getId();
2034  Species* pSpecies2 = pModel->getSpecies(1);
2035  CPPUNIT_ASSERT(pSpecies2->getHasOnlySubstanceUnits() == false);
2036  CPPUNIT_ASSERT(pModel->getNumRules() == 1);
2037  AssignmentRule* pRule = dynamic_cast<AssignmentRule*>(pModel->getRule(0));
2038  CPPUNIT_ASSERT(pRule != NULL);
2039  CPPUNIT_ASSERT(pRule->getVariable() == pSpecies1->getId());
2040  const ASTNode* pMath = pRule->getMath();
2041  CPPUNIT_ASSERT(pMath != NULL);
2042  // make sure the mathematical expression contains only one node that is a
2043  // reference to the global parameter
2044  CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
2045  CPPUNIT_ASSERT(pMath->getName() == pParameter->getId());
2046  CPPUNIT_ASSERT(pModel->getNumReactions() == 0);
2047 }
SBMLDocument * getCurrentSBMLDocument()
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static const char * MODEL_STRING101
Definition: test000064.h:81
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000064.h:98
void test000064::test_export_rule_expression_and_hasOnlySubstanceUnits_2 ( )

Definition at line 2092 of file test000064.cpp.

References CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CCopasiDataModel::getModel(), load_cps_model_from_stream(), MODEL_STRING102, and pCOPASIDATAMODEL.

2093 {
2094  // load the CPS file
2095  // export to SBML
2096  // check the resulting SBML model
2097  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
2098  std::istringstream iss(test000064::MODEL_STRING102);
2099  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
2100  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
2101  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 3).empty() == false);
2102  SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
2103  CPPUNIT_ASSERT(pDocument != NULL);
2104  Model* pModel = pDocument->getModel();
2105  CPPUNIT_ASSERT(pModel != NULL);
2106  // check the units
2107  UnitDefinition* pUDef = pModel->getUnitDefinition("time");
2108  Unit* pUnit = NULL;
2109 
2110  // since second is the default time unit, it does not have to be exported and
2111  // might be NULL
2112  if (pUDef != NULL)
2113  {
2114  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
2115  pUnit = pUDef->getUnit(0);
2116  CPPUNIT_ASSERT(pUnit != NULL);
2117  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_SECOND);
2118  CPPUNIT_ASSERT(pUnit->getScale() == 0);
2119  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
2120  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
2121  }
2122 
2123  pUDef = pModel->getUnitDefinition("substance");
2124  CPPUNIT_ASSERT(pUDef != NULL);
2125  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
2126  pUnit = pUDef->getUnit(0);
2127  CPPUNIT_ASSERT(pUnit != NULL);
2128  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_MOLE);
2129  CPPUNIT_ASSERT(pUnit->getScale() == -3);
2130  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
2131  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
2132  pUDef = pModel->getUnitDefinition("volume");
2133  CPPUNIT_ASSERT(pUDef != NULL);
2134  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
2135  pUnit = pUDef->getUnit(0);
2136  CPPUNIT_ASSERT(pUnit != NULL);
2137  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_LITRE);
2138  CPPUNIT_ASSERT(pUnit->getScale() == -3);
2139  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
2140  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
2141  // assert that there is only one compartment and
2142  // assert the compartment is not constant
2143  CPPUNIT_ASSERT(pModel->getNumCompartments() == 1);
2144  Compartment* pCompartment = pModel->getCompartment(0);
2145  CPPUNIT_ASSERT(pCompartment->getConstant() == false);
2146  CPPUNIT_ASSERT(pModel->getNumParameters() == 2);
2147  Parameter* pParameter1 = pModel->getParameter(0);
2148  CPPUNIT_ASSERT(pParameter1 != NULL);
2149  Parameter* pParameter2 = NULL;
2150 
2151  if (pParameter1->getName() == "K")
2152  {
2153  pParameter2 = pModel->getParameter(1);
2154  CPPUNIT_ASSERT(pParameter2 != NULL);
2155  }
2156  else
2157  {
2158  pParameter2 = pParameter1;
2159  pParameter1 = pModel->getParameter(1);
2160  CPPUNIT_ASSERT(pParameter1 != NULL);
2161  }
2162 
2163  CPPUNIT_ASSERT(pParameter1->getName() == "K");
2164  CPPUNIT_ASSERT(pParameter2->getName() == "P");
2165  CPPUNIT_ASSERT(pModel->getNumSpecies() == 2);
2166  Species* pSpecies1 = pModel->getSpecies(0);
2167  CPPUNIT_ASSERT(pSpecies1->getHasOnlySubstanceUnits() == true);
2168  std::string idSpeciesA = pSpecies1->getId();
2169  Species* pSpecies2 = pModel->getSpecies(1);
2170  CPPUNIT_ASSERT(pSpecies2->getHasOnlySubstanceUnits() == true);
2171  CPPUNIT_ASSERT(pModel->getNumRules() == 2);
2172  AssignmentRule* pRule1 = dynamic_cast<AssignmentRule*>(pModel->getRule(0));
2173  AssignmentRule* pRule2 = NULL;
2174  CPPUNIT_ASSERT(pRule1 != NULL);
2175 
2176  if (pRule1->getVariable() == pSpecies1->getId())
2177  {
2178  pRule2 = pRule1;
2179  pRule1 = dynamic_cast<AssignmentRule*>(pModel->getRule(1));
2180  }
2181  else
2182  {
2183  pRule2 = dynamic_cast<AssignmentRule*>(pModel->getRule(1));
2184  }
2185 
2186  // check the rule for the compartment
2187  const ASTNode* pMath = pRule1->getMath();
2188  CPPUNIT_ASSERT(pMath != NULL);
2189  // make sure the mathematical expression contains only one node that is a
2190  // reference to the global parameter P
2191  CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
2192  CPPUNIT_ASSERT(pMath->getName() == pParameter2->getId());
2193  pMath = pRule2->getMath();
2194  CPPUNIT_ASSERT(pMath != NULL);
2195  // make sure the mathematical expression contains a multiplication of the
2196  // global parameter K and the compartment volume
2197  CPPUNIT_ASSERT(pMath->getType() == AST_TIMES);
2198  CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
2199  ASTNode* pChild1 = pMath->getChild(0);
2200  ASTNode* pChild2 = pMath->getChild(1);
2201  CPPUNIT_ASSERT(pChild1->getType() == AST_NAME);
2202  CPPUNIT_ASSERT(pChild2->getType() == AST_NAME);
2203  CPPUNIT_ASSERT(pChild1->getName() == pParameter1->getId() || pChild2->getName() == pParameter1->getId());
2204  CPPUNIT_ASSERT(pChild1->getName() == pCompartment->getId() || pChild2->getName() == pCompartment->getId());
2205  CPPUNIT_ASSERT(pModel->getNumReactions() == 0);
2206 }
SBMLDocument * getCurrentSBMLDocument()
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static const char * MODEL_STRING102
Definition: test000064.h:82
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000064.h:98
void test000064::test_export_rule_expression_and_hasOnlySubstanceUnits_3 ( )

Definition at line 2257 of file test000064.cpp.

References CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CCopasiDataModel::getModel(), load_cps_model_from_stream(), MODEL_STRING103, and pCOPASIDATAMODEL.

2258 {
2259  // load the CPS file
2260  // export to SBML
2261  // check the resulting SBML model
2262  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
2263  std::istringstream iss(test000064::MODEL_STRING103);
2264  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
2265  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
2266  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 3).empty() == false);
2267  SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
2268  CPPUNIT_ASSERT(pDocument != NULL);
2269  Model* pModel = pDocument->getModel();
2270  CPPUNIT_ASSERT(pModel != NULL);
2271  // check the units
2272  UnitDefinition* pUDef = pModel->getUnitDefinition("time");
2273  Unit* pUnit = NULL;
2274 
2275  // since second is the default time unit, it does not have to be exported and
2276  // might be NULL
2277  if (pUDef != NULL)
2278  {
2279  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
2280  pUnit = pUDef->getUnit(0);
2281  CPPUNIT_ASSERT(pUnit != NULL);
2282  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_SECOND);
2283  CPPUNIT_ASSERT(pUnit->getScale() == 0);
2284  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
2285  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
2286  }
2287 
2288  pUDef = pModel->getUnitDefinition("substance");
2289  CPPUNIT_ASSERT(pUDef != NULL);
2290  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
2291  pUnit = pUDef->getUnit(0);
2292  CPPUNIT_ASSERT(pUnit != NULL);
2293  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_ITEM);
2294  CPPUNIT_ASSERT(pUnit->getScale() == 0);
2295  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
2296  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
2297  pUDef = pModel->getUnitDefinition("volume");
2298  CPPUNIT_ASSERT(pUDef != NULL);
2299  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
2300  pUnit = pUDef->getUnit(0);
2301  CPPUNIT_ASSERT(pUnit != NULL);
2302  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_LITRE);
2303  CPPUNIT_ASSERT(pUnit->getScale() == -3);
2304  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
2305  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
2306  // assert that there is only one compartment and
2307  // assert the compartment is constant
2308  CPPUNIT_ASSERT(pModel->getNumCompartments() == 1);
2309  Compartment* pCompartment = pModel->getCompartment(0);
2310  CPPUNIT_ASSERT(pCompartment->getConstant() == true);
2311  CPPUNIT_ASSERT(pModel->getNumParameters() == 1);
2312  Parameter* pParameter = pModel->getParameter(0);
2313  CPPUNIT_ASSERT(pParameter != NULL);
2314  CPPUNIT_ASSERT(pModel->getNumSpecies() == 2);
2315  Species* pSpecies1 = pModel->getSpecies(0);
2316  CPPUNIT_ASSERT(pSpecies1->getHasOnlySubstanceUnits() == false);
2317  std::string idSpeciesA = pSpecies1->getId();
2318  Species* pSpecies2 = pModel->getSpecies(1);
2319  CPPUNIT_ASSERT(pSpecies2->getHasOnlySubstanceUnits() == false);
2320  CPPUNIT_ASSERT(pModel->getNumRules() == 1);
2321  AssignmentRule* pRule = dynamic_cast<AssignmentRule*>(pModel->getRule(0));
2322  CPPUNIT_ASSERT(pRule != NULL);
2323  CPPUNIT_ASSERT(pRule->getVariable() == pSpecies1->getId());
2324  const ASTNode* pMath = pRule->getMath();
2325  CPPUNIT_ASSERT(pMath != NULL);
2326  // make sure the mathematical expression contains only one node that is a
2327  // reference to the global parameter
2328  CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
2329  CPPUNIT_ASSERT(pMath->getName() == pParameter->getId());
2330  CPPUNIT_ASSERT(pModel->getNumReactions() == 0);
2331 }
SBMLDocument * getCurrentSBMLDocument()
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000064.h:98
static const char * MODEL_STRING103
Definition: test000064.h:83
void test000064::test_export_rule_expression_and_hasOnlySubstanceUnits_4 ( )

Definition at line 2376 of file test000064.cpp.

References CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CCopasiDataModel::getModel(), load_cps_model_from_stream(), MODEL_STRING104, and pCOPASIDATAMODEL.

2377 {
2378  // load the CPS file
2379  // export to SBML
2380  // check the resulting SBML model
2381  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
2382  std::istringstream iss(test000064::MODEL_STRING104);
2383  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
2384  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
2385  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 3).empty() == false);
2386  SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
2387  CPPUNIT_ASSERT(pDocument != NULL);
2388  Model* pModel = pDocument->getModel();
2389  CPPUNIT_ASSERT(pModel != NULL);
2390  // check the units
2391  UnitDefinition* pUDef = pModel->getUnitDefinition("time");
2392  Unit* pUnit = NULL;
2393 
2394  // since second is the default time unit, it does not have to be exported and
2395  // might be NULL
2396  if (pUDef != NULL)
2397  {
2398  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
2399  pUnit = pUDef->getUnit(0);
2400  CPPUNIT_ASSERT(pUnit != NULL);
2401  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_SECOND);
2402  CPPUNIT_ASSERT(pUnit->getScale() == 0);
2403  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
2404  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
2405  }
2406 
2407  pUDef = pModel->getUnitDefinition("substance");
2408  CPPUNIT_ASSERT(pUDef != NULL);
2409  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
2410  pUnit = pUDef->getUnit(0);
2411  CPPUNIT_ASSERT(pUnit != NULL);
2412  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_ITEM);
2413  CPPUNIT_ASSERT(pUnit->getScale() == 0);
2414  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
2415  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
2416  pUDef = pModel->getUnitDefinition("volume");
2417  CPPUNIT_ASSERT(pUDef != NULL);
2418  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
2419  pUnit = pUDef->getUnit(0);
2420  CPPUNIT_ASSERT(pUnit != NULL);
2421  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_LITRE);
2422  CPPUNIT_ASSERT(pUnit->getScale() == -3);
2423  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
2424  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
2425  // assert that there is only one compartment and
2426  // assert the compartment is not constant
2427  CPPUNIT_ASSERT(pModel->getNumCompartments() == 1);
2428  Compartment* pCompartment = pModel->getCompartment(0);
2429  CPPUNIT_ASSERT(pCompartment->getConstant() == false);
2430  CPPUNIT_ASSERT(pModel->getNumParameters() == 2);
2431  Parameter* pParameter1 = pModel->getParameter(0);
2432  CPPUNIT_ASSERT(pParameter1 != NULL);
2433  Parameter* pParameter2 = NULL;
2434 
2435  if (pParameter1->getName() == "K")
2436  {
2437  pParameter2 = pModel->getParameter(1);
2438  CPPUNIT_ASSERT(pParameter2 != NULL);
2439  }
2440  else
2441  {
2442  pParameter2 = pParameter1;
2443  pParameter1 = pModel->getParameter(1);
2444  CPPUNIT_ASSERT(pParameter1 != NULL);
2445  }
2446 
2447  CPPUNIT_ASSERT(pParameter1->getName() == "K");
2448  CPPUNIT_ASSERT(pParameter2->getName() == "P");
2449  CPPUNIT_ASSERT(pModel->getNumSpecies() == 2);
2450  Species* pSpecies1 = pModel->getSpecies(0);
2451  CPPUNIT_ASSERT(pSpecies1->getHasOnlySubstanceUnits() == true);
2452  std::string idSpeciesA = pSpecies1->getId();
2453  Species* pSpecies2 = pModel->getSpecies(1);
2454  CPPUNIT_ASSERT(pSpecies2->getHasOnlySubstanceUnits() == true);
2455  CPPUNIT_ASSERT(pModel->getNumRules() == 2);
2456  AssignmentRule* pRule1 = dynamic_cast<AssignmentRule*>(pModel->getRule(0));
2457  AssignmentRule* pRule2 = NULL;
2458  CPPUNIT_ASSERT(pRule1 != NULL);
2459 
2460  if (pRule1->getVariable() == pSpecies1->getId())
2461  {
2462  pRule2 = pRule1;
2463  pRule1 = dynamic_cast<AssignmentRule*>(pModel->getRule(1));
2464  }
2465  else
2466  {
2467  pRule2 = dynamic_cast<AssignmentRule*>(pModel->getRule(1));
2468  }
2469 
2470  // check the rule for the compartment
2471  const ASTNode* pMath = pRule1->getMath();
2472  CPPUNIT_ASSERT(pMath != NULL);
2473  // make sure the mathematical expression contains only one node that is a
2474  // reference to the global parameter P
2475  CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
2476  CPPUNIT_ASSERT(pMath->getName() == pParameter2->getId());
2477  pMath = pRule2->getMath();
2478  CPPUNIT_ASSERT(pMath != NULL);
2479  // make sure the mathematical expression contains a multiplication of the
2480  // global parameter K and the compartment volume
2481  CPPUNIT_ASSERT(pMath->getType() == AST_TIMES);
2482  CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
2483  ASTNode* pChild1 = pMath->getChild(0);
2484  ASTNode* pChild2 = pMath->getChild(1);
2485  CPPUNIT_ASSERT(pChild1->getType() == AST_NAME);
2486  CPPUNIT_ASSERT(pChild2->getType() == AST_NAME);
2487  CPPUNIT_ASSERT(pChild1->getName() == pParameter1->getId() || pChild2->getName() == pParameter1->getId());
2488  CPPUNIT_ASSERT(pChild1->getName() == pCompartment->getId() || pChild2->getName() == pCompartment->getId());
2489  CPPUNIT_ASSERT(pModel->getNumReactions() == 0);
2490 }
SBMLDocument * getCurrentSBMLDocument()
static const char * MODEL_STRING104
Definition: test000064.h:84
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000064.h:98
void test000064::test_export_rule_expression_and_hasOnlySubstanceUnits_5 ( )

Definition at line 2540 of file test000064.cpp.

References CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CCopasiDataModel::getModel(), load_cps_model_from_stream(), MODEL_STRING105, and pCOPASIDATAMODEL.

2541 {
2542  // load the CPS file
2543  // export to SBML
2544  // check the resulting SBML model
2545  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
2546  std::istringstream iss(test000064::MODEL_STRING105);
2547  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
2548  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
2549  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 3).empty() == false);
2550  SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
2551  CPPUNIT_ASSERT(pDocument != NULL);
2552  Model* pModel = pDocument->getModel();
2553  CPPUNIT_ASSERT(pModel != NULL);
2554  // check the units
2555  UnitDefinition* pUDef = pModel->getUnitDefinition("time");
2556  Unit* pUnit = NULL;
2557 
2558  // since second is the default time unit, it does not have to be exported and
2559  // might be NULL
2560  if (pUDef != NULL)
2561  {
2562  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
2563  pUnit = pUDef->getUnit(0);
2564  CPPUNIT_ASSERT(pUnit != NULL);
2565  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_SECOND);
2566  CPPUNIT_ASSERT(pUnit->getScale() == 0);
2567  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
2568  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
2569  }
2570 
2571  pUDef = pModel->getUnitDefinition("substance");
2572  CPPUNIT_ASSERT(pUDef != NULL);
2573  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
2574  pUnit = pUDef->getUnit(0);
2575  CPPUNIT_ASSERT(pUnit != NULL);
2576  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_MOLE);
2577  CPPUNIT_ASSERT(pUnit->getScale() == -3);
2578  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
2579  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
2580  pUDef = pModel->getUnitDefinition("volume");
2581  CPPUNIT_ASSERT(pUDef != NULL);
2582  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
2583  pUnit = pUDef->getUnit(0);
2584  CPPUNIT_ASSERT(pUnit != NULL);
2585  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_LITRE);
2586  CPPUNIT_ASSERT(pUnit->getScale() == -3);
2587  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
2588  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
2589  // assert that there is only one compartment and
2590  // assert the compartment is constant
2591  CPPUNIT_ASSERT(pModel->getNumCompartments() == 1);
2592  Compartment* pCompartment = pModel->getCompartment(0);
2593  CPPUNIT_ASSERT(pCompartment->getConstant() == true);
2594  CPPUNIT_ASSERT(pModel->getNumParameters() == 1);
2595  Parameter* pParameter = pModel->getParameter(0);
2596  CPPUNIT_ASSERT(pParameter != NULL);
2597  CPPUNIT_ASSERT(pModel->getNumSpecies() == 2);
2598  Species* pSpecies1 = pModel->getSpecies(0);
2599  CPPUNIT_ASSERT(pSpecies1->getHasOnlySubstanceUnits() == false);
2600  std::string idSpeciesA = pSpecies1->getId();
2601  Species* pSpecies2 = pModel->getSpecies(1);
2602  CPPUNIT_ASSERT(pSpecies2->getHasOnlySubstanceUnits() == false);
2603  CPPUNIT_ASSERT(pModel->getNumRules() == 1);
2604  AssignmentRule* pRule = dynamic_cast<AssignmentRule*>(pModel->getRule(0));
2605  CPPUNIT_ASSERT(pRule != NULL);
2606  CPPUNIT_ASSERT(pRule->getVariable() == pSpecies1->getId());
2607  const ASTNode* pMath = pRule->getMath();
2608  CPPUNIT_ASSERT(pMath != NULL);
2609  // make sure the mathematical expression contains only one node that is a
2610  // reference to the global parameter divided by the compartment volume
2611  CPPUNIT_ASSERT(pMath->getType() == AST_DIVIDE);
2612  CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
2613  ASTNode* pChild = pMath->getChild(0);
2614  CPPUNIT_ASSERT(pChild->getType() == AST_NAME);
2615  CPPUNIT_ASSERT(pChild->getName() == pParameter->getId());
2616  pChild = pMath->getChild(1);
2617  CPPUNIT_ASSERT(pChild->getType() == AST_NAME);
2618  CPPUNIT_ASSERT(pChild->getName() == pCompartment->getId());
2619  CPPUNIT_ASSERT(pModel->getNumReactions() == 0);
2620 }
SBMLDocument * getCurrentSBMLDocument()
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static const char * MODEL_STRING105
Definition: test000064.h:85
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000064.h:98
void test000064::test_export_rule_expression_and_hasOnlySubstanceUnits_6 ( )

Definition at line 2665 of file test000064.cpp.

References CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CCopasiDataModel::getModel(), load_cps_model_from_stream(), MODEL_STRING106, and pCOPASIDATAMODEL.

2666 {
2667  // load the CPS file
2668  // export to SBML
2669  // check the resulting SBML model
2670  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
2671  std::istringstream iss(test000064::MODEL_STRING106);
2672  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
2673  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
2674  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 3).empty() == false);
2675  SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
2676  CPPUNIT_ASSERT(pDocument != NULL);
2677  Model* pModel = pDocument->getModel();
2678  CPPUNIT_ASSERT(pModel != NULL);
2679  // check the units
2680  UnitDefinition* pUDef = pModel->getUnitDefinition("time");
2681  Unit* pUnit = NULL;
2682 
2683  // since second is the default time unit, it does not have to be exported and
2684  // might be NULL
2685  if (pUDef != NULL)
2686  {
2687  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
2688  pUnit = pUDef->getUnit(0);
2689  CPPUNIT_ASSERT(pUnit != NULL);
2690  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_SECOND);
2691  CPPUNIT_ASSERT(pUnit->getScale() == 0);
2692  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
2693  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
2694  }
2695 
2696  pUDef = pModel->getUnitDefinition("substance");
2697  CPPUNIT_ASSERT(pUDef != NULL);
2698  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
2699  pUnit = pUDef->getUnit(0);
2700  CPPUNIT_ASSERT(pUnit != NULL);
2701  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_MOLE);
2702  CPPUNIT_ASSERT(pUnit->getScale() == -3);
2703  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
2704  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
2705  pUDef = pModel->getUnitDefinition("volume");
2706  CPPUNIT_ASSERT(pUDef != NULL);
2707  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
2708  pUnit = pUDef->getUnit(0);
2709  CPPUNIT_ASSERT(pUnit != NULL);
2710  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_LITRE);
2711  CPPUNIT_ASSERT(pUnit->getScale() == -3);
2712  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
2713  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
2714  // assert that there is only one compartment and
2715  // assert the compartment is not constant
2716  CPPUNIT_ASSERT(pModel->getNumCompartments() == 1);
2717  Compartment* pCompartment = pModel->getCompartment(0);
2718  CPPUNIT_ASSERT(pCompartment->getConstant() == false);
2719  CPPUNIT_ASSERT(pModel->getNumParameters() == 2);
2720  Parameter* pParameter1 = pModel->getParameter(0);
2721  CPPUNIT_ASSERT(pParameter1 != NULL);
2722  Parameter* pParameter2 = NULL;
2723 
2724  if (pParameter1->getName() == "K")
2725  {
2726  pParameter2 = pModel->getParameter(1);
2727  CPPUNIT_ASSERT(pParameter2 != NULL);
2728  }
2729  else
2730  {
2731  pParameter2 = pParameter1;
2732  pParameter1 = pModel->getParameter(1);
2733  CPPUNIT_ASSERT(pParameter1 != NULL);
2734  }
2735 
2736  CPPUNIT_ASSERT(pParameter1->getName() == "K");
2737  CPPUNIT_ASSERT(pParameter2->getName() == "P");
2738  CPPUNIT_ASSERT(pModel->getNumSpecies() == 2);
2739  Species* pSpecies1 = pModel->getSpecies(0);
2740  CPPUNIT_ASSERT(pSpecies1->getHasOnlySubstanceUnits() == true);
2741  std::string idSpeciesA = pSpecies1->getId();
2742  Species* pSpecies2 = pModel->getSpecies(1);
2743  CPPUNIT_ASSERT(pSpecies2->getHasOnlySubstanceUnits() == true);
2744  CPPUNIT_ASSERT(pModel->getNumRules() == 2);
2745  AssignmentRule* pRule1 = dynamic_cast<AssignmentRule*>(pModel->getRule(0));
2746  AssignmentRule* pRule2 = NULL;
2747  CPPUNIT_ASSERT(pRule1 != NULL);
2748 
2749  if (pRule1->getVariable() == pSpecies1->getId())
2750  {
2751  pRule2 = pRule1;
2752  pRule1 = dynamic_cast<AssignmentRule*>(pModel->getRule(1));
2753  }
2754  else
2755  {
2756  pRule2 = dynamic_cast<AssignmentRule*>(pModel->getRule(1));
2757  }
2758 
2759  // check the rule for the compartment
2760  const ASTNode* pMath = pRule1->getMath();
2761  CPPUNIT_ASSERT(pMath != NULL);
2762  // make sure the mathematical expression contains only one node that is a
2763  // reference to the global parameter P
2764  CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
2765  CPPUNIT_ASSERT(pMath->getName() == pParameter2->getId());
2766  pMath = pRule2->getMath();
2767  CPPUNIT_ASSERT(pMath != NULL);
2768  // make sure the mathematical expression contains a multiplication of the
2769  // global parameter K and the compartment volume
2770  CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
2771  CPPUNIT_ASSERT(pMath->getName() == pParameter1->getId());
2772  CPPUNIT_ASSERT(pModel->getNumReactions() == 0);
2773 }
SBMLDocument * getCurrentSBMLDocument()
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000064.h:98
static const char * MODEL_STRING106
Definition: test000064.h:86
void test000064::test_export_rule_expression_and_hasOnlySubstanceUnits_7 ( )

Definition at line 2824 of file test000064.cpp.

References CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CCopasiDataModel::getModel(), load_cps_model_from_stream(), MODEL_STRING107, and pCOPASIDATAMODEL.

2825 {
2826  // load the CPS file
2827  // export to SBML
2828  // check the resulting SBML model
2829  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
2830  std::istringstream iss(test000064::MODEL_STRING107);
2831  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
2832  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
2833  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 3).empty() == false);
2834  SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
2835  CPPUNIT_ASSERT(pDocument != NULL);
2836  Model* pModel = pDocument->getModel();
2837  CPPUNIT_ASSERT(pModel != NULL);
2838  // check the units
2839  UnitDefinition* pUDef = pModel->getUnitDefinition("time");
2840  Unit* pUnit = NULL;
2841 
2842  // since second is the default time unit, it does not have to be exported and
2843  // might be NULL
2844  if (pUDef != NULL)
2845  {
2846  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
2847  pUnit = pUDef->getUnit(0);
2848  CPPUNIT_ASSERT(pUnit != NULL);
2849  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_SECOND);
2850  CPPUNIT_ASSERT(pUnit->getScale() == 0);
2851  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
2852  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
2853  }
2854 
2855  pUDef = pModel->getUnitDefinition("substance");
2856  CPPUNIT_ASSERT(pUDef != NULL);
2857  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
2858  pUnit = pUDef->getUnit(0);
2859  CPPUNIT_ASSERT(pUnit != NULL);
2860  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_ITEM);
2861  CPPUNIT_ASSERT(pUnit->getScale() == 0);
2862  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
2863  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
2864  pUDef = pModel->getUnitDefinition("volume");
2865  CPPUNIT_ASSERT(pUDef != NULL);
2866  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
2867  pUnit = pUDef->getUnit(0);
2868  CPPUNIT_ASSERT(pUnit != NULL);
2869  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_LITRE);
2870  CPPUNIT_ASSERT(pUnit->getScale() == -3);
2871  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
2872  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
2873  // assert that there is only one compartment and
2874  // assert the compartment is constant
2875  CPPUNIT_ASSERT(pModel->getNumCompartments() == 1);
2876  Compartment* pCompartment = pModel->getCompartment(0);
2877  CPPUNIT_ASSERT(pCompartment->getConstant() == true);
2878  CPPUNIT_ASSERT(pModel->getNumParameters() == 1);
2879  Parameter* pParameter = pModel->getParameter(0);
2880  CPPUNIT_ASSERT(pParameter != NULL);
2881  CPPUNIT_ASSERT(pModel->getNumSpecies() == 2);
2882  Species* pSpecies1 = pModel->getSpecies(0);
2883  CPPUNIT_ASSERT(pSpecies1->getHasOnlySubstanceUnits() == false);
2884  std::string idSpeciesA = pSpecies1->getId();
2885  Species* pSpecies2 = pModel->getSpecies(1);
2886  CPPUNIT_ASSERT(pSpecies2->getHasOnlySubstanceUnits() == false);
2887  CPPUNIT_ASSERT(pModel->getNumRules() == 1);
2888  AssignmentRule* pRule = dynamic_cast<AssignmentRule*>(pModel->getRule(0));
2889  CPPUNIT_ASSERT(pRule != NULL);
2890  CPPUNIT_ASSERT(pRule->getVariable() == pSpecies1->getId());
2891  const ASTNode* pMath = pRule->getMath();
2892  CPPUNIT_ASSERT(pMath != NULL);
2893  // make sure the mathematical expression contains only one node that is a
2894  // reference to the global parameter
2895  CPPUNIT_ASSERT(pMath->getType() == AST_DIVIDE);
2896  CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
2897  ASTNode* pChild = pMath->getChild(0);
2898  CPPUNIT_ASSERT(pChild != NULL);
2899  CPPUNIT_ASSERT(pChild->getName() == pParameter->getId());
2900  pChild = pMath->getChild(1);
2901  CPPUNIT_ASSERT(pChild != NULL);
2902  CPPUNIT_ASSERT(pChild->getName() == pCompartment->getId());
2903  CPPUNIT_ASSERT(pModel->getNumReactions() == 0);
2904 }
SBMLDocument * getCurrentSBMLDocument()
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000064.h:98
static const char * MODEL_STRING107
Definition: test000064.h:87
void test000064::test_export_rule_expression_and_hasOnlySubstanceUnits_8 ( )

Definition at line 2949 of file test000064.cpp.

References CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CCopasiDataModel::getModel(), load_cps_model_from_stream(), MODEL_STRING108, and pCOPASIDATAMODEL.

2950 {
2951  // load the CPS file
2952  // export to SBML
2953  // check the resulting SBML model
2954  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
2955  std::istringstream iss(test000064::MODEL_STRING108);
2956  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
2957  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
2958  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 3).empty() == false);
2959  SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
2960  CPPUNIT_ASSERT(pDocument != NULL);
2961  Model* pModel = pDocument->getModel();
2962  CPPUNIT_ASSERT(pModel != NULL);
2963  // check the units
2964  UnitDefinition* pUDef = pModel->getUnitDefinition("time");
2965  Unit* pUnit = NULL;
2966 
2967  // since second is the default time unit, it does not have to be exported and
2968  // might be NULL
2969  if (pUDef != NULL)
2970  {
2971  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
2972  pUnit = pUDef->getUnit(0);
2973  CPPUNIT_ASSERT(pUnit != NULL);
2974  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_SECOND);
2975  CPPUNIT_ASSERT(pUnit->getScale() == 0);
2976  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
2977  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
2978  }
2979 
2980  pUDef = pModel->getUnitDefinition("substance");
2981  CPPUNIT_ASSERT(pUDef != NULL);
2982  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
2983  pUnit = pUDef->getUnit(0);
2984  CPPUNIT_ASSERT(pUnit != NULL);
2985  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_ITEM);
2986  CPPUNIT_ASSERT(pUnit->getScale() == 0);
2987  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
2988  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
2989  pUDef = pModel->getUnitDefinition("volume");
2990  CPPUNIT_ASSERT(pUDef != NULL);
2991  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
2992  pUnit = pUDef->getUnit(0);
2993  CPPUNIT_ASSERT(pUnit != NULL);
2994  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_LITRE);
2995  CPPUNIT_ASSERT(pUnit->getScale() == -3);
2996  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
2997  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
2998  // assert that there is only one compartment and
2999  // assert the compartment is not constant
3000  CPPUNIT_ASSERT(pModel->getNumCompartments() == 1);
3001  Compartment* pCompartment = pModel->getCompartment(0);
3002  CPPUNIT_ASSERT(pCompartment->getConstant() == false);
3003  CPPUNIT_ASSERT(pModel->getNumParameters() == 2);
3004  Parameter* pParameter1 = pModel->getParameter(0);
3005  CPPUNIT_ASSERT(pParameter1 != NULL);
3006  Parameter* pParameter2 = NULL;
3007 
3008  if (pParameter1->getName() == "K")
3009  {
3010  pParameter2 = pModel->getParameter(1);
3011  CPPUNIT_ASSERT(pParameter2 != NULL);
3012  }
3013  else
3014  {
3015  pParameter2 = pParameter1;
3016  pParameter1 = pModel->getParameter(1);
3017  CPPUNIT_ASSERT(pParameter1 != NULL);
3018  }
3019 
3020  CPPUNIT_ASSERT(pParameter1->getName() == "K");
3021  CPPUNIT_ASSERT(pParameter2->getName() == "P");
3022  CPPUNIT_ASSERT(pModel->getNumSpecies() == 2);
3023  Species* pSpecies1 = pModel->getSpecies(0);
3024  CPPUNIT_ASSERT(pSpecies1->getHasOnlySubstanceUnits() == true);
3025  std::string idSpeciesA = pSpecies1->getId();
3026  Species* pSpecies2 = pModel->getSpecies(1);
3027  CPPUNIT_ASSERT(pSpecies2->getHasOnlySubstanceUnits() == true);
3028  CPPUNIT_ASSERT(pModel->getNumRules() == 2);
3029  AssignmentRule* pRule1 = dynamic_cast<AssignmentRule*>(pModel->getRule(0));
3030  AssignmentRule* pRule2 = NULL;
3031  CPPUNIT_ASSERT(pRule1 != NULL);
3032 
3033  if (pRule1->getVariable() == pSpecies1->getId())
3034  {
3035  pRule2 = pRule1;
3036  pRule1 = dynamic_cast<AssignmentRule*>(pModel->getRule(1));
3037  }
3038  else
3039  {
3040  pRule2 = dynamic_cast<AssignmentRule*>(pModel->getRule(1));
3041  }
3042 
3043  // check the rule for the compartment
3044  const ASTNode* pMath = pRule1->getMath();
3045  CPPUNIT_ASSERT(pMath != NULL);
3046  // make sure the mathematical expression contains only one node that is a
3047  // reference to the global parameter P
3048  CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
3049  CPPUNIT_ASSERT(pMath->getName() == pParameter2->getId());
3050  pMath = pRule2->getMath();
3051  CPPUNIT_ASSERT(pMath != NULL);
3052  // make sure the mathematical expression contains a multiplication of the
3053  // global parameter K and the compartment volume
3054  CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
3055  CPPUNIT_ASSERT(pMath->getName() == pParameter1->getId());
3056  CPPUNIT_ASSERT(pModel->getNumReactions() == 0);
3057 }
SBMLDocument * getCurrentSBMLDocument()
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
static const char * MODEL_STRING108
Definition: test000064.h:88
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000064.h:98
void test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_1 ( )

Definition at line 441 of file test000064.cpp.

References CEvaluationNodeOperator::DIVIDE, CModelEntity::FIXED, CCopasiNode< _Data >::getChild(), CCopasiDataModel::getModel(), CEvaluationNodeObject::getObjectCN(), CCopasiObject::getObjectName(), CCopasiObject::getObjectParent(), CEvaluationTree::getRoot(), CEvaluationNode::getType(), CEvaluationNode::getValue(), CEvaluationNodeLogical::GT, CCopasiDataModel::importSBMLFromString(), CCopasiObject::isReference(), CEvaluationNode::LOGICAL, CModel::ml, CModel::mMol, MODEL_STRING5, CEvaluationNode::NUMBER, CEvaluationNode::OBJECT, CCopasiDataModel::ObjectFromName(), CEvaluationNode::OPERATOR, pCOPASIDATAMODEL, CModelEntity::REACTIONS, CModel::s, CEvaluationNode::subType(), and CEvaluationNode::type().

442 {
443  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
444  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING5));
445  CModel* pModel = pDataModel->getModel();
446  CPPUNIT_ASSERT(pModel != NULL);
447  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::mMol);
448  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::ml);
449  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
450  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
451  const CCompartment* pCompartment = pModel->getCompartments()[0];
452  CPPUNIT_ASSERT(pCompartment != NULL);
453  CPPUNIT_ASSERT(pCompartment->getStatus() == CModelEntity::FIXED);
454  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 2);
455  CMetab* pA = pModel->getMetabolites()[0];
456  CPPUNIT_ASSERT(pA != NULL);
457  CPPUNIT_ASSERT(pA->getStatus() == CModelEntity::REACTIONS);
458  const CMetab* pB = pModel->getMetabolites()[1];
459  CPPUNIT_ASSERT(pB != NULL);
460  CPPUNIT_ASSERT(pB->getStatus() == CModelEntity::REACTIONS);
461  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
462  const CModelValue* pModelValue = pModel->getModelValues()[0];
463  CPPUNIT_ASSERT(pModelValue != NULL);
464  CPPUNIT_ASSERT(pModelValue->getStatus() == CModelEntity::FIXED);
465  CPPUNIT_ASSERT(pModel->getEvents().size() == 1);
466  const CEvent* pEvent = pModel->getEvents()[0];
467  CPPUNIT_ASSERT(pEvent != NULL);
468  // check the trigger expression
469  const CExpression* pExpr = pEvent->getTriggerExpressionPtr();
470  CPPUNIT_ASSERT(pExpr != NULL);
471  const CEvaluationNode* pNode = pExpr->getRoot();
472  CPPUNIT_ASSERT(pNode != NULL);
473  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::LOGICAL);
475  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getChild());
476  CPPUNIT_ASSERT(pNode != NULL);
477  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
478  const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
479  CPPUNIT_ASSERT(pObjectNode != NULL);
480  CCopasiObjectName objectCN = pObjectNode->getObjectCN();
481  CPPUNIT_ASSERT(!objectCN.empty());
482  std::vector<CCopasiContainer*> listOfContainers;
483  listOfContainers.push_back(pModel);
484  const CCopasiObject* pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
485  CPPUNIT_ASSERT(pObject != NULL);
486  CPPUNIT_ASSERT(pObject->isReference() == true);
487  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Time"));
488  CPPUNIT_ASSERT(pObject->getObjectParent() == pModel);
489  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getSibling());
490  CPPUNIT_ASSERT(pNode != NULL);
491  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::NUMBER);
492  const CEvaluationNodeNumber* pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pNode);
493  CPPUNIT_ASSERT(pNumberNode != NULL);
494  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 2.0) / 2.0) < 1e-6);
495  // check that there is no delay
496  const CExpression* pExpression = pEvent->getDelayExpressionPtr();
497  CPPUNIT_ASSERT(pExpression == NULL);
498  CPPUNIT_ASSERT(pEvent->getAssignments().size() == 1);
499  // check the event assignment
500  std::string key = pEvent->getAssignments()[0]->getTargetKey();
501  CPPUNIT_ASSERT(key == pA->getKey());
502  pExpression = pEvent->getAssignments()[0]->getExpressionPtr();
503  CPPUNIT_ASSERT(pExpression != NULL);
504  pNode = pExpression->getRoot();
505  CPPUNIT_ASSERT(pNode != NULL);
506  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OPERATOR);
508  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getChild());
509  CPPUNIT_ASSERT(pNode != NULL);
510  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
511  pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
512  CPPUNIT_ASSERT(pObjectNode != NULL);
513  objectCN = pObjectNode->getObjectCN();
514  CPPUNIT_ASSERT(!objectCN.empty());
515  pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
516  CPPUNIT_ASSERT(pObject != NULL);
517  CPPUNIT_ASSERT(pObject->isReference() == true);
518  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Value"));
519  CPPUNIT_ASSERT(pObject->getObjectParent() == pModelValue);
520  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getSibling());
521  CPPUNIT_ASSERT(pNode != NULL);
522  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
523  pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
524  CPPUNIT_ASSERT(pObjectNode != NULL);
525  objectCN = pObjectNode->getObjectCN();
526  CPPUNIT_ASSERT(!objectCN.empty());
527  pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
528  CPPUNIT_ASSERT(pObject != NULL);
529  CPPUNIT_ASSERT(pObject->isReference() == true);
530  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Volume"));
531  CPPUNIT_ASSERT(pObject->getObjectParent() == pCompartment);
532 }
Definition: CEvent.h:152
const std::string & getObjectName() const
const CRegisteredObjectName & getObjectCN() const
const C_FLOAT64 & getValue() const
const Type & getType() const
Definition: CMetab.h:178
static Type type(const Type &type)
bool isReference() const
static const char * MODEL_STRING5
Definition: test000064.h:67
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000064.h:98
static Type subType(const Type &type)
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50
CCopasiNode< Data > * getChild()
Definition: CCopasiNode.h:210
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
CEvaluationNode * getRoot()
CCopasiContainer * getObjectParent() const
void test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_2 ( )

Definition at line 590 of file test000064.cpp.

References CModelEntity::FIXED, CCopasiNode< _Data >::getChild(), CCopasiDataModel::getModel(), CEvaluationNodeObject::getObjectCN(), CCopasiObject::getObjectName(), CCopasiObject::getObjectParent(), CEvaluationTree::getRoot(), CEvaluationNode::getType(), CEvaluationNode::getValue(), CEvaluationNodeLogical::GT, CCopasiDataModel::importSBMLFromString(), CCopasiObject::isReference(), CEvaluationNode::LOGICAL, CModel::ml, CModel::mMol, MODEL_STRING6, CEvaluationNode::NUMBER, CEvaluationNode::OBJECT, CCopasiDataModel::ObjectFromName(), pCOPASIDATAMODEL, CModelEntity::REACTIONS, CModel::s, CEvaluationNode::subType(), and CEvaluationNode::type().

591 {
592  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
593  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING6));
594  CModel* pModel = pDataModel->getModel();
595  CPPUNIT_ASSERT(pModel != NULL);
596  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::mMol);
597  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::ml);
598  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
599  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
600  const CCompartment* pCompartment = pModel->getCompartments()[0];
601  CPPUNIT_ASSERT(pCompartment != NULL);
602  CPPUNIT_ASSERT(pCompartment->getStatus() == CModelEntity::FIXED);
603  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 2);
604  CMetab* pA = pModel->getMetabolites()[0];
605  CPPUNIT_ASSERT(pA != NULL);
606  CPPUNIT_ASSERT(pA->getStatus() == CModelEntity::REACTIONS);
607  const CMetab* pB = pModel->getMetabolites()[1];
608  CPPUNIT_ASSERT(pB != NULL);
609  CPPUNIT_ASSERT(pB->getStatus() == CModelEntity::REACTIONS);
610  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
611  const CModelValue* pModelValue = pModel->getModelValues()[0];
612  CPPUNIT_ASSERT(pModelValue != NULL);
613  CPPUNIT_ASSERT(pModelValue->getStatus() == CModelEntity::FIXED);
614  CPPUNIT_ASSERT(pModel->getEvents().size() == 1);
615  const CEvent* pEvent = pModel->getEvents()[0];
616  CPPUNIT_ASSERT(pEvent != NULL);
617  // check the trigger expression
618  const CExpression* pExpr = pEvent->getTriggerExpressionPtr();
619  CPPUNIT_ASSERT(pExpr != NULL);
620  const CEvaluationNode* pNode = pExpr->getRoot();
621  CPPUNIT_ASSERT(pNode != NULL);
622  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::LOGICAL);
624  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getChild());
625  CPPUNIT_ASSERT(pNode != NULL);
626  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
627  const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
628  CPPUNIT_ASSERT(pObjectNode != NULL);
629  CCopasiObjectName objectCN = pObjectNode->getObjectCN();
630  CPPUNIT_ASSERT(!objectCN.empty());
631  std::vector<CCopasiContainer*> listOfContainers;
632  listOfContainers.push_back(pModel);
633  const CCopasiObject* pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
634  CPPUNIT_ASSERT(pObject != NULL);
635  CPPUNIT_ASSERT(pObject->isReference() == true);
636  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Time"));
637  CPPUNIT_ASSERT(pObject->getObjectParent() == pModel);
638  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getSibling());
639  CPPUNIT_ASSERT(pNode != NULL);
640  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::NUMBER);
641  const CEvaluationNodeNumber* pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pNode);
642  CPPUNIT_ASSERT(pNumberNode != NULL);
643  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 2.0) / 2.0) < 1e-6);
644  // check that there is no delay
645  const CExpression* pExpression = pEvent->getDelayExpressionPtr();
646  CPPUNIT_ASSERT(pExpression == NULL);
647  CPPUNIT_ASSERT(pEvent->getAssignments().size() == 1);
648  // check the event assignment
649  std::string key = pEvent->getAssignments()[0]->getTargetKey();
650  CPPUNIT_ASSERT(key == pA->getKey());
651  pExpression = pEvent->getAssignments()[0]->getExpressionPtr();
652  CPPUNIT_ASSERT(pExpression != NULL);
653  pNode = pExpression->getRoot();
654  CPPUNIT_ASSERT(pNode != NULL);
655  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
656  pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
657  CPPUNIT_ASSERT(pObjectNode != NULL);
658  objectCN = pObjectNode->getObjectCN();
659  CPPUNIT_ASSERT(!objectCN.empty());
660  pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
661  CPPUNIT_ASSERT(pObject != NULL);
662  CPPUNIT_ASSERT(pObject->isReference() == true);
663  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Value"));
664  CPPUNIT_ASSERT(pObject->getObjectParent() == pModelValue);
665 }
Definition: CEvent.h:152
const std::string & getObjectName() const
const CRegisteredObjectName & getObjectCN() const
const C_FLOAT64 & getValue() const
const Type & getType() const
Definition: CMetab.h:178
static const char * MODEL_STRING6
Definition: test000064.h:68
static Type type(const Type &type)
bool isReference() const
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000064.h:98
static Type subType(const Type &type)
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50
CCopasiNode< Data > * getChild()
Definition: CCopasiNode.h:210
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
CEvaluationNode * getRoot()
CCopasiContainer * getObjectParent() const
void test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_3 ( )

Definition at line 723 of file test000064.cpp.

References CModelEntity::FIXED, CCopasiNode< _Data >::getChild(), CCopasiDataModel::getModel(), CEvaluationNodeObject::getObjectCN(), CCopasiObject::getObjectName(), CCopasiObject::getObjectParent(), CEvaluationTree::getRoot(), CEvaluationNode::getType(), CEvaluationNode::getValue(), CEvaluationNodeLogical::GT, CCopasiDataModel::importSBMLFromString(), CCopasiObject::isReference(), CEvaluationNode::LOGICAL, CModel::ml, MODEL_STRING7, CEvaluationNode::NUMBER, CModel::number, CEvaluationNode::OBJECT, CCopasiDataModel::ObjectFromName(), pCOPASIDATAMODEL, CModelEntity::REACTIONS, CModel::s, CEvaluationNode::subType(), and CEvaluationNode::type().

724 {
725  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
726  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING7));
727  CModel* pModel = pDataModel->getModel();
728  CPPUNIT_ASSERT(pModel != NULL);
729  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::number);
730  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::ml);
731  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
732  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
733  const CCompartment* pCompartment = pModel->getCompartments()[0];
734  CPPUNIT_ASSERT(pCompartment != NULL);
735  CPPUNIT_ASSERT(pCompartment->getStatus() == CModelEntity::FIXED);
736  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 2);
737  CMetab* pA = pModel->getMetabolites()[0];
738  CPPUNIT_ASSERT(pA != NULL);
739  CPPUNIT_ASSERT(pA->getStatus() == CModelEntity::REACTIONS);
740  const CMetab* pB = pModel->getMetabolites()[1];
741  CPPUNIT_ASSERT(pB != NULL);
742  CPPUNIT_ASSERT(pB->getStatus() == CModelEntity::REACTIONS);
743  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
744  const CModelValue* pModelValue = pModel->getModelValues()[0];
745  CPPUNIT_ASSERT(pModelValue != NULL);
746  CPPUNIT_ASSERT(pModelValue->getStatus() == CModelEntity::FIXED);
747  CPPUNIT_ASSERT(pModel->getEvents().size() == 1);
748  const CEvent* pEvent = pModel->getEvents()[0];
749  CPPUNIT_ASSERT(pEvent != NULL);
750  // check the trigger expression
751  const CExpression* pExpr = pEvent->getTriggerExpressionPtr();
752  CPPUNIT_ASSERT(pExpr != NULL);
753  const CEvaluationNode* pNode = pExpr->getRoot();
754  CPPUNIT_ASSERT(pNode != NULL);
755  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::LOGICAL);
757  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getChild());
758  CPPUNIT_ASSERT(pNode != NULL);
759  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
760  const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
761  CPPUNIT_ASSERT(pObjectNode != NULL);
762  CCopasiObjectName objectCN = pObjectNode->getObjectCN();
763  CPPUNIT_ASSERT(!objectCN.empty());
764  std::vector<CCopasiContainer*> listOfContainers;
765  listOfContainers.push_back(pModel);
766  const CCopasiObject* pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
767  CPPUNIT_ASSERT(pObject != NULL);
768  CPPUNIT_ASSERT(pObject->isReference() == true);
769  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Time"));
770  CPPUNIT_ASSERT(pObject->getObjectParent() == pModel);
771  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getSibling());
772  CPPUNIT_ASSERT(pNode != NULL);
773  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::NUMBER);
774  const CEvaluationNodeNumber* pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pNode);
775  CPPUNIT_ASSERT(pNumberNode != NULL);
776  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 2.0) / 2.0) < 1e-6);
777  // check that there is no delay
778  const CExpression* pExpression = pEvent->getDelayExpressionPtr();
779  CPPUNIT_ASSERT(pExpression == NULL);
780  CPPUNIT_ASSERT(pEvent->getAssignments().size() == 1);
781  // check the event assignment
782  std::string key = pEvent->getAssignments()[0]->getTargetKey();
783  CPPUNIT_ASSERT(key == pA->getKey());
784  pExpression = pEvent->getAssignments()[0]->getExpressionPtr();
785  CPPUNIT_ASSERT(pExpression != NULL);
786  pNode = pExpression->getRoot();
787  CPPUNIT_ASSERT(pNode != NULL);
788  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
789  pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
790  CPPUNIT_ASSERT(pObjectNode != NULL);
791  objectCN = pObjectNode->getObjectCN();
792  CPPUNIT_ASSERT(!objectCN.empty());
793  pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
794  CPPUNIT_ASSERT(pObject != NULL);
795  CPPUNIT_ASSERT(pObject->isReference() == true);
796  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Value"));
797  CPPUNIT_ASSERT(pObject->getObjectParent() == pModelValue);
798 }
Definition: CEvent.h:152
static const char * MODEL_STRING7
Definition: test000064.h:69
const std::string & getObjectName() const
const CRegisteredObjectName & getObjectCN() const
const C_FLOAT64 & getValue() const
const Type & getType() const
Definition: CMetab.h:178
static Type type(const Type &type)
bool isReference() const
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000064.h:98
static Type subType(const Type &type)
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50
CCopasiNode< Data > * getChild()
Definition: CCopasiNode.h:210
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
CEvaluationNode * getRoot()
CCopasiContainer * getObjectParent() const
void test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_4 ( )

Definition at line 856 of file test000064.cpp.

References CEvaluationNodeOperator::DIVIDE, CModelEntity::FIXED, CCopasiNode< _Data >::getChild(), CCopasiDataModel::getModel(), CEvaluationNodeObject::getObjectCN(), CCopasiObject::getObjectName(), CCopasiObject::getObjectParent(), CEvaluationTree::getRoot(), CEvaluationNode::getType(), CEvaluationNode::getValue(), CEvaluationNodeLogical::GT, CCopasiDataModel::importSBMLFromString(), CCopasiObject::isReference(), CEvaluationNode::LOGICAL, CModel::ml, MODEL_STRING8, CEvaluationNode::NUMBER, CModel::number, CEvaluationNode::OBJECT, CCopasiDataModel::ObjectFromName(), CEvaluationNode::OPERATOR, pCOPASIDATAMODEL, CModelEntity::REACTIONS, CModel::s, CEvaluationNode::subType(), and CEvaluationNode::type().

857 {
858  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
859  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING8));
860  CModel* pModel = pDataModel->getModel();
861  CPPUNIT_ASSERT(pModel != NULL);
862  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::number);
863  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::ml);
864  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
865  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
866  const CCompartment* pCompartment = pModel->getCompartments()[0];
867  CPPUNIT_ASSERT(pCompartment != NULL);
868  CPPUNIT_ASSERT(pCompartment->getStatus() == CModelEntity::FIXED);
869  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 2);
870  CMetab* pA = pModel->getMetabolites()[0];
871  CPPUNIT_ASSERT(pA != NULL);
872  CPPUNIT_ASSERT(pA->getStatus() == CModelEntity::REACTIONS);
873  const CMetab* pB = pModel->getMetabolites()[1];
874  CPPUNIT_ASSERT(pB != NULL);
875  CPPUNIT_ASSERT(pB->getStatus() == CModelEntity::REACTIONS);
876  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
877  const CModelValue* pModelValue = pModel->getModelValues()[0];
878  CPPUNIT_ASSERT(pModelValue != NULL);
879  CPPUNIT_ASSERT(pModelValue->getStatus() == CModelEntity::FIXED);
880  CPPUNIT_ASSERT(pModel->getEvents().size() == 1);
881  const CEvent* pEvent = pModel->getEvents()[0];
882  CPPUNIT_ASSERT(pEvent != NULL);
883  // check the trigger expression
884  const CExpression* pExpr = pEvent->getTriggerExpressionPtr();
885  CPPUNIT_ASSERT(pExpr != NULL);
886  const CEvaluationNode* pNode = pExpr->getRoot();
887  CPPUNIT_ASSERT(pNode != NULL);
888  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::LOGICAL);
890  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getChild());
891  CPPUNIT_ASSERT(pNode != NULL);
892  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
893  const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
894  CPPUNIT_ASSERT(pObjectNode != NULL);
895  CCopasiObjectName objectCN = pObjectNode->getObjectCN();
896  CPPUNIT_ASSERT(!objectCN.empty());
897  std::vector<CCopasiContainer*> listOfContainers;
898  listOfContainers.push_back(pModel);
899  const CCopasiObject* pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
900  CPPUNIT_ASSERT(pObject != NULL);
901  CPPUNIT_ASSERT(pObject->isReference() == true);
902  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Time"));
903  CPPUNIT_ASSERT(pObject->getObjectParent() == pModel);
904  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getSibling());
905  CPPUNIT_ASSERT(pNode != NULL);
906  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::NUMBER);
907  const CEvaluationNodeNumber* pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pNode);
908  CPPUNIT_ASSERT(pNumberNode != NULL);
909  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 2.0) / 2.0) < 1e-6);
910  // check that there is no delay
911  const CExpression* pExpression = pEvent->getDelayExpressionPtr();
912  CPPUNIT_ASSERT(pExpression == NULL);
913  CPPUNIT_ASSERT(pEvent->getAssignments().size() == 1);
914  // check the event assignment
915  std::string key = pEvent->getAssignments()[0]->getTargetKey();
916  CPPUNIT_ASSERT(key == pA->getKey());
917  pExpression = pEvent->getAssignments()[0]->getExpressionPtr();
918  CPPUNIT_ASSERT(pExpression != NULL);
919  pNode = pExpression->getRoot();
920  CPPUNIT_ASSERT(pNode != NULL);
921  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OPERATOR);
923  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getChild());
924  CPPUNIT_ASSERT(pNode != NULL);
925  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
926  pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
927  CPPUNIT_ASSERT(pObjectNode != NULL);
928  objectCN = pObjectNode->getObjectCN();
929  CPPUNIT_ASSERT(!objectCN.empty());
930  pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
931  CPPUNIT_ASSERT(pObject != NULL);
932  CPPUNIT_ASSERT(pObject->isReference() == true);
933  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Value"));
934  CPPUNIT_ASSERT(pObject->getObjectParent() == pModelValue);
935  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getSibling());
936  CPPUNIT_ASSERT(pNode != NULL);
937  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
938  pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
939  CPPUNIT_ASSERT(pObjectNode != NULL);
940  objectCN = pObjectNode->getObjectCN();
941  CPPUNIT_ASSERT(!objectCN.empty());
942  pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
943  CPPUNIT_ASSERT(pObject != NULL);
944  CPPUNIT_ASSERT(pObject->isReference() == true);
945  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Volume"));
946  CPPUNIT_ASSERT(pObject->getObjectParent() == pCompartment);
947 }
Definition: CEvent.h:152
const std::string & getObjectName() const
const CRegisteredObjectName & getObjectCN() const
const C_FLOAT64 & getValue() const
static const char * MODEL_STRING8
Definition: test000064.h:70
const Type & getType() const
Definition: CMetab.h:178
static Type type(const Type &type)
bool isReference() const
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000064.h:98
static Type subType(const Type &type)
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50
CCopasiNode< Data > * getChild()
Definition: CCopasiNode.h:210
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
CEvaluationNode * getRoot()
CCopasiContainer * getObjectParent() const
void test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_5 ( )

Definition at line 1393 of file test000064.cpp.

References CModelEntity::FIXED, CCopasiNode< _Data >::getChild(), CCopasiDataModel::getModel(), CEvaluationNodeObject::getObjectCN(), CCopasiObject::getObjectName(), CCopasiObject::getObjectParent(), CEvaluationTree::getRoot(), CEvaluationNode::getType(), CEvaluationNode::getValue(), CEvaluationNodeLogical::GT, CCopasiDataModel::importSBMLFromString(), CCopasiObject::isReference(), CEvaluationNode::LOGICAL, CModel::ml, CModel::mMol, MODEL_STRING13, CEvaluationNode::NUMBER, CEvaluationNode::OBJECT, CCopasiDataModel::ObjectFromName(), pCOPASIDATAMODEL, CModelEntity::REACTIONS, CModel::s, CEvaluationNode::subType(), and CEvaluationNode::type().

1394 {
1395  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
1396  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING13));
1397  CModel* pModel = pDataModel->getModel();
1398  CPPUNIT_ASSERT(pModel != NULL);
1399  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::mMol);
1400  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::ml);
1401  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
1402  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
1403  const CCompartment* pCompartment = pModel->getCompartments()[0];
1404  CPPUNIT_ASSERT(pCompartment != NULL);
1405  CPPUNIT_ASSERT(pCompartment->getStatus() == CModelEntity::FIXED);
1406  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 2);
1407  CMetab* pA = pModel->getMetabolites()[0];
1408  CPPUNIT_ASSERT(pA != NULL);
1409  CPPUNIT_ASSERT(pA->getStatus() == CModelEntity::REACTIONS);
1410  const CMetab* pB = pModel->getMetabolites()[1];
1411  CPPUNIT_ASSERT(pB != NULL);
1412  CPPUNIT_ASSERT(pB->getStatus() == CModelEntity::REACTIONS);
1413  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
1414  const CModelValue* pModelValue = pModel->getModelValues()[0];
1415  CPPUNIT_ASSERT(pModelValue != NULL);
1416  CPPUNIT_ASSERT(pModelValue->getStatus() == CModelEntity::FIXED);
1417  CPPUNIT_ASSERT(pModel->getEvents().size() == 1);
1418  const CEvent* pEvent = pModel->getEvents()[0];
1419  CPPUNIT_ASSERT(pEvent != NULL);
1420  // check the trigger expression
1421  const CExpression* pExpr = pEvent->getTriggerExpressionPtr();
1422  CPPUNIT_ASSERT(pExpr != NULL);
1423  const CEvaluationNode* pNode = pExpr->getRoot();
1424  CPPUNIT_ASSERT(pNode != NULL);
1425  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::LOGICAL);
1427  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getChild());
1428  CPPUNIT_ASSERT(pNode != NULL);
1429  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
1430  const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
1431  CPPUNIT_ASSERT(pObjectNode != NULL);
1432  CCopasiObjectName objectCN = pObjectNode->getObjectCN();
1433  CPPUNIT_ASSERT(!objectCN.empty());
1434  std::vector<CCopasiContainer*> listOfContainers;
1435  listOfContainers.push_back(pModel);
1436  const CCopasiObject* pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
1437  CPPUNIT_ASSERT(pObject != NULL);
1438  CPPUNIT_ASSERT(pObject->isReference() == true);
1439  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Time"));
1440  CPPUNIT_ASSERT(pObject->getObjectParent() == pModel);
1441  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getSibling());
1442  CPPUNIT_ASSERT(pNode != NULL);
1443  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::NUMBER);
1444  const CEvaluationNodeNumber* pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pNode);
1445  CPPUNIT_ASSERT(pNumberNode != NULL);
1446  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 2.0) / 2.0) < 1e-6);
1447  // check that there is no delay
1448  const CExpression* pExpression = pEvent->getDelayExpressionPtr();
1449  CPPUNIT_ASSERT(pExpression == NULL);
1450  CPPUNIT_ASSERT(pEvent->getAssignments().size() == 1);
1451  // check the event assignment
1452  std::string key = pEvent->getAssignments()[0]->getTargetKey();
1453  CPPUNIT_ASSERT(key == pA->getKey());
1454  pExpression = pEvent->getAssignments()[0]->getExpressionPtr();
1455  CPPUNIT_ASSERT(pExpression != NULL);
1456  pNode = pExpression->getRoot();
1457  CPPUNIT_ASSERT(pNode != NULL);
1458  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
1459  pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
1460  CPPUNIT_ASSERT(pObjectNode != NULL);
1461  objectCN = pObjectNode->getObjectCN();
1462  CPPUNIT_ASSERT(!objectCN.empty());
1463  pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
1464  CPPUNIT_ASSERT(pObject != NULL);
1465  CPPUNIT_ASSERT(pObject->isReference() == true);
1466  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Value"));
1467  CPPUNIT_ASSERT(pObject->getObjectParent() == pModelValue);
1468 }
Definition: CEvent.h:152
const std::string & getObjectName() const
const CRegisteredObjectName & getObjectCN() const
const C_FLOAT64 & getValue() const
const Type & getType() const
static const char * MODEL_STRING13
Definition: test000064.h:75
Definition: CMetab.h:178
static Type type(const Type &type)
bool isReference() const
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000064.h:98
static Type subType(const Type &type)
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50
CCopasiNode< Data > * getChild()
Definition: CCopasiNode.h:210
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
CEvaluationNode * getRoot()
CCopasiContainer * getObjectParent() const
void test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_6 ( )

Definition at line 1530 of file test000064.cpp.

References CModelEntity::FIXED, CCopasiNode< _Data >::getChild(), CCopasiDataModel::getModel(), CEvaluationNodeObject::getObjectCN(), CCopasiObject::getObjectName(), CCopasiObject::getObjectParent(), CEvaluationTree::getRoot(), CEvaluationNode::getType(), CEvaluationNode::getValue(), CEvaluationNodeLogical::GT, CCopasiDataModel::importSBMLFromString(), CCopasiObject::isReference(), CEvaluationNode::LOGICAL, CModel::ml, CModel::mMol, MODEL_STRING14, CEvaluationNodeOperator::MULTIPLY, CEvaluationNode::NUMBER, CEvaluationNode::OBJECT, CCopasiDataModel::ObjectFromName(), CEvaluationNode::OPERATOR, pCOPASIDATAMODEL, CModelEntity::REACTIONS, CModel::s, CEvaluationNode::subType(), and CEvaluationNode::type().

1531 {
1532  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
1533  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING14));
1534  CModel* pModel = pDataModel->getModel();
1535  CPPUNIT_ASSERT(pModel != NULL);
1536  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::mMol);
1537  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::ml);
1538  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
1539  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
1540  const CCompartment* pCompartment = pModel->getCompartments()[0];
1541  CPPUNIT_ASSERT(pCompartment != NULL);
1542  CPPUNIT_ASSERT(pCompartment->getStatus() == CModelEntity::FIXED);
1543  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 2);
1544  CMetab* pA = pModel->getMetabolites()[0];
1545  CPPUNIT_ASSERT(pA != NULL);
1546  CPPUNIT_ASSERT(pA->getStatus() == CModelEntity::REACTIONS);
1547  const CMetab* pB = pModel->getMetabolites()[1];
1548  CPPUNIT_ASSERT(pB != NULL);
1549  CPPUNIT_ASSERT(pB->getStatus() == CModelEntity::REACTIONS);
1550  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
1551  const CModelValue* pModelValue = pModel->getModelValues()[0];
1552  CPPUNIT_ASSERT(pModelValue != NULL);
1553  CPPUNIT_ASSERT(pModelValue->getStatus() == CModelEntity::FIXED);
1554  CPPUNIT_ASSERT(pModel->getEvents().size() == 1);
1555  const CEvent* pEvent = pModel->getEvents()[0];
1556  CPPUNIT_ASSERT(pEvent != NULL);
1557  // check the trigger expression
1558  const CExpression* pExpr = pEvent->getTriggerExpressionPtr();
1559  CPPUNIT_ASSERT(pExpr != NULL);
1560  const CEvaluationNode* pNode = pExpr->getRoot();
1561  CPPUNIT_ASSERT(pNode != NULL);
1562  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::LOGICAL);
1564  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getChild());
1565  CPPUNIT_ASSERT(pNode != NULL);
1566  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
1567  const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
1568  CPPUNIT_ASSERT(pObjectNode != NULL);
1569  CCopasiObjectName objectCN = pObjectNode->getObjectCN();
1570  CPPUNIT_ASSERT(!objectCN.empty());
1571  std::vector<CCopasiContainer*> listOfContainers;
1572  listOfContainers.push_back(pModel);
1573  const CCopasiObject* pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
1574  CPPUNIT_ASSERT(pObject != NULL);
1575  CPPUNIT_ASSERT(pObject->isReference() == true);
1576  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Time"));
1577  CPPUNIT_ASSERT(pObject->getObjectParent() == pModel);
1578  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getSibling());
1579  CPPUNIT_ASSERT(pNode != NULL);
1580  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::NUMBER);
1581  const CEvaluationNodeNumber* pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pNode);
1582  CPPUNIT_ASSERT(pNumberNode != NULL);
1583  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 2.0) / 2.0) < 1e-6);
1584  // check that there is no delay
1585  const CExpression* pExpression = pEvent->getDelayExpressionPtr();
1586  CPPUNIT_ASSERT(pExpression == NULL);
1587  CPPUNIT_ASSERT(pEvent->getAssignments().size() == 1);
1588  // check the event assignment
1589  std::string key = pEvent->getAssignments()[0]->getTargetKey();
1590  CPPUNIT_ASSERT(key == pA->getKey());
1591  pExpression = pEvent->getAssignments()[0]->getExpressionPtr();
1592  CPPUNIT_ASSERT(pExpression != NULL);
1593  pNode = pExpression->getRoot();
1594  CPPUNIT_ASSERT(pNode != NULL);
1595  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OPERATOR);
1597  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getChild());
1598  CPPUNIT_ASSERT(pNode != NULL);
1599  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
1600  pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
1601  CPPUNIT_ASSERT(pObjectNode != NULL);
1602  objectCN = pObjectNode->getObjectCN();
1603  CPPUNIT_ASSERT(!objectCN.empty());
1604  pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
1605  CPPUNIT_ASSERT(pObject != NULL);
1606  CPPUNIT_ASSERT(pObject->isReference() == true);
1607  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Value"));
1608  CPPUNIT_ASSERT(pObject->getObjectParent() == pModelValue);
1609  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getSibling());
1610  CPPUNIT_ASSERT(pNode != NULL);
1611  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
1612  pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
1613  CPPUNIT_ASSERT(pObjectNode != NULL);
1614  objectCN = pObjectNode->getObjectCN();
1615  CPPUNIT_ASSERT(!objectCN.empty());
1616  pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
1617  CPPUNIT_ASSERT(pObject != NULL);
1618  CPPUNIT_ASSERT(pObject->isReference() == true);
1619  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Volume"));
1620  CPPUNIT_ASSERT(pObject->getObjectParent() == pCompartment);
1621 }
Definition: CEvent.h:152
const std::string & getObjectName() const
const CRegisteredObjectName & getObjectCN() const
const C_FLOAT64 & getValue() const
const Type & getType() const
Definition: CMetab.h:178
static Type type(const Type &type)
bool isReference() const
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000064.h:98
static const char * MODEL_STRING14
Definition: test000064.h:76
static Type subType(const Type &type)
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50
CCopasiNode< Data > * getChild()
Definition: CCopasiNode.h:210
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
CEvaluationNode * getRoot()
CCopasiContainer * getObjectParent() const
void test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_7 ( )

Definition at line 1683 of file test000064.cpp.

References CModelEntity::FIXED, CCopasiNode< _Data >::getChild(), CCopasiDataModel::getModel(), CEvaluationNodeObject::getObjectCN(), CCopasiObject::getObjectName(), CCopasiObject::getObjectParent(), CEvaluationTree::getRoot(), CEvaluationNode::getType(), CEvaluationNode::getValue(), CEvaluationNodeLogical::GT, CCopasiDataModel::importSBMLFromString(), CCopasiObject::isReference(), CEvaluationNode::LOGICAL, CModel::ml, MODEL_STRING15, CEvaluationNodeOperator::MULTIPLY, CEvaluationNode::NUMBER, CModel::number, CEvaluationNode::OBJECT, CCopasiDataModel::ObjectFromName(), CEvaluationNode::OPERATOR, pCOPASIDATAMODEL, CModelEntity::REACTIONS, CModel::s, CEvaluationNode::subType(), and CEvaluationNode::type().

1684 {
1685  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
1686  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING15));
1687  CModel* pModel = pDataModel->getModel();
1688  CPPUNIT_ASSERT(pModel != NULL);
1689  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::number);
1690  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::ml);
1691  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
1692  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
1693  const CCompartment* pCompartment = pModel->getCompartments()[0];
1694  CPPUNIT_ASSERT(pCompartment != NULL);
1695  CPPUNIT_ASSERT(pCompartment->getStatus() == CModelEntity::FIXED);
1696  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 2);
1697  CMetab* pA = pModel->getMetabolites()[0];
1698  CPPUNIT_ASSERT(pA != NULL);
1699  CPPUNIT_ASSERT(pA->getStatus() == CModelEntity::REACTIONS);
1700  const CMetab* pB = pModel->getMetabolites()[1];
1701  CPPUNIT_ASSERT(pB != NULL);
1702  CPPUNIT_ASSERT(pB->getStatus() == CModelEntity::REACTIONS);
1703  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
1704  const CModelValue* pModelValue = pModel->getModelValues()[0];
1705  CPPUNIT_ASSERT(pModelValue != NULL);
1706  CPPUNIT_ASSERT(pModelValue->getStatus() == CModelEntity::FIXED);
1707  CPPUNIT_ASSERT(pModel->getEvents().size() == 1);
1708  const CEvent* pEvent = pModel->getEvents()[0];
1709  CPPUNIT_ASSERT(pEvent != NULL);
1710  // check the trigger expression
1711  const CExpression* pExpr = pEvent->getTriggerExpressionPtr();
1712  CPPUNIT_ASSERT(pExpr != NULL);
1713  const CEvaluationNode* pNode = pExpr->getRoot();
1714  CPPUNIT_ASSERT(pNode != NULL);
1715  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::LOGICAL);
1717  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getChild());
1718  CPPUNIT_ASSERT(pNode != NULL);
1719  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
1720  const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
1721  CPPUNIT_ASSERT(pObjectNode != NULL);
1722  CCopasiObjectName objectCN = pObjectNode->getObjectCN();
1723  CPPUNIT_ASSERT(!objectCN.empty());
1724  std::vector<CCopasiContainer*> listOfContainers;
1725  listOfContainers.push_back(pModel);
1726  const CCopasiObject* pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
1727  CPPUNIT_ASSERT(pObject != NULL);
1728  CPPUNIT_ASSERT(pObject->isReference() == true);
1729  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Time"));
1730  CPPUNIT_ASSERT(pObject->getObjectParent() == pModel);
1731  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getSibling());
1732  CPPUNIT_ASSERT(pNode != NULL);
1733  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::NUMBER);
1734  const CEvaluationNodeNumber* pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pNode);
1735  CPPUNIT_ASSERT(pNumberNode != NULL);
1736  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 2.0) / 2.0) < 1e-6);
1737  // check that there is no delay
1738  const CExpression* pExpression = pEvent->getDelayExpressionPtr();
1739  CPPUNIT_ASSERT(pExpression == NULL);
1740  CPPUNIT_ASSERT(pEvent->getAssignments().size() == 1);
1741  // check the event assignment
1742  std::string key = pEvent->getAssignments()[0]->getTargetKey();
1743  CPPUNIT_ASSERT(key == pA->getKey());
1744  pExpression = pEvent->getAssignments()[0]->getExpressionPtr();
1745  CPPUNIT_ASSERT(pExpression != NULL);
1746  pNode = pExpression->getRoot();
1747  CPPUNIT_ASSERT(pNode != NULL);
1748  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OPERATOR);
1750  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getChild());
1751  CPPUNIT_ASSERT(pNode != NULL);
1752  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
1753  pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
1754  CPPUNIT_ASSERT(pObjectNode != NULL);
1755  objectCN = pObjectNode->getObjectCN();
1756  CPPUNIT_ASSERT(!objectCN.empty());
1757  pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
1758  CPPUNIT_ASSERT(pObject != NULL);
1759  CPPUNIT_ASSERT(pObject->isReference() == true);
1760  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Value"));
1761  CPPUNIT_ASSERT(pObject->getObjectParent() == pModelValue);
1762  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getSibling());
1763  CPPUNIT_ASSERT(pNode != NULL);
1764  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
1765  pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
1766  CPPUNIT_ASSERT(pObjectNode != NULL);
1767  objectCN = pObjectNode->getObjectCN();
1768  CPPUNIT_ASSERT(!objectCN.empty());
1769  pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
1770  CPPUNIT_ASSERT(pObject != NULL);
1771  CPPUNIT_ASSERT(pObject->isReference() == true);
1772  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Volume"));
1773  CPPUNIT_ASSERT(pObject->getObjectParent() == pCompartment);
1774 }
Definition: CEvent.h:152
const std::string & getObjectName() const
const CRegisteredObjectName & getObjectCN() const
const C_FLOAT64 & getValue() const
const Type & getType() const
Definition: CMetab.h:178
static Type type(const Type &type)
bool isReference() const
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000064.h:98
static const char * MODEL_STRING15
Definition: test000064.h:77
static Type subType(const Type &type)
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50
CCopasiNode< Data > * getChild()
Definition: CCopasiNode.h:210
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
CEvaluationNode * getRoot()
CCopasiContainer * getObjectParent() const
void test000064::test_import_event_assignment_expression_and_hasOnlySubstanceUnits_8 ( )

Definition at line 1836 of file test000064.cpp.

References CModelEntity::FIXED, CCopasiNode< _Data >::getChild(), CCopasiDataModel::getModel(), CEvaluationNodeObject::getObjectCN(), CCopasiObject::getObjectName(), CCopasiObject::getObjectParent(), CEvaluationTree::getRoot(), CEvaluationNode::getType(), CEvaluationNode::getValue(), CEvaluationNodeLogical::GT, CCopasiDataModel::importSBMLFromString(), CCopasiObject::isReference(), CEvaluationNode::LOGICAL, CModel::ml, MODEL_STRING16, CEvaluationNode::NUMBER, CModel::number, CEvaluationNode::OBJECT, CCopasiDataModel::ObjectFromName(), pCOPASIDATAMODEL, CModelEntity::REACTIONS, CModel::s, CEvaluationNode::subType(), and CEvaluationNode::type().

1837 {
1838  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
1839  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING16));
1840  CModel* pModel = pDataModel->getModel();
1841  CPPUNIT_ASSERT(pModel != NULL);
1842  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::number);
1843  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::ml);
1844  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
1845  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
1846  const CCompartment* pCompartment = pModel->getCompartments()[0];
1847  CPPUNIT_ASSERT(pCompartment != NULL);
1848  CPPUNIT_ASSERT(pCompartment->getStatus() == CModelEntity::FIXED);
1849  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 2);
1850  CMetab* pA = pModel->getMetabolites()[0];
1851  CPPUNIT_ASSERT(pA != NULL);
1852  CPPUNIT_ASSERT(pA->getStatus() == CModelEntity::REACTIONS);
1853  const CMetab* pB = pModel->getMetabolites()[1];
1854  CPPUNIT_ASSERT(pB != NULL);
1855  CPPUNIT_ASSERT(pB->getStatus() == CModelEntity::REACTIONS);
1856  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
1857  const CModelValue* pModelValue = pModel->getModelValues()[0];
1858  CPPUNIT_ASSERT(pModelValue != NULL);
1859  CPPUNIT_ASSERT(pModelValue->getStatus() == CModelEntity::FIXED);
1860  CPPUNIT_ASSERT(pModel->getEvents().size() == 1);
1861  const CEvent* pEvent = pModel->getEvents()[0];
1862  CPPUNIT_ASSERT(pEvent != NULL);
1863  // check the trigger expression
1864  const CExpression* pExpr = pEvent->getTriggerExpressionPtr();
1865  CPPUNIT_ASSERT(pExpr != NULL);
1866  const CEvaluationNode* pNode = pExpr->getRoot();
1867  CPPUNIT_ASSERT(pNode != NULL);
1868  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::LOGICAL);
1870  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getChild());
1871  CPPUNIT_ASSERT(pNode != NULL);
1872  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
1873  const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
1874  CPPUNIT_ASSERT(pObjectNode != NULL);
1875  CCopasiObjectName objectCN = pObjectNode->getObjectCN();
1876  CPPUNIT_ASSERT(!objectCN.empty());
1877  std::vector<CCopasiContainer*> listOfContainers;
1878  listOfContainers.push_back(pModel);
1879  const CCopasiObject* pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
1880  CPPUNIT_ASSERT(pObject != NULL);
1881  CPPUNIT_ASSERT(pObject->isReference() == true);
1882  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Time"));
1883  CPPUNIT_ASSERT(pObject->getObjectParent() == pModel);
1884  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getSibling());
1885  CPPUNIT_ASSERT(pNode != NULL);
1886  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::NUMBER);
1887  const CEvaluationNodeNumber* pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pNode);
1888  CPPUNIT_ASSERT(pNumberNode != NULL);
1889  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 2.0) / 2.0) < 1e-6);
1890  // check that there is no delay
1891  const CExpression* pExpression = pEvent->getDelayExpressionPtr();
1892  CPPUNIT_ASSERT(pExpression == NULL);
1893  CPPUNIT_ASSERT(pEvent->getAssignments().size() == 1);
1894  // check the event assignment
1895  std::string key = pEvent->getAssignments()[0]->getTargetKey();
1896  CPPUNIT_ASSERT(key == pA->getKey());
1897  pExpression = pEvent->getAssignments()[0]->getExpressionPtr();
1898  CPPUNIT_ASSERT(pExpression != NULL);
1899  pNode = pExpression->getRoot();
1900  CPPUNIT_ASSERT(pNode != NULL);
1901  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
1902  pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
1903  CPPUNIT_ASSERT(pObjectNode != NULL);
1904  objectCN = pObjectNode->getObjectCN();
1905  CPPUNIT_ASSERT(!objectCN.empty());
1906  pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
1907  CPPUNIT_ASSERT(pObject != NULL);
1908  CPPUNIT_ASSERT(pObject->isReference() == true);
1909  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Value"));
1910  CPPUNIT_ASSERT(pObject->getObjectParent() == pModelValue);
1911 }
Definition: CEvent.h:152
static const char * MODEL_STRING16
Definition: test000064.h:78
const std::string & getObjectName() const
const CRegisteredObjectName & getObjectCN() const
const C_FLOAT64 & getValue() const
const Type & getType() const
Definition: CMetab.h:178
static Type type(const Type &type)
bool isReference() const
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000064.h:98
static Type subType(const Type &type)
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50
CCopasiNode< Data > * getChild()
Definition: CCopasiNode.h:210
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
CEvaluationNode * getRoot()
CCopasiContainer * getObjectParent() const
void test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_1 ( )

Definition at line 69 of file test000064.cpp.

References CModelEntity::ASSIGNMENT, CEvaluationNodeOperator::DIVIDE, CModelEntity::FIXED, CCopasiNode< _Data >::getChild(), CCopasiDataModel::getModel(), CEvaluationNodeObject::getObjectCN(), CCopasiObject::getObjectName(), CCopasiObject::getObjectParent(), CEvaluationNode::getType(), CCopasiDataModel::importSBMLFromString(), CCopasiObject::isReference(), CModel::ml, CModel::mMol, MODEL_STRING1, CEvaluationNode::OBJECT, CCopasiDataModel::ObjectFromName(), CEvaluationNode::OPERATOR, pCOPASIDATAMODEL, CModelEntity::REACTIONS, CModel::s, CEvaluationNode::subType(), and CEvaluationNode::type().

70 {
71  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
72  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING1));
73  CModel* pModel = pDataModel->getModel();
74  CPPUNIT_ASSERT(pModel != NULL);
75  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::mMol);
76  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::ml);
77  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
78  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
79  const CCompartment* pCompartment = pModel->getCompartments()[0];
80  CPPUNIT_ASSERT(pCompartment != NULL);
81  CPPUNIT_ASSERT(pCompartment->getStatus() == CModelEntity::FIXED);
82  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 2);
83  CMetab* pA = pModel->getMetabolites()[0];
84  CPPUNIT_ASSERT(pA != NULL);
85  CPPUNIT_ASSERT(pA->getStatus() == CModelEntity::ASSIGNMENT);
86  const CMetab* pB = pModel->getMetabolites()[1];
87  CPPUNIT_ASSERT(pB != NULL);
88  CPPUNIT_ASSERT(pB->getStatus() == CModelEntity::REACTIONS);
89  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
90  const CModelValue* pModelValue = pModel->getModelValues()[0];
91  CPPUNIT_ASSERT(pModelValue != NULL);
92  CPPUNIT_ASSERT(pModelValue->getStatus() == CModelEntity::FIXED);
93  const CExpression* pExpr = pA->getExpressionPtr();
94  // check the expression
95  const CEvaluationNode* pNode = pExpr->getRoot();
96  CPPUNIT_ASSERT(pNode != NULL);
97  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OPERATOR);
99  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getChild());
100  CPPUNIT_ASSERT(pNode != NULL);
101  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
102  const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
103  CPPUNIT_ASSERT(pObjectNode != NULL);
104  CCopasiObjectName objectCN = pObjectNode->getObjectCN();
105  CPPUNIT_ASSERT(!objectCN.empty());
106  std::vector<CCopasiContainer*> listOfContainers;
107  listOfContainers.push_back(pModel);
108  const CCopasiObject* pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
109  CPPUNIT_ASSERT(pObject != NULL);
110  CPPUNIT_ASSERT(pObject->isReference() == true);
111  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Value"));
112  CPPUNIT_ASSERT(pObject->getObjectParent() == pModelValue);
113  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getSibling());
114  CPPUNIT_ASSERT(pNode != NULL);
115  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
116  pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
117  CPPUNIT_ASSERT(pObjectNode != NULL);
118  objectCN = pObjectNode->getObjectCN();
119  CPPUNIT_ASSERT(!objectCN.empty());
120  pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
121  CPPUNIT_ASSERT(pObject != NULL);
122  CPPUNIT_ASSERT(pObject->isReference() == true);
123  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Volume"));
124  CPPUNIT_ASSERT(pObject->getObjectParent() == pCompartment);
125 }
static const char * MODEL_STRING1
Definition: test000064.h:63
const std::string & getObjectName() const
const CRegisteredObjectName & getObjectCN() const
const Type & getType() const
Definition: CMetab.h:178
static Type type(const Type &type)
bool isReference() const
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000064.h:98
static Type subType(const Type &type)
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50
CCopasiNode< Data > * getChild()
Definition: CCopasiNode.h:210
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
CCopasiContainer * getObjectParent() const
void test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_2 ( )

Definition at line 170 of file test000064.cpp.

References CModelEntity::ASSIGNMENT, CModelEntity::FIXED, CCopasiDataModel::getModel(), CEvaluationNodeObject::getObjectCN(), CCopasiObject::getObjectName(), CCopasiObject::getObjectParent(), CEvaluationNode::getType(), CCopasiDataModel::importSBMLFromString(), CCopasiObject::isReference(), CModel::ml, CModel::mMol, MODEL_STRING2, CEvaluationNode::OBJECT, CCopasiDataModel::ObjectFromName(), pCOPASIDATAMODEL, CModelEntity::REACTIONS, CModel::s, and CEvaluationNode::type().

171 {
172  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
173  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING2));
174  CModel* pModel = pDataModel->getModel();
175  CPPUNIT_ASSERT(pModel != NULL);
176  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::mMol);
177  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::ml);
178  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
179  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
180  const CCompartment* pCompartment = pModel->getCompartments()[0];
181  CPPUNIT_ASSERT(pCompartment != NULL);
182  CPPUNIT_ASSERT(pCompartment->getStatus() == CModelEntity::FIXED);
183  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 2);
184  CMetab* pA = pModel->getMetabolites()[0];
185  CPPUNIT_ASSERT(pA != NULL);
186  CPPUNIT_ASSERT(pA->getStatus() == CModelEntity::ASSIGNMENT);
187  const CMetab* pB = pModel->getMetabolites()[1];
188  CPPUNIT_ASSERT(pB != NULL);
189  CPPUNIT_ASSERT(pB->getStatus() == CModelEntity::REACTIONS);
190  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
191  const CModelValue* pModelValue = pModel->getModelValues()[0];
192  CPPUNIT_ASSERT(pModelValue != NULL);
193  CPPUNIT_ASSERT(pModelValue->getStatus() == CModelEntity::FIXED);
194  const CExpression* pExpr = pA->getExpressionPtr();
195  // check the expression
196  const CEvaluationNode* pNode = pExpr->getRoot();
197  CPPUNIT_ASSERT(pNode != NULL);
198  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
199  const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
200  CPPUNIT_ASSERT(pObjectNode != NULL);
201  CCopasiObjectName objectCN = pObjectNode->getObjectCN();
202  CPPUNIT_ASSERT(!objectCN.empty());
203  std::vector<CCopasiContainer*> listOfContainers;
204  listOfContainers.push_back(pModel);
205  const CCopasiObject* pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
206  CPPUNIT_ASSERT(pObject != NULL);
207  CPPUNIT_ASSERT(pObject->isReference() == true);
208  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Value"));
209  CPPUNIT_ASSERT(pObject->getObjectParent() == pModelValue);
210 }
const std::string & getObjectName() const
const CRegisteredObjectName & getObjectCN() const
const Type & getType() const
Definition: CMetab.h:178
static Type type(const Type &type)
bool isReference() const
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000064.h:98
static const char * MODEL_STRING2
Definition: test000064.h:64
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
CCopasiContainer * getObjectParent() const
void test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_3 ( )

Definition at line 255 of file test000064.cpp.

References CModelEntity::ASSIGNMENT, CModelEntity::FIXED, CCopasiDataModel::getModel(), CEvaluationNodeObject::getObjectCN(), CCopasiObject::getObjectName(), CCopasiObject::getObjectParent(), CEvaluationNode::getType(), CCopasiDataModel::importSBMLFromString(), CCopasiObject::isReference(), CModel::ml, MODEL_STRING3, CModel::number, CEvaluationNode::OBJECT, CCopasiDataModel::ObjectFromName(), pCOPASIDATAMODEL, CModelEntity::REACTIONS, CModel::s, and CEvaluationNode::type().

256 {
257  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
258  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING3));
259  CModel* pModel = pDataModel->getModel();
260  CPPUNIT_ASSERT(pModel != NULL);
261  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::number);
262  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::ml);
263  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
264  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
265  const CCompartment* pCompartment = pModel->getCompartments()[0];
266  CPPUNIT_ASSERT(pCompartment != NULL);
267  CPPUNIT_ASSERT(pCompartment->getStatus() == CModelEntity::FIXED);
268  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 2);
269  CMetab* pA = pModel->getMetabolites()[0];
270  CPPUNIT_ASSERT(pA != NULL);
271  CPPUNIT_ASSERT(pA->getStatus() == CModelEntity::ASSIGNMENT);
272  const CMetab* pB = pModel->getMetabolites()[1];
273  CPPUNIT_ASSERT(pB != NULL);
274  CPPUNIT_ASSERT(pB->getStatus() == CModelEntity::REACTIONS);
275  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
276  const CModelValue* pModelValue = pModel->getModelValues()[0];
277  CPPUNIT_ASSERT(pModelValue != NULL);
278  CPPUNIT_ASSERT(pModelValue->getStatus() == CModelEntity::FIXED);
279  const CExpression* pExpr = pA->getExpressionPtr();
280  // check the expression
281  const CEvaluationNode* pNode = pExpr->getRoot();
282  CPPUNIT_ASSERT(pNode != NULL);
283  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
284  const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
285  CPPUNIT_ASSERT(pObjectNode != NULL);
286  CCopasiObjectName objectCN = pObjectNode->getObjectCN();
287  CPPUNIT_ASSERT(!objectCN.empty());
288  std::vector<CCopasiContainer*> listOfContainers;
289  listOfContainers.push_back(pModel);
290  const CCopasiObject* pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
291  CPPUNIT_ASSERT(pObject != NULL);
292  CPPUNIT_ASSERT(pObject->isReference() == true);
293  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Value"));
294  CPPUNIT_ASSERT(pObject->getObjectParent() == pModelValue);
295 }
const std::string & getObjectName() const
const CRegisteredObjectName & getObjectCN() const
const Type & getType() const
Definition: CMetab.h:178
static Type type(const Type &type)
bool isReference() const
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000064.h:98
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50
static const char * MODEL_STRING3
Definition: test000064.h:65
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
CCopasiContainer * getObjectParent() const
void test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_4 ( )

Definition at line 340 of file test000064.cpp.

References CModelEntity::ASSIGNMENT, CEvaluationNodeOperator::DIVIDE, CModelEntity::FIXED, CCopasiNode< _Data >::getChild(), CCopasiDataModel::getModel(), CEvaluationNodeObject::getObjectCN(), CCopasiObject::getObjectName(), CCopasiObject::getObjectParent(), CEvaluationNode::getType(), CCopasiDataModel::importSBMLFromString(), CCopasiObject::isReference(), CModel::ml, MODEL_STRING4, CModel::number, CEvaluationNode::OBJECT, CCopasiDataModel::ObjectFromName(), CEvaluationNode::OPERATOR, pCOPASIDATAMODEL, CModelEntity::REACTIONS, CModel::s, CEvaluationNode::subType(), and CEvaluationNode::type().

341 {
342  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
343  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING4));
344  CModel* pModel = pDataModel->getModel();
345  CPPUNIT_ASSERT(pModel != NULL);
346  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::number);
347  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::ml);
348  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
349  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
350  const CCompartment* pCompartment = pModel->getCompartments()[0];
351  CPPUNIT_ASSERT(pCompartment != NULL);
352  CPPUNIT_ASSERT(pCompartment->getStatus() == CModelEntity::FIXED);
353  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 2);
354  CMetab* pA = pModel->getMetabolites()[0];
355  CPPUNIT_ASSERT(pA != NULL);
356  CPPUNIT_ASSERT(pA->getStatus() == CModelEntity::ASSIGNMENT);
357  const CMetab* pB = pModel->getMetabolites()[1];
358  CPPUNIT_ASSERT(pB != NULL);
359  CPPUNIT_ASSERT(pB->getStatus() == CModelEntity::REACTIONS);
360  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
361  const CModelValue* pModelValue = pModel->getModelValues()[0];
362  CPPUNIT_ASSERT(pModelValue != NULL);
363  CPPUNIT_ASSERT(pModelValue->getStatus() == CModelEntity::FIXED);
364  const CExpression* pExpr = pA->getExpressionPtr();
365  // check the expression
366  const CEvaluationNode* pNode = pExpr->getRoot();
367  CPPUNIT_ASSERT(pNode != NULL);
368  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OPERATOR);
370  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getChild());
371  CPPUNIT_ASSERT(pNode != NULL);
372  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
373  const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
374  CPPUNIT_ASSERT(pObjectNode != NULL);
375  CCopasiObjectName objectCN = pObjectNode->getObjectCN();
376  CPPUNIT_ASSERT(!objectCN.empty());
377  std::vector<CCopasiContainer*> listOfContainers;
378  listOfContainers.push_back(pModel);
379  const CCopasiObject* pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
380  CPPUNIT_ASSERT(pObject != NULL);
381  CPPUNIT_ASSERT(pObject->isReference() == true);
382  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Value"));
383  CPPUNIT_ASSERT(pObject->getObjectParent() == pModelValue);
384  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getSibling());
385  CPPUNIT_ASSERT(pNode != NULL);
386  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
387  pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
388  CPPUNIT_ASSERT(pObjectNode != NULL);
389  objectCN = pObjectNode->getObjectCN();
390  CPPUNIT_ASSERT(!objectCN.empty());
391  pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
392  CPPUNIT_ASSERT(pObject != NULL);
393  CPPUNIT_ASSERT(pObject->isReference() == true);
394  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Volume"));
395  CPPUNIT_ASSERT(pObject->getObjectParent() == pCompartment);
396 }
const std::string & getObjectName() const
static const char * MODEL_STRING4
Definition: test000064.h:66
const CRegisteredObjectName & getObjectCN() const
const Type & getType() const
Definition: CMetab.h:178
static Type type(const Type &type)
bool isReference() const
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000064.h:98
static Type subType(const Type &type)
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50
CCopasiNode< Data > * getChild()
Definition: CCopasiNode.h:210
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
CCopasiContainer * getObjectParent() const
void test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_5 ( )

Definition at line 1005 of file test000064.cpp.

References CModelEntity::ASSIGNMENT, CModelEntity::FIXED, CCopasiDataModel::getModel(), CEvaluationNodeObject::getObjectCN(), CCopasiObject::getObjectName(), CCopasiObject::getObjectParent(), CEvaluationNode::getType(), CCopasiDataModel::importSBMLFromString(), CCopasiObject::isReference(), CModel::ml, CModel::mMol, MODEL_STRING9, CEvaluationNode::OBJECT, CCopasiDataModel::ObjectFromName(), pCOPASIDATAMODEL, CModelEntity::REACTIONS, CModel::s, and CEvaluationNode::type().

1006 {
1007  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
1008  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING9));
1009  CModel* pModel = pDataModel->getModel();
1010  CPPUNIT_ASSERT(pModel != NULL);
1011  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::mMol);
1012  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::ml);
1013  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
1014  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
1015  const CCompartment* pCompartment = pModel->getCompartments()[0];
1016  CPPUNIT_ASSERT(pCompartment != NULL);
1017  CPPUNIT_ASSERT(pCompartment->getStatus() == CModelEntity::FIXED);
1018  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 2);
1019  CMetab* pA = pModel->getMetabolites()[0];
1020  CPPUNIT_ASSERT(pA != NULL);
1021  CPPUNIT_ASSERT(pA->getStatus() == CModelEntity::ASSIGNMENT);
1022  const CMetab* pB = pModel->getMetabolites()[1];
1023  CPPUNIT_ASSERT(pB != NULL);
1024  CPPUNIT_ASSERT(pB->getStatus() == CModelEntity::REACTIONS);
1025  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
1026  const CModelValue* pModelValue = pModel->getModelValues()[0];
1027  CPPUNIT_ASSERT(pModelValue != NULL);
1028  CPPUNIT_ASSERT(pModelValue->getStatus() == CModelEntity::FIXED);
1029  const CExpression* pExpr = pA->getExpressionPtr();
1030  // check the expression
1031  const CEvaluationNode* pNode = pExpr->getRoot();
1032  CPPUNIT_ASSERT(pNode != NULL);
1033  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
1034  const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
1035  CPPUNIT_ASSERT(pObjectNode != NULL);
1036  CCopasiObjectName objectCN = pObjectNode->getObjectCN();
1037  CPPUNIT_ASSERT(!objectCN.empty());
1038  std::vector<CCopasiContainer*> listOfContainers;
1039  listOfContainers.push_back(pModel);
1040  const CCopasiObject* pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
1041  CPPUNIT_ASSERT(pObject != NULL);
1042  CPPUNIT_ASSERT(pObject->isReference() == true);
1043  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Value"));
1044  CPPUNIT_ASSERT(pObject->getObjectParent() == pModelValue);
1045 }
const std::string & getObjectName() const
const CRegisteredObjectName & getObjectCN() const
const Type & getType() const
Definition: CMetab.h:178
static Type type(const Type &type)
bool isReference() const
static const char * MODEL_STRING9
Definition: test000064.h:71
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000064.h:98
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
CCopasiContainer * getObjectParent() const
void test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_6 ( )

Definition at line 1094 of file test000064.cpp.

References CModelEntity::ASSIGNMENT, CModelEntity::FIXED, CCopasiNode< _Data >::getChild(), CCopasiDataModel::getModel(), CEvaluationNodeObject::getObjectCN(), CCopasiObject::getObjectName(), CCopasiObject::getObjectParent(), CEvaluationNode::getType(), CCopasiDataModel::importSBMLFromString(), CCopasiObject::isReference(), CModel::ml, CModel::mMol, MODEL_STRING10, CEvaluationNodeOperator::MULTIPLY, CEvaluationNode::OBJECT, CCopasiDataModel::ObjectFromName(), CEvaluationNode::OPERATOR, pCOPASIDATAMODEL, CModelEntity::REACTIONS, CModel::s, CEvaluationNode::subType(), and CEvaluationNode::type().

1095 {
1096  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
1097  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING10));
1098  CModel* pModel = pDataModel->getModel();
1099  CPPUNIT_ASSERT(pModel != NULL);
1100  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::mMol);
1101  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::ml);
1102  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
1103  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
1104  const CCompartment* pCompartment = pModel->getCompartments()[0];
1105  CPPUNIT_ASSERT(pCompartment != NULL);
1106  CPPUNIT_ASSERT(pCompartment->getStatus() == CModelEntity::FIXED);
1107  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 2);
1108  CMetab* pA = pModel->getMetabolites()[0];
1109  CPPUNIT_ASSERT(pA != NULL);
1110  CPPUNIT_ASSERT(pA->getStatus() == CModelEntity::ASSIGNMENT);
1111  const CMetab* pB = pModel->getMetabolites()[1];
1112  CPPUNIT_ASSERT(pB != NULL);
1113  CPPUNIT_ASSERT(pB->getStatus() == CModelEntity::REACTIONS);
1114  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
1115  const CModelValue* pModelValue = pModel->getModelValues()[0];
1116  CPPUNIT_ASSERT(pModelValue != NULL);
1117  CPPUNIT_ASSERT(pModelValue->getStatus() == CModelEntity::FIXED);
1118  const CExpression* pExpr = pA->getExpressionPtr();
1119  // check the expression
1120  const CEvaluationNode* pNode = pExpr->getRoot();
1121  CPPUNIT_ASSERT(pNode != NULL);
1122  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OPERATOR);
1124  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getChild());
1125  CPPUNIT_ASSERT(pNode != NULL);
1126  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
1127  const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
1128  CPPUNIT_ASSERT(pObjectNode != NULL);
1129  CCopasiObjectName objectCN = pObjectNode->getObjectCN();
1130  CPPUNIT_ASSERT(!objectCN.empty());
1131  std::vector<CCopasiContainer*> listOfContainers;
1132  listOfContainers.push_back(pModel);
1133  const CCopasiObject* pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
1134  CPPUNIT_ASSERT(pObject != NULL);
1135  CPPUNIT_ASSERT(pObject->isReference() == true);
1136  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Value"));
1137  CPPUNIT_ASSERT(pObject->getObjectParent() == pModelValue);
1138  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getSibling());
1139  CPPUNIT_ASSERT(pNode != NULL);
1140  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
1141  pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
1142  CPPUNIT_ASSERT(pObjectNode != NULL);
1143  objectCN = pObjectNode->getObjectCN();
1144  CPPUNIT_ASSERT(!objectCN.empty());
1145  pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
1146  CPPUNIT_ASSERT(pObject != NULL);
1147  CPPUNIT_ASSERT(pObject->isReference() == true);
1148  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Volume"));
1149  CPPUNIT_ASSERT(pObject->getObjectParent() == pCompartment);
1150 }
const std::string & getObjectName() const
const CRegisteredObjectName & getObjectCN() const
const Type & getType() const
Definition: CMetab.h:178
static Type type(const Type &type)
bool isReference() const
static const char * MODEL_STRING10
Definition: test000064.h:72
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000064.h:98
static Type subType(const Type &type)
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50
CCopasiNode< Data > * getChild()
Definition: CCopasiNode.h:210
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
CCopasiContainer * getObjectParent() const
void test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_7 ( )

Definition at line 1199 of file test000064.cpp.

References CModelEntity::ASSIGNMENT, CModelEntity::FIXED, CCopasiNode< _Data >::getChild(), CCopasiDataModel::getModel(), CEvaluationNodeObject::getObjectCN(), CCopasiObject::getObjectName(), CCopasiObject::getObjectParent(), CEvaluationNode::getType(), CCopasiDataModel::importSBMLFromString(), CCopasiObject::isReference(), CModel::ml, MODEL_STRING11, CEvaluationNodeOperator::MULTIPLY, CModel::number, CEvaluationNode::OBJECT, CCopasiDataModel::ObjectFromName(), CEvaluationNode::OPERATOR, pCOPASIDATAMODEL, CModelEntity::REACTIONS, CModel::s, CEvaluationNode::subType(), and CEvaluationNode::type().

1200 {
1201  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
1202  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING11));
1203  CModel* pModel = pDataModel->getModel();
1204  CPPUNIT_ASSERT(pModel != NULL);
1205  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::number);
1206  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::ml);
1207  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
1208  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
1209  const CCompartment* pCompartment = pModel->getCompartments()[0];
1210  CPPUNIT_ASSERT(pCompartment != NULL);
1211  CPPUNIT_ASSERT(pCompartment->getStatus() == CModelEntity::FIXED);
1212  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 2);
1213  CMetab* pA = pModel->getMetabolites()[0];
1214  CPPUNIT_ASSERT(pA != NULL);
1215  CPPUNIT_ASSERT(pA->getStatus() == CModelEntity::ASSIGNMENT);
1216  const CMetab* pB = pModel->getMetabolites()[1];
1217  CPPUNIT_ASSERT(pB != NULL);
1218  CPPUNIT_ASSERT(pB->getStatus() == CModelEntity::REACTIONS);
1219  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
1220  const CModelValue* pModelValue = pModel->getModelValues()[0];
1221  CPPUNIT_ASSERT(pModelValue != NULL);
1222  CPPUNIT_ASSERT(pModelValue->getStatus() == CModelEntity::FIXED);
1223  const CExpression* pExpr = pA->getExpressionPtr();
1224  // check the expression
1225  const CEvaluationNode* pNode = pExpr->getRoot();
1226  CPPUNIT_ASSERT(pNode != NULL);
1227  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OPERATOR);
1229  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getChild());
1230  CPPUNIT_ASSERT(pNode != NULL);
1231  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
1232  const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
1233  CPPUNIT_ASSERT(pObjectNode != NULL);
1234  CCopasiObjectName objectCN = pObjectNode->getObjectCN();
1235  CPPUNIT_ASSERT(!objectCN.empty());
1236  std::vector<CCopasiContainer*> listOfContainers;
1237  listOfContainers.push_back(pModel);
1238  const CCopasiObject* pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
1239  CPPUNIT_ASSERT(pObject != NULL);
1240  CPPUNIT_ASSERT(pObject->isReference() == true);
1241  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Value"));
1242  CPPUNIT_ASSERT(pObject->getObjectParent() == pModelValue);
1243  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getSibling());
1244  CPPUNIT_ASSERT(pNode != NULL);
1245  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
1246  pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
1247  CPPUNIT_ASSERT(pObjectNode != NULL);
1248  objectCN = pObjectNode->getObjectCN();
1249  CPPUNIT_ASSERT(!objectCN.empty());
1250  pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
1251  CPPUNIT_ASSERT(pObject != NULL);
1252  CPPUNIT_ASSERT(pObject->isReference() == true);
1253  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Volume"));
1254  CPPUNIT_ASSERT(pObject->getObjectParent() == pCompartment);
1255 }
const std::string & getObjectName() const
const CRegisteredObjectName & getObjectCN() const
const Type & getType() const
Definition: CMetab.h:178
static Type type(const Type &type)
bool isReference() const
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000064.h:98
static Type subType(const Type &type)
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50
CCopasiNode< Data > * getChild()
Definition: CCopasiNode.h:210
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
static const char * MODEL_STRING11
Definition: test000064.h:73
CCopasiContainer * getObjectParent() const
void test000064::test_import_rule_expression_and_hasOnlySubstanceUnits_8 ( )

Definition at line 1304 of file test000064.cpp.

References CModelEntity::ASSIGNMENT, CModelEntity::FIXED, CCopasiDataModel::getModel(), CEvaluationNodeObject::getObjectCN(), CCopasiObject::getObjectName(), CCopasiObject::getObjectParent(), CEvaluationNode::getType(), CCopasiDataModel::importSBMLFromString(), CCopasiObject::isReference(), CModel::ml, MODEL_STRING12, CModel::number, CEvaluationNode::OBJECT, CCopasiDataModel::ObjectFromName(), pCOPASIDATAMODEL, CModelEntity::REACTIONS, CModel::s, and CEvaluationNode::type().

1305 {
1306  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
1307  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING12));
1308  CModel* pModel = pDataModel->getModel();
1309  CPPUNIT_ASSERT(pModel != NULL);
1310  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::number);
1311  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::ml);
1312  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
1313  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
1314  const CCompartment* pCompartment = pModel->getCompartments()[0];
1315  CPPUNIT_ASSERT(pCompartment != NULL);
1316  CPPUNIT_ASSERT(pCompartment->getStatus() == CModelEntity::FIXED);
1317  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 2);
1318  CMetab* pA = pModel->getMetabolites()[0];
1319  CPPUNIT_ASSERT(pA != NULL);
1320  CPPUNIT_ASSERT(pA->getStatus() == CModelEntity::ASSIGNMENT);
1321  const CMetab* pB = pModel->getMetabolites()[1];
1322  CPPUNIT_ASSERT(pB != NULL);
1323  CPPUNIT_ASSERT(pB->getStatus() == CModelEntity::REACTIONS);
1324  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
1325  const CModelValue* pModelValue = pModel->getModelValues()[0];
1326  CPPUNIT_ASSERT(pModelValue != NULL);
1327  CPPUNIT_ASSERT(pModelValue->getStatus() == CModelEntity::FIXED);
1328  const CExpression* pExpr = pA->getExpressionPtr();
1329  // check the expression
1330  const CEvaluationNode* pNode = pExpr->getRoot();
1331  CPPUNIT_ASSERT(pNode != NULL);
1332  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
1333  const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
1334  CPPUNIT_ASSERT(pObjectNode != NULL);
1335  CCopasiObjectName objectCN = pObjectNode->getObjectCN();
1336  CPPUNIT_ASSERT(!objectCN.empty());
1337  std::vector<CCopasiContainer*> listOfContainers;
1338  listOfContainers.push_back(pModel);
1339  const CCopasiObject* pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
1340  CPPUNIT_ASSERT(pObject != NULL);
1341  CPPUNIT_ASSERT(pObject->isReference() == true);
1342  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Value"));
1343  CPPUNIT_ASSERT(pObject->getObjectParent() == pModelValue);
1344 }
const std::string & getObjectName() const
const CRegisteredObjectName & getObjectCN() const
const Type & getType() const
Definition: CMetab.h:178
static const char * MODEL_STRING12
Definition: test000064.h:74
static Type type(const Type &type)
bool isReference() const
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000064.h:98
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
CCopasiContainer * getObjectParent() const

Member Data Documentation

const char * test000064::MODEL_STRING1
staticprotected
const char * test000064::MODEL_STRING10
staticprotected
const char * test000064::MODEL_STRING101
staticprotected
const char * test000064::MODEL_STRING102
staticprotected
const char * test000064::MODEL_STRING103
staticprotected
const char * test000064::MODEL_STRING104
staticprotected
const char * test000064::MODEL_STRING105
staticprotected
const char * test000064::MODEL_STRING106
staticprotected
const char * test000064::MODEL_STRING107
staticprotected
const char * test000064::MODEL_STRING108
staticprotected
const char * test000064::MODEL_STRING109
staticprotected
const char * test000064::MODEL_STRING11
staticprotected
const char * test000064::MODEL_STRING110
staticprotected
const char * test000064::MODEL_STRING111
staticprotected
const char * test000064::MODEL_STRING112
staticprotected
const char * test000064::MODEL_STRING113
staticprotected
const char * test000064::MODEL_STRING114
staticprotected
const char * test000064::MODEL_STRING115
staticprotected
const char * test000064::MODEL_STRING116
staticprotected
const char * test000064::MODEL_STRING12
staticprotected
const char * test000064::MODEL_STRING13
staticprotected
const char * test000064::MODEL_STRING14
staticprotected
const char * test000064::MODEL_STRING15
staticprotected
const char * test000064::MODEL_STRING16
staticprotected
const char * test000064::MODEL_STRING2
staticprotected
const char * test000064::MODEL_STRING3
staticprotected
const char * test000064::MODEL_STRING4
staticprotected
const char * test000064::MODEL_STRING5
staticprotected
const char * test000064::MODEL_STRING6
staticprotected
const char * test000064::MODEL_STRING7
staticprotected
const char * test000064::MODEL_STRING8
staticprotected
const char * test000064::MODEL_STRING9
staticprotected
CCopasiDataModel * test000064::pCOPASIDATAMODEL = NULL
staticprotected

These tests are supposed to make sure that assignments on a species with the hasOnlySubstanceUnits flag set are exported correctly. It tests rules and event assignments with and without the flag set.

Definition at line 98 of file test000064.h.

Referenced by setUp(), test_export_event_assignment_expression_and_hasOnlySubstanceUnits_1(), test_export_event_assignment_expression_and_hasOnlySubstanceUnits_2(), test_export_event_assignment_expression_and_hasOnlySubstanceUnits_3(), test_export_event_assignment_expression_and_hasOnlySubstanceUnits_4(), test_export_event_assignment_expression_and_hasOnlySubstanceUnits_5(), test_export_event_assignment_expression_and_hasOnlySubstanceUnits_6(), test_export_event_assignment_expression_and_hasOnlySubstanceUnits_7(), test_export_event_assignment_expression_and_hasOnlySubstanceUnits_8(), test_export_rule_expression_and_hasOnlySubstanceUnits_1(), test_export_rule_expression_and_hasOnlySubstanceUnits_2(), test_export_rule_expression_and_hasOnlySubstanceUnits_3(), test_export_rule_expression_and_hasOnlySubstanceUnits_4(), test_export_rule_expression_and_hasOnlySubstanceUnits_5(), test_export_rule_expression_and_hasOnlySubstanceUnits_6(), test_export_rule_expression_and_hasOnlySubstanceUnits_7(), test_export_rule_expression_and_hasOnlySubstanceUnits_8(), test_import_event_assignment_expression_and_hasOnlySubstanceUnits_1(), test_import_event_assignment_expression_and_hasOnlySubstanceUnits_2(), test_import_event_assignment_expression_and_hasOnlySubstanceUnits_3(), test_import_event_assignment_expression_and_hasOnlySubstanceUnits_4(), test_import_event_assignment_expression_and_hasOnlySubstanceUnits_5(), test_import_event_assignment_expression_and_hasOnlySubstanceUnits_6(), test_import_event_assignment_expression_and_hasOnlySubstanceUnits_7(), test_import_event_assignment_expression_and_hasOnlySubstanceUnits_8(), test_import_rule_expression_and_hasOnlySubstanceUnits_1(), test_import_rule_expression_and_hasOnlySubstanceUnits_2(), test_import_rule_expression_and_hasOnlySubstanceUnits_3(), test_import_rule_expression_and_hasOnlySubstanceUnits_4(), test_import_rule_expression_and_hasOnlySubstanceUnits_5(), test_import_rule_expression_and_hasOnlySubstanceUnits_6(), test_import_rule_expression_and_hasOnlySubstanceUnits_7(), and test_import_rule_expression_and_hasOnlySubstanceUnits_8().


The documentation for this class was generated from the following files: