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

#include <test000082.h>

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

Public Member Functions

void setUp ()
 
void tearDown ()
 
void test_export_delayAssignment_1 ()
 
void test_export_delayAssignment_2 ()
 
void test_export_delayAssignment_3 ()
 
void test_export_delayAssignment_4 ()
 
void test_export_delayAssignment_5 ()
 
void test_export_delayAssignment_6 ()
 
void test_import_delayAssignment_1 ()
 
void test_import_delayAssignment_2 ()
 
void test_import_delayAssignment_3 ()
 
void test_import_delayAssignment_4 ()
 
void test_import_delayAssignment_5 ()
 
void test_import_delayAssignment_6 ()
 
void test_import_delayAssignment_7 ()
 
void test_import_delayAssignment_8 ()
 

Static Protected Attributes

static const char * MODEL_STRING1
 
static const char * MODEL_STRING101
 
static const char * MODEL_STRING102
 
static const char * MODEL_STRING103
 
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 CCopasiDataModelpCOPASIDATAMODEL = NULL
 

Private Member Functions

 CPPUNIT_TEST (test_import_delayAssignment_1)
 
 CPPUNIT_TEST (test_import_delayAssignment_2)
 
 CPPUNIT_TEST (test_import_delayAssignment_3)
 
 CPPUNIT_TEST (test_import_delayAssignment_4)
 
 CPPUNIT_TEST (test_import_delayAssignment_5)
 
 CPPUNIT_TEST (test_import_delayAssignment_6)
 
 CPPUNIT_TEST (test_import_delayAssignment_7)
 
 CPPUNIT_TEST (test_import_delayAssignment_8)
 
 CPPUNIT_TEST (test_export_delayAssignment_1)
 
 CPPUNIT_TEST (test_export_delayAssignment_2)
 
 CPPUNIT_TEST (test_export_delayAssignment_3)
 
 CPPUNIT_TEST (test_export_delayAssignment_4)
 
 CPPUNIT_TEST (test_export_delayAssignment_5)
 
 CPPUNIT_TEST (test_export_delayAssignment_6)
 
 CPPUNIT_TEST_SUITE (test000082)
 
 CPPUNIT_TEST_SUITE_END ()
 

Detailed Description

Definition at line 29 of file test000082.h.

Member Function Documentation

test000082::CPPUNIT_TEST ( test_import_delayAssignment_1  )
private
test000082::CPPUNIT_TEST ( test_import_delayAssignment_2  )
private
test000082::CPPUNIT_TEST ( test_import_delayAssignment_3  )
private
test000082::CPPUNIT_TEST ( test_import_delayAssignment_4  )
private
test000082::CPPUNIT_TEST ( test_import_delayAssignment_5  )
private
test000082::CPPUNIT_TEST ( test_import_delayAssignment_6  )
private
test000082::CPPUNIT_TEST ( test_import_delayAssignment_7  )
private
test000082::CPPUNIT_TEST ( test_import_delayAssignment_8  )
private
test000082::CPPUNIT_TEST ( test_export_delayAssignment_1  )
private
test000082::CPPUNIT_TEST ( test_export_delayAssignment_2  )
private
test000082::CPPUNIT_TEST ( test_export_delayAssignment_3  )
private
test000082::CPPUNIT_TEST ( test_export_delayAssignment_4  )
private
test000082::CPPUNIT_TEST ( test_export_delayAssignment_5  )
private
test000082::CPPUNIT_TEST ( test_export_delayAssignment_6  )
private
test000082::CPPUNIT_TEST_SUITE ( test000082  )
private
test000082::CPPUNIT_TEST_SUITE_END ( )
private
void test000082::setUp ( )

Definition at line 51 of file test000082.cpp.

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

52 {
53  // Create the root container.
54  CCopasiRootContainer::init(0, NULL, false);
55  // Create the global data model.
57 }
static CCopasiDataModel * addDatamodel()
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000082.h:80
static void init(int argc, char *argv[], const bool &withGui=false)
void test000082::tearDown ( )

Definition at line 59 of file test000082.cpp.

References CCopasiRootContainer::destroy().

void test000082::test_export_delayAssignment_1 ( )

Definition at line 1116 of file test000082.cpp.

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

1117 {
1118  // load the CPS file
1119  // export to SBML
1120  // check the resulting SBML model
1121  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
1122  std::istringstream iss(test000082::MODEL_STRING101);
1123  bool result = load_cps_model_from_stream(iss, *pDataModel);
1124  CPPUNIT_ASSERT(result == true);
1125  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
1126  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 4).empty() == false);
1127  SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
1128  CPPUNIT_ASSERT(pDocument != NULL);
1129  CPPUNIT_ASSERT(pDocument->getLevel() == 2);
1130  CPPUNIT_ASSERT(pDocument->getVersion() == 4);
1131  Model* pModel = pDocument->getModel();
1132  CPPUNIT_ASSERT(pModel != NULL);
1133  // check the units
1134  UnitDefinition* pUDef = pModel->getUnitDefinition("time");
1135  Unit* pUnit = NULL;
1136 
1137  // since second is the default time unit, it does not have to be exported and
1138  // might be NULL
1139  if (pUDef != NULL)
1140  {
1141  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
1142  pUnit = pUDef->getUnit(0);
1143  CPPUNIT_ASSERT(pUnit != NULL);
1144  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_SECOND);
1145  CPPUNIT_ASSERT(pUnit->getScale() == 0);
1146  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
1147  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
1148  }
1149 
1150  pUDef = pModel->getUnitDefinition("substance");
1151  CPPUNIT_ASSERT(pUDef != NULL);
1152  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
1153  pUnit = pUDef->getUnit(0);
1154  CPPUNIT_ASSERT(pUnit != NULL);
1155  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_MOLE);
1156  CPPUNIT_ASSERT(pUnit->getScale() == -3);
1157  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
1158  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
1159  pUDef = pModel->getUnitDefinition("volume");
1160  CPPUNIT_ASSERT(pUDef != NULL);
1161  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
1162  pUnit = pUDef->getUnit(0);
1163  CPPUNIT_ASSERT(pUnit != NULL);
1164  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_LITRE);
1165  CPPUNIT_ASSERT(pUnit->getScale() == -3);
1166  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
1167  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
1168  // assert that there is only one compartment and
1169  // assert the compartment is constant
1170  CPPUNIT_ASSERT(pModel->getNumCompartments() == 1);
1171  CPPUNIT_ASSERT(pModel->getNumParameters() == 1);
1172  Parameter* pParameter1 = pModel->getParameter(0);
1173  CPPUNIT_ASSERT(pParameter1 != NULL);
1174  CPPUNIT_ASSERT(pParameter1->getName() == "K");
1175  CPPUNIT_ASSERT(pModel->getNumSpecies() == 2);
1176  Species* pSpecies1 = pModel->getSpecies(0);
1177  CPPUNIT_ASSERT(pSpecies1->getName() == "A");
1178  Species* pSpecies2 = pModel->getSpecies(1);
1179  CPPUNIT_ASSERT(pSpecies2->getName() == "B");
1180  CPPUNIT_ASSERT(pModel->getNumRules() == 0);
1181  CPPUNIT_ASSERT(pModel->getNumReactions() == 0);
1182  CPPUNIT_ASSERT(pModel->getNumEvents() == 1);
1183  Event* pEvent = pModel->getEvent(0);
1184  CPPUNIT_ASSERT(pEvent != NULL);
1185  // check the trigger
1186  CPPUNIT_ASSERT(pEvent->isSetTrigger());
1187  Trigger* pTrigger = pEvent->getTrigger();
1188  CPPUNIT_ASSERT(pTrigger != NULL);
1189  CPPUNIT_ASSERT(pTrigger->isSetMath());
1190  const ASTNode* pMath = pTrigger->getMath();
1191  CPPUNIT_ASSERT(pMath != NULL);
1192  CPPUNIT_ASSERT(pMath->getType() == AST_RELATIONAL_GT);
1193  CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
1194  const ASTNode* pChild = pMath->getChild(0);
1195  CPPUNIT_ASSERT(pChild != NULL);
1196  CPPUNIT_ASSERT(pChild->getType() == AST_NAME_TIME);
1197  pChild = pMath->getChild(1);
1198  CPPUNIT_ASSERT(pChild != NULL);
1199  CPPUNIT_ASSERT(pChild->getType() == AST_REAL);
1200  CPPUNIT_ASSERT(fabs((pChild->getReal() - 2.0) / 2.0) < 1e-6);
1201  // check the delay
1202  CPPUNIT_ASSERT(pEvent->isSetDelay());
1203  CPPUNIT_ASSERT(pEvent->getUseValuesFromTriggerTime() == true);
1204  Delay* pDelay = pEvent->getDelay();
1205  CPPUNIT_ASSERT(pDelay != NULL);
1206  CPPUNIT_ASSERT(pDelay->isSetMath());
1207  pMath = pDelay->getMath();
1208  CPPUNIT_ASSERT(pMath != NULL);
1209  CPPUNIT_ASSERT(pMath->getType() == AST_REAL);
1210  CPPUNIT_ASSERT(fabs((pMath->getReal() - 4.0) / 4.0) < 1e-6);
1211  // check the event assignment
1212  CPPUNIT_ASSERT(pEvent->getNumEventAssignments() == 1);
1213  EventAssignment* pEA = pEvent->getEventAssignment(0);
1214  CPPUNIT_ASSERT(pEA != NULL);
1215  CPPUNIT_ASSERT(pEA->getVariable() == pSpecies1->getId());
1216  pMath = pEA->getMath();
1217  CPPUNIT_ASSERT(pMath != NULL);
1218  // make sure the mathematical expression contains only one node that is a
1219  // reference to the global parameter
1220  CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
1221  CPPUNIT_ASSERT(pMath->getName() == pParameter1->getId());
1222 }
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: test000082.h:80
static const char * MODEL_STRING101
Definition: test000082.h:74
void test000082::test_export_delayAssignment_2 ( )

Definition at line 1224 of file test000082.cpp.

References CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CCopasiMessage::getLastMessage(), CCopasiDataModel::getModel(), CCopasiMessage::getNumber(), load_cps_model_from_stream(), MCSBML, MODEL_STRING101, pCOPASIDATAMODEL, and CCopasiMessage::size().

1225 {
1226  // load the CPS file
1227  // export to SBML
1228  // check the resulting SBML model
1229  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
1230  std::istringstream iss(test000082::MODEL_STRING101);
1231  bool result = load_cps_model_from_stream(iss, *pDataModel);
1232  CPPUNIT_ASSERT(result == true);
1233  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
1234  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 1).empty() == false);
1235  SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
1236  CPPUNIT_ASSERT(pDocument != NULL);
1237  CPPUNIT_ASSERT(pDocument->getLevel() == 2);
1238  CPPUNIT_ASSERT(pDocument->getVersion() == 1);
1239  Model* pModel = pDocument->getModel();
1240  CPPUNIT_ASSERT(pModel != NULL);
1241  // check the units
1242  UnitDefinition* pUDef = pModel->getUnitDefinition("time");
1243  Unit* pUnit = NULL;
1244 
1245  // since second is the default time unit, it does not have to be exported and
1246  // might be NULL
1247  if (pUDef != NULL)
1248  {
1249  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
1250  pUnit = pUDef->getUnit(0);
1251  CPPUNIT_ASSERT(pUnit != NULL);
1252  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_SECOND);
1253  CPPUNIT_ASSERT(pUnit->getScale() == 0);
1254  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
1255  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
1256  }
1257 
1258  pUDef = pModel->getUnitDefinition("substance");
1259  CPPUNIT_ASSERT(pUDef != NULL);
1260  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
1261  pUnit = pUDef->getUnit(0);
1262  CPPUNIT_ASSERT(pUnit != NULL);
1263  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_MOLE);
1264  CPPUNIT_ASSERT(pUnit->getScale() == -3);
1265  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
1266  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
1267  pUDef = pModel->getUnitDefinition("volume");
1268  CPPUNIT_ASSERT(pUDef != NULL);
1269  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
1270  pUnit = pUDef->getUnit(0);
1271  CPPUNIT_ASSERT(pUnit != NULL);
1272  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_LITRE);
1273  CPPUNIT_ASSERT(pUnit->getScale() == -3);
1274  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
1275  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
1276  // assert that there is only one compartment and
1277  // assert the compartment is constant
1278  CPPUNIT_ASSERT(pModel->getNumCompartments() == 1);
1279  CPPUNIT_ASSERT(pModel->getNumParameters() == 1);
1280  Parameter* pParameter1 = pModel->getParameter(0);
1281  CPPUNIT_ASSERT(pParameter1 != NULL);
1282  CPPUNIT_ASSERT(pParameter1->getName() == "K");
1283  CPPUNIT_ASSERT(pModel->getNumSpecies() == 2);
1284  Species* pSpecies1 = pModel->getSpecies(0);
1285  CPPUNIT_ASSERT(pSpecies1->getName() == "A");
1286  Species* pSpecies2 = pModel->getSpecies(1);
1287  CPPUNIT_ASSERT(pSpecies2->getName() == "B");
1288  CPPUNIT_ASSERT(pModel->getNumRules() == 0);
1289  CPPUNIT_ASSERT(pModel->getNumReactions() == 0);
1290  CPPUNIT_ASSERT(pModel->getNumEvents() == 1);
1291  Event* pEvent = pModel->getEvent(0);
1292  CPPUNIT_ASSERT(pEvent != NULL);
1293  // check the trigger
1294  CPPUNIT_ASSERT(pEvent->isSetTrigger());
1295  Trigger* pTrigger = pEvent->getTrigger();
1296  CPPUNIT_ASSERT(pTrigger != NULL);
1297  CPPUNIT_ASSERT(pTrigger->isSetMath());
1298  const ASTNode* pMath = pTrigger->getMath();
1299  CPPUNIT_ASSERT(pMath != NULL);
1300  CPPUNIT_ASSERT(pMath->getType() == AST_RELATIONAL_GT);
1301  CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
1302  const ASTNode* pChild = pMath->getChild(0);
1303  CPPUNIT_ASSERT(pChild != NULL);
1304  CPPUNIT_ASSERT(pChild->getType() == AST_NAME_TIME);
1305  pChild = pMath->getChild(1);
1306  CPPUNIT_ASSERT(pChild != NULL);
1307  CPPUNIT_ASSERT(pChild->getType() == AST_REAL);
1308  CPPUNIT_ASSERT(fabs((pChild->getReal() - 2.0) / 2.0) < 1e-6);
1309  // check the delay
1310  CPPUNIT_ASSERT(pEvent->isSetDelay());
1311  CPPUNIT_ASSERT(pEvent->getUseValuesFromTriggerTime() == true);
1312  Delay* pDelay = pEvent->getDelay();
1313  CPPUNIT_ASSERT(pDelay != NULL);
1314  CPPUNIT_ASSERT(pDelay->isSetMath());
1315  pMath = pDelay->getMath();
1316  CPPUNIT_ASSERT(pMath != NULL);
1317  CPPUNIT_ASSERT(pMath->getType() == AST_REAL);
1318  CPPUNIT_ASSERT(fabs((pMath->getReal() - 4.0) / 4.0) < 1e-6);
1319  // check the event assignment
1320  CPPUNIT_ASSERT(pEvent->getNumEventAssignments() == 1);
1321  EventAssignment* pEA = pEvent->getEventAssignment(0);
1322  CPPUNIT_ASSERT(pEA != NULL);
1323  CPPUNIT_ASSERT(pEA->getVariable() == pSpecies1->getId());
1324  pMath = pEA->getMath();
1325  CPPUNIT_ASSERT(pMath != NULL);
1326  // make sure the mathematical expression contains only one node that is a
1327  // reference to the global parameter
1328  CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
1329  CPPUNIT_ASSERT(pMath->getName() == pParameter1->getId());
1330  // make sure there is actually no warning MCSBML + 77
1331  unsigned int i = 0, iMax = CCopasiMessage::size();
1332 
1333  while (i < iMax)
1334  {
1336  CPPUNIT_ASSERT(message.getNumber() != MCSBML + 77);
1337  ++i;
1338  }
1339 }
SBMLDocument * getCurrentSBMLDocument()
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
const size_t & getNumber() const
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
#define MCSBML
static size_t size()
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000082.h:80
static CCopasiMessage getLastMessage()
static const char * MODEL_STRING101
Definition: test000082.h:74
void test000082::test_export_delayAssignment_3 ( )

Definition at line 1398 of file test000082.cpp.

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

1399 {
1400  // load the CPS file
1401  // export to SBML
1402  // check the resulting SBML model
1403  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
1404  std::istringstream iss(test000082::MODEL_STRING102);
1405  bool result = load_cps_model_from_stream(iss, *pDataModel);
1406  CPPUNIT_ASSERT(result == true);
1407  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
1408  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 4).empty() == false);
1409  SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
1410  CPPUNIT_ASSERT(pDocument != NULL);
1411  CPPUNIT_ASSERT(pDocument->getLevel() == 2);
1412  CPPUNIT_ASSERT(pDocument->getVersion() == 4);
1413  Model* pModel = pDocument->getModel();
1414  CPPUNIT_ASSERT(pModel != NULL);
1415  // check the units
1416  UnitDefinition* pUDef = pModel->getUnitDefinition("time");
1417  Unit* pUnit = NULL;
1418 
1419  // since second is the default time unit, it does not have to be exported and
1420  // might be NULL
1421  if (pUDef != NULL)
1422  {
1423  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
1424  pUnit = pUDef->getUnit(0);
1425  CPPUNIT_ASSERT(pUnit != NULL);
1426  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_SECOND);
1427  CPPUNIT_ASSERT(pUnit->getScale() == 0);
1428  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
1429  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
1430  }
1431 
1432  pUDef = pModel->getUnitDefinition("substance");
1433  CPPUNIT_ASSERT(pUDef != NULL);
1434  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
1435  pUnit = pUDef->getUnit(0);
1436  CPPUNIT_ASSERT(pUnit != NULL);
1437  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_MOLE);
1438  CPPUNIT_ASSERT(pUnit->getScale() == -3);
1439  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
1440  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
1441  pUDef = pModel->getUnitDefinition("volume");
1442  CPPUNIT_ASSERT(pUDef != NULL);
1443  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
1444  pUnit = pUDef->getUnit(0);
1445  CPPUNIT_ASSERT(pUnit != NULL);
1446  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_LITRE);
1447  CPPUNIT_ASSERT(pUnit->getScale() == -3);
1448  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
1449  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
1450  // assert that there is only one compartment and
1451  // assert the compartment is constant
1452  CPPUNIT_ASSERT(pModel->getNumCompartments() == 1);
1453  CPPUNIT_ASSERT(pModel->getNumParameters() == 1);
1454  Parameter* pParameter1 = pModel->getParameter(0);
1455  CPPUNIT_ASSERT(pParameter1 != NULL);
1456  CPPUNIT_ASSERT(pParameter1->getName() == "K");
1457  CPPUNIT_ASSERT(pModel->getNumSpecies() == 2);
1458  Species* pSpecies1 = pModel->getSpecies(0);
1459  CPPUNIT_ASSERT(pSpecies1->getName() == "A");
1460  Species* pSpecies2 = pModel->getSpecies(1);
1461  CPPUNIT_ASSERT(pSpecies2->getName() == "B");
1462  CPPUNIT_ASSERT(pModel->getNumRules() == 0);
1463  CPPUNIT_ASSERT(pModel->getNumReactions() == 0);
1464  CPPUNIT_ASSERT(pModel->getNumEvents() == 1);
1465  Event* pEvent = pModel->getEvent(0);
1466  CPPUNIT_ASSERT(pEvent != NULL);
1467  // check the trigger
1468  CPPUNIT_ASSERT(pEvent->isSetTrigger());
1469  Trigger* pTrigger = pEvent->getTrigger();
1470  CPPUNIT_ASSERT(pTrigger != NULL);
1471  CPPUNIT_ASSERT(pTrigger->isSetMath());
1472  const ASTNode* pMath = pTrigger->getMath();
1473  CPPUNIT_ASSERT(pMath != NULL);
1474  CPPUNIT_ASSERT(pMath->getType() == AST_RELATIONAL_GT);
1475  CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
1476  const ASTNode* pChild = pMath->getChild(0);
1477  CPPUNIT_ASSERT(pChild != NULL);
1478  CPPUNIT_ASSERT(pChild->getType() == AST_NAME_TIME);
1479  pChild = pMath->getChild(1);
1480  CPPUNIT_ASSERT(pChild != NULL);
1481  CPPUNIT_ASSERT(pChild->getType() == AST_REAL);
1482  CPPUNIT_ASSERT(fabs((pChild->getReal() - 2.0) / 2.0) < 1e-6);
1483  // check the delay
1484  CPPUNIT_ASSERT(pEvent->isSetDelay());
1485  CPPUNIT_ASSERT(pEvent->getUseValuesFromTriggerTime() == false);
1486  Delay* pDelay = pEvent->getDelay();
1487  CPPUNIT_ASSERT(pDelay != NULL);
1488  CPPUNIT_ASSERT(pDelay->isSetMath());
1489  pMath = pDelay->getMath();
1490  CPPUNIT_ASSERT(pMath != NULL);
1491  CPPUNIT_ASSERT(pMath->getType() == AST_REAL);
1492  CPPUNIT_ASSERT(fabs((pMath->getReal() - 4.0) / 4.0) < 1e-6);
1493  // check the event assignment
1494  CPPUNIT_ASSERT(pEvent->getNumEventAssignments() == 1);
1495  EventAssignment* pEA = pEvent->getEventAssignment(0);
1496  CPPUNIT_ASSERT(pEA != NULL);
1497  CPPUNIT_ASSERT(pEA->getVariable() == pSpecies1->getId());
1498  pMath = pEA->getMath();
1499  CPPUNIT_ASSERT(pMath != NULL);
1500  // make sure the mathematical expression contains only one node that is a
1501  // reference to the global parameter
1502  CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
1503  CPPUNIT_ASSERT(pMath->getName() == pParameter1->getId());
1504 }
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: test000082.h:80
static const char * MODEL_STRING102
Definition: test000082.h:76
void test000082::test_export_delayAssignment_4 ( )

Definition at line 1506 of file test000082.cpp.

References CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CCopasiMessage::getLastMessage(), CCopasiDataModel::getModel(), CCopasiMessage::getNumber(), load_cps_model_from_stream(), MCSBML, MODEL_STRING102, pCOPASIDATAMODEL, and CCopasiMessage::size().

1507 {
1508  // load the CPS file
1509  // export to SBML
1510  // check the resulting SBML model
1511  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
1512  std::istringstream iss(test000082::MODEL_STRING102);
1513  bool result = load_cps_model_from_stream(iss, *pDataModel);
1514  CPPUNIT_ASSERT(result == true);
1515  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
1516  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 1).empty() == false);
1517  SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
1518  CPPUNIT_ASSERT(pDocument != NULL);
1519  CPPUNIT_ASSERT(pDocument->getLevel() == 2);
1520  CPPUNIT_ASSERT(pDocument->getVersion() == 1);
1521  Model* pModel = pDocument->getModel();
1522  CPPUNIT_ASSERT(pModel != NULL);
1523  // check the units
1524  UnitDefinition* pUDef = pModel->getUnitDefinition("time");
1525  Unit* pUnit = NULL;
1526 
1527  // since second is the default time unit, it does not have to be exported and
1528  // might be NULL
1529  if (pUDef != NULL)
1530  {
1531  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
1532  pUnit = pUDef->getUnit(0);
1533  CPPUNIT_ASSERT(pUnit != NULL);
1534  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_SECOND);
1535  CPPUNIT_ASSERT(pUnit->getScale() == 0);
1536  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
1537  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
1538  }
1539 
1540  pUDef = pModel->getUnitDefinition("substance");
1541  CPPUNIT_ASSERT(pUDef != NULL);
1542  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
1543  pUnit = pUDef->getUnit(0);
1544  CPPUNIT_ASSERT(pUnit != NULL);
1545  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_MOLE);
1546  CPPUNIT_ASSERT(pUnit->getScale() == -3);
1547  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
1548  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
1549  pUDef = pModel->getUnitDefinition("volume");
1550  CPPUNIT_ASSERT(pUDef != NULL);
1551  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
1552  pUnit = pUDef->getUnit(0);
1553  CPPUNIT_ASSERT(pUnit != NULL);
1554  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_LITRE);
1555  CPPUNIT_ASSERT(pUnit->getScale() == -3);
1556  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
1557  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
1558  // assert that there is only one compartment and
1559  // assert the compartment is constant
1560  CPPUNIT_ASSERT(pModel->getNumCompartments() == 1);
1561  CPPUNIT_ASSERT(pModel->getNumParameters() == 1);
1562  Parameter* pParameter1 = pModel->getParameter(0);
1563  CPPUNIT_ASSERT(pParameter1 != NULL);
1564  CPPUNIT_ASSERT(pParameter1->getName() == "K");
1565  CPPUNIT_ASSERT(pModel->getNumSpecies() == 2);
1566  Species* pSpecies1 = pModel->getSpecies(0);
1567  CPPUNIT_ASSERT(pSpecies1->getName() == "A");
1568  Species* pSpecies2 = pModel->getSpecies(1);
1569  CPPUNIT_ASSERT(pSpecies2->getName() == "B");
1570  CPPUNIT_ASSERT(pModel->getNumRules() == 0);
1571  CPPUNIT_ASSERT(pModel->getNumReactions() == 0);
1572  CPPUNIT_ASSERT(pModel->getNumEvents() == 1);
1573  Event* pEvent = pModel->getEvent(0);
1574  CPPUNIT_ASSERT(pEvent != NULL);
1575  // check the trigger
1576  CPPUNIT_ASSERT(pEvent->isSetTrigger());
1577  Trigger* pTrigger = pEvent->getTrigger();
1578  CPPUNIT_ASSERT(pTrigger != NULL);
1579  CPPUNIT_ASSERT(pTrigger->isSetMath());
1580  const ASTNode* pMath = pTrigger->getMath();
1581  CPPUNIT_ASSERT(pMath != NULL);
1582  CPPUNIT_ASSERT(pMath->getType() == AST_RELATIONAL_GT);
1583  CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
1584  const ASTNode* pChild = pMath->getChild(0);
1585  CPPUNIT_ASSERT(pChild != NULL);
1586  CPPUNIT_ASSERT(pChild->getType() == AST_NAME_TIME);
1587  pChild = pMath->getChild(1);
1588  CPPUNIT_ASSERT(pChild != NULL);
1589  CPPUNIT_ASSERT(pChild->getType() == AST_REAL);
1590  CPPUNIT_ASSERT(fabs((pChild->getReal() - 2.0) / 2.0) < 1e-6);
1591  // check the delay
1592  CPPUNIT_ASSERT(pEvent->isSetDelay());
1593  CPPUNIT_ASSERT(pEvent->getUseValuesFromTriggerTime() == true);
1594  Delay* pDelay = pEvent->getDelay();
1595  CPPUNIT_ASSERT(pDelay != NULL);
1596  CPPUNIT_ASSERT(pDelay->isSetMath());
1597  pMath = pDelay->getMath();
1598  CPPUNIT_ASSERT(pMath != NULL);
1599  CPPUNIT_ASSERT(pMath->getType() == AST_REAL);
1600  CPPUNIT_ASSERT(fabs((pMath->getReal() - 4.0) / 4.0) < 1e-6);
1601  // check the event assignment
1602  CPPUNIT_ASSERT(pEvent->getNumEventAssignments() == 1);
1603  EventAssignment* pEA = pEvent->getEventAssignment(0);
1604  CPPUNIT_ASSERT(pEA != NULL);
1605  CPPUNIT_ASSERT(pEA->getVariable() == pSpecies1->getId());
1606  pMath = pEA->getMath();
1607  CPPUNIT_ASSERT(pMath != NULL);
1608  // make sure the mathematical expression contains only one node that is a
1609  // reference to the global parameter
1610  CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
1611  CPPUNIT_ASSERT(pMath->getName() == pParameter1->getId());
1612  // make sure there is actually a warning MCSBML + 77
1613  unsigned int i = 0, iMax = CCopasiMessage::size();
1614 
1615  while (i < iMax)
1616  {
1618 
1619  if (message.getNumber() == MCSBML + 77)
1620  {
1621  break;
1622  }
1623 
1624  ++i;
1625  }
1626 
1627  CPPUNIT_ASSERT(i != iMax);
1628 }
SBMLDocument * getCurrentSBMLDocument()
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
const size_t & getNumber() const
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
#define MCSBML
static size_t size()
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000082.h:80
static CCopasiMessage getLastMessage()
static const char * MODEL_STRING102
Definition: test000082.h:76
void test000082::test_export_delayAssignment_5 ( )

Definition at line 1687 of file test000082.cpp.

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

1688 {
1689  // load the CPS file
1690  // export to SBML
1691  // check the resulting SBML model
1692  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
1693  std::istringstream iss(test000082::MODEL_STRING103);
1694  bool result = load_cps_model_from_stream(iss, *pDataModel);
1695  CPPUNIT_ASSERT(result == true);
1696  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
1697  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 4).empty() == false);
1698  SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
1699  CPPUNIT_ASSERT(pDocument != NULL);
1700  CPPUNIT_ASSERT(pDocument->getLevel() == 2);
1701  CPPUNIT_ASSERT(pDocument->getVersion() == 4);
1702  Model* pModel = pDocument->getModel();
1703  CPPUNIT_ASSERT(pModel != NULL);
1704  // check the units
1705  UnitDefinition* pUDef = pModel->getUnitDefinition("time");
1706  Unit* pUnit = NULL;
1707 
1708  // since second is the default time unit, it does not have to be exported and
1709  // might be NULL
1710  if (pUDef != NULL)
1711  {
1712  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
1713  pUnit = pUDef->getUnit(0);
1714  CPPUNIT_ASSERT(pUnit != NULL);
1715  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_SECOND);
1716  CPPUNIT_ASSERT(pUnit->getScale() == 0);
1717  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
1718  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
1719  }
1720 
1721  pUDef = pModel->getUnitDefinition("substance");
1722  CPPUNIT_ASSERT(pUDef != NULL);
1723  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
1724  pUnit = pUDef->getUnit(0);
1725  CPPUNIT_ASSERT(pUnit != NULL);
1726  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_MOLE);
1727  CPPUNIT_ASSERT(pUnit->getScale() == -3);
1728  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
1729  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
1730  pUDef = pModel->getUnitDefinition("volume");
1731  CPPUNIT_ASSERT(pUDef != NULL);
1732  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
1733  pUnit = pUDef->getUnit(0);
1734  CPPUNIT_ASSERT(pUnit != NULL);
1735  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_LITRE);
1736  CPPUNIT_ASSERT(pUnit->getScale() == -3);
1737  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
1738  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
1739  // assert that there is only one compartment and
1740  // assert the compartment is constant
1741  CPPUNIT_ASSERT(pModel->getNumCompartments() == 1);
1742  CPPUNIT_ASSERT(pModel->getNumParameters() == 1);
1743  Parameter* pParameter1 = pModel->getParameter(0);
1744  CPPUNIT_ASSERT(pParameter1 != NULL);
1745  CPPUNIT_ASSERT(pParameter1->getName() == "K");
1746  CPPUNIT_ASSERT(pModel->getNumSpecies() == 2);
1747  Species* pSpecies1 = pModel->getSpecies(0);
1748  CPPUNIT_ASSERT(pSpecies1->getName() == "A");
1749  Species* pSpecies2 = pModel->getSpecies(1);
1750  CPPUNIT_ASSERT(pSpecies2->getName() == "B");
1751  CPPUNIT_ASSERT(pModel->getNumRules() == 0);
1752  CPPUNIT_ASSERT(pModel->getNumReactions() == 0);
1753  CPPUNIT_ASSERT(pModel->getNumEvents() == 1);
1754  Event* pEvent = pModel->getEvent(0);
1755  CPPUNIT_ASSERT(pEvent != NULL);
1756  // check the trigger
1757  CPPUNIT_ASSERT(pEvent->isSetTrigger());
1758  Trigger* pTrigger = pEvent->getTrigger();
1759  CPPUNIT_ASSERT(pTrigger != NULL);
1760  CPPUNIT_ASSERT(pTrigger->isSetMath());
1761  const ASTNode* pMath = pTrigger->getMath();
1762  CPPUNIT_ASSERT(pMath != NULL);
1763  CPPUNIT_ASSERT(pMath->getType() == AST_RELATIONAL_GT);
1764  CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
1765  const ASTNode* pChild = pMath->getChild(0);
1766  CPPUNIT_ASSERT(pChild != NULL);
1767  CPPUNIT_ASSERT(pChild->getType() == AST_NAME_TIME);
1768  pChild = pMath->getChild(1);
1769  CPPUNIT_ASSERT(pChild != NULL);
1770  CPPUNIT_ASSERT(pChild->getType() == AST_REAL);
1771  CPPUNIT_ASSERT(fabs((pChild->getReal() - 2.0) / 2.0) < 1e-6);
1772  // check the delay
1773  CPPUNIT_ASSERT(pEvent->isSetDelay() == false);
1774  CPPUNIT_ASSERT(pEvent->getUseValuesFromTriggerTime() == true);
1775  Delay* pDelay = pEvent->getDelay();
1776  CPPUNIT_ASSERT(pDelay == NULL);
1777  // check the event assignment
1778  CPPUNIT_ASSERT(pEvent->getNumEventAssignments() == 1);
1779  EventAssignment* pEA = pEvent->getEventAssignment(0);
1780  CPPUNIT_ASSERT(pEA != NULL);
1781  CPPUNIT_ASSERT(pEA->getVariable() == pSpecies1->getId());
1782  pMath = pEA->getMath();
1783  CPPUNIT_ASSERT(pMath != NULL);
1784  // make sure the mathematical expression contains only one node that is a
1785  // reference to the global parameter
1786  CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
1787  CPPUNIT_ASSERT(pMath->getName() == pParameter1->getId());
1788 }
SBMLDocument * getCurrentSBMLDocument()
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static const char * MODEL_STRING103
Definition: test000082.h:78
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000082.h:80
void test000082::test_export_delayAssignment_6 ( )

Definition at line 1790 of file test000082.cpp.

References CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CCopasiMessage::getLastMessage(), CCopasiDataModel::getModel(), CCopasiMessage::getNumber(), load_cps_model_from_stream(), MCSBML, MODEL_STRING103, pCOPASIDATAMODEL, and CCopasiMessage::size().

1791 {
1792  // load the CPS file
1793  // export to SBML
1794  // check the resulting SBML model
1795  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
1796  std::istringstream iss(test000082::MODEL_STRING103);
1797  bool result = load_cps_model_from_stream(iss, *pDataModel);
1798  CPPUNIT_ASSERT(result == true);
1799  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
1800  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 1).empty() == false);
1801  SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
1802  CPPUNIT_ASSERT(pDocument != NULL);
1803  CPPUNIT_ASSERT(pDocument->getLevel() == 2);
1804  CPPUNIT_ASSERT(pDocument->getVersion() == 1);
1805  Model* pModel = pDocument->getModel();
1806  CPPUNIT_ASSERT(pModel != NULL);
1807  // check the units
1808  UnitDefinition* pUDef = pModel->getUnitDefinition("time");
1809  Unit* pUnit = NULL;
1810 
1811  // since second is the default time unit, it does not have to be exported and
1812  // might be NULL
1813  if (pUDef != NULL)
1814  {
1815  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
1816  pUnit = pUDef->getUnit(0);
1817  CPPUNIT_ASSERT(pUnit != NULL);
1818  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_SECOND);
1819  CPPUNIT_ASSERT(pUnit->getScale() == 0);
1820  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
1821  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
1822  }
1823 
1824  pUDef = pModel->getUnitDefinition("substance");
1825  CPPUNIT_ASSERT(pUDef != NULL);
1826  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
1827  pUnit = pUDef->getUnit(0);
1828  CPPUNIT_ASSERT(pUnit != NULL);
1829  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_MOLE);
1830  CPPUNIT_ASSERT(pUnit->getScale() == -3);
1831  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
1832  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
1833  pUDef = pModel->getUnitDefinition("volume");
1834  CPPUNIT_ASSERT(pUDef != NULL);
1835  CPPUNIT_ASSERT(pUDef->getNumUnits() == 1);
1836  pUnit = pUDef->getUnit(0);
1837  CPPUNIT_ASSERT(pUnit != NULL);
1838  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_LITRE);
1839  CPPUNIT_ASSERT(pUnit->getScale() == -3);
1840  CPPUNIT_ASSERT(pUnit->getExponent() == 1);
1841  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
1842  // assert that there is only one compartment and
1843  // assert the compartment is constant
1844  CPPUNIT_ASSERT(pModel->getNumCompartments() == 1);
1845  CPPUNIT_ASSERT(pModel->getNumParameters() == 1);
1846  Parameter* pParameter1 = pModel->getParameter(0);
1847  CPPUNIT_ASSERT(pParameter1 != NULL);
1848  CPPUNIT_ASSERT(pParameter1->getName() == "K");
1849  CPPUNIT_ASSERT(pModel->getNumSpecies() == 2);
1850  Species* pSpecies1 = pModel->getSpecies(0);
1851  CPPUNIT_ASSERT(pSpecies1->getName() == "A");
1852  Species* pSpecies2 = pModel->getSpecies(1);
1853  CPPUNIT_ASSERT(pSpecies2->getName() == "B");
1854  CPPUNIT_ASSERT(pModel->getNumRules() == 0);
1855  CPPUNIT_ASSERT(pModel->getNumReactions() == 0);
1856  CPPUNIT_ASSERT(pModel->getNumEvents() == 1);
1857  Event* pEvent = pModel->getEvent(0);
1858  CPPUNIT_ASSERT(pEvent != NULL);
1859  // check the trigger
1860  CPPUNIT_ASSERT(pEvent->isSetTrigger());
1861  Trigger* pTrigger = pEvent->getTrigger();
1862  CPPUNIT_ASSERT(pTrigger != NULL);
1863  CPPUNIT_ASSERT(pTrigger->isSetMath());
1864  const ASTNode* pMath = pTrigger->getMath();
1865  CPPUNIT_ASSERT(pMath != NULL);
1866  CPPUNIT_ASSERT(pMath->getType() == AST_RELATIONAL_GT);
1867  CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
1868  const ASTNode* pChild = pMath->getChild(0);
1869  CPPUNIT_ASSERT(pChild != NULL);
1870  CPPUNIT_ASSERT(pChild->getType() == AST_NAME_TIME);
1871  pChild = pMath->getChild(1);
1872  CPPUNIT_ASSERT(pChild != NULL);
1873  CPPUNIT_ASSERT(pChild->getType() == AST_REAL);
1874  CPPUNIT_ASSERT(fabs((pChild->getReal() - 2.0) / 2.0) < 1e-6);
1875  // check the delay
1876  CPPUNIT_ASSERT(pEvent->isSetDelay() == false);
1877  CPPUNIT_ASSERT(pEvent->getUseValuesFromTriggerTime() == true);
1878  Delay* pDelay = pEvent->getDelay();
1879  CPPUNIT_ASSERT(pDelay == NULL);
1880  // check the event assignment
1881  CPPUNIT_ASSERT(pEvent->getNumEventAssignments() == 1);
1882  EventAssignment* pEA = pEvent->getEventAssignment(0);
1883  CPPUNIT_ASSERT(pEA != NULL);
1884  CPPUNIT_ASSERT(pEA->getVariable() == pSpecies1->getId());
1885  pMath = pEA->getMath();
1886  CPPUNIT_ASSERT(pMath != NULL);
1887  // make sure the mathematical expression contains only one node that is a
1888  // reference to the global parameter
1889  CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
1890  CPPUNIT_ASSERT(pMath->getName() == pParameter1->getId());
1891  // make sure there is actually no warning MCSBML + 77
1892  unsigned int i = 0, iMax = CCopasiMessage::size();
1893 
1894  while (i < iMax)
1895  {
1897  CPPUNIT_ASSERT(message.getNumber() != MCSBML + 77);
1898  ++i;
1899  }
1900 }
SBMLDocument * getCurrentSBMLDocument()
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
const size_t & getNumber() const
static const char * MODEL_STRING103
Definition: test000082.h:78
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
#define MCSBML
static size_t size()
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000082.h:80
static CCopasiMessage getLastMessage()
void test000082::test_import_delayAssignment_1 ( )

Definition at line 64 of file test000082.cpp.

References 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_STRING1, CEvaluationNode::NUMBER, CEvaluationNode::OBJECT, CCopasiDataModel::ObjectFromName(), pCOPASIDATAMODEL, CModel::s, CEvaluationNode::subType(), and CEvaluationNode::type().

65 {
66  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
67  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING1));
68  CModel* pModel = pDataModel->getModel();
69  CPPUNIT_ASSERT(pModel != NULL);
70  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::mMol);
71  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::ml);
72  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
73  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
74  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 1);
75  CMetab* pA = pModel->getMetabolites()[0];
76  CPPUNIT_ASSERT(pA != NULL);
77  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
78  const CModelValue* pModelValue = pModel->getModelValues()[0];
79  CPPUNIT_ASSERT(pModelValue != NULL);
80  CPPUNIT_ASSERT(pModel->getEvents().size() == 1);
81  const CEvent* pEvent = pModel->getEvents()[0];
82  CPPUNIT_ASSERT(pEvent != NULL);
83  // check the trigger expression
84  const CExpression* pExpr = pEvent->getTriggerExpressionPtr();
85  CPPUNIT_ASSERT(pExpr != NULL);
86  const CEvaluationNode* pNode = pExpr->getRoot();
87  CPPUNIT_ASSERT(pNode != NULL);
88  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::LOGICAL);
90  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getChild());
91  CPPUNIT_ASSERT(pNode != NULL);
92  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
93  const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
94  CPPUNIT_ASSERT(pObjectNode != NULL);
95  CCopasiObjectName objectCN = pObjectNode->getObjectCN();
96  CPPUNIT_ASSERT(!objectCN.empty());
97  std::vector<CCopasiContainer*> listOfContainers;
98  listOfContainers.push_back(pModel);
99  const CCopasiObject* pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
100  CPPUNIT_ASSERT(pObject != NULL);
101  CPPUNIT_ASSERT(pObject->isReference() == true);
102  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Time"));
103  CPPUNIT_ASSERT(pObject->getObjectParent() == pModel);
104  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getSibling());
105  CPPUNIT_ASSERT(pNode != NULL);
106  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::NUMBER);
107  const CEvaluationNodeNumber* pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pNode);
108  CPPUNIT_ASSERT(pNumberNode != NULL);
109  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 2.0) / 2.0) < 1e-6);
110  // check that there is a delay
111  pExpr = pEvent->getDelayExpressionPtr();
112  CPPUNIT_ASSERT(pExpr != NULL);
113  pNode = pExpr->getRoot();
114  CPPUNIT_ASSERT(pNode != NULL);
115  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::NUMBER);
116  pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pNode);
117  CPPUNIT_ASSERT(pNumberNode != NULL);
118  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 10.0) / 10.0) < 1e-6);
119  // check that the delayAssignment flag is set to true
120  CPPUNIT_ASSERT(pEvent->getDelayAssignment() == true);
121 
122  CPPUNIT_ASSERT(pEvent->getAssignments().size() == 1);
123  // check the event assignment
124  std::string key = pEvent->getAssignments()[0]->getTargetKey();
125  CPPUNIT_ASSERT(key == pA->getKey());
126  pExpr = pEvent->getAssignments()[0]->getExpressionPtr();
127  CPPUNIT_ASSERT(pExpr != NULL);
128  pNode = pExpr->getRoot();
129  CPPUNIT_ASSERT(pNode != NULL);
130  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
131  pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
132  CPPUNIT_ASSERT(pObjectNode != NULL);
133  objectCN = pObjectNode->getObjectCN();
134  CPPUNIT_ASSERT(!objectCN.empty());
135  pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
136  CPPUNIT_ASSERT(pObject != NULL);
137  CPPUNIT_ASSERT(pObject->isReference() == true);
138  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Value"));
139  CPPUNIT_ASSERT(pObject->getObjectParent() == pModelValue);
140 }
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)
static const char * MODEL_STRING1
Definition: test000082.h:53
bool isReference() const
static Type subType(const Type &type)
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000082.h:80
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 test000082::test_import_delayAssignment_2 ( )

Definition at line 201 of file test000082.cpp.

References 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_STRING2, CEvaluationNode::NUMBER, CEvaluationNode::OBJECT, CCopasiDataModel::ObjectFromName(), pCOPASIDATAMODEL, CModel::s, CEvaluationNode::subType(), and CEvaluationNode::type().

202 {
203  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
204  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING2));
205  CModel* pModel = pDataModel->getModel();
206  CPPUNIT_ASSERT(pModel != NULL);
207  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::mMol);
208  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::ml);
209  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
210  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
211  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 1);
212  CMetab* pA = pModel->getMetabolites()[0];
213  CPPUNIT_ASSERT(pA != NULL);
214  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
215  const CModelValue* pModelValue = pModel->getModelValues()[0];
216  CPPUNIT_ASSERT(pModelValue != NULL);
217  CPPUNIT_ASSERT(pModel->getEvents().size() == 1);
218  const CEvent* pEvent = pModel->getEvents()[0];
219  CPPUNIT_ASSERT(pEvent != NULL);
220  // check the trigger expression
221  const CExpression* pExpr = pEvent->getTriggerExpressionPtr();
222  CPPUNIT_ASSERT(pExpr != NULL);
223  const CEvaluationNode* pNode = pExpr->getRoot();
224  CPPUNIT_ASSERT(pNode != NULL);
225  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::LOGICAL);
227  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getChild());
228  CPPUNIT_ASSERT(pNode != NULL);
229  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
230  const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
231  CPPUNIT_ASSERT(pObjectNode != NULL);
232  CCopasiObjectName objectCN = pObjectNode->getObjectCN();
233  CPPUNIT_ASSERT(!objectCN.empty());
234  std::vector<CCopasiContainer*> listOfContainers;
235  listOfContainers.push_back(pModel);
236  const CCopasiObject* pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
237  CPPUNIT_ASSERT(pObject != NULL);
238  CPPUNIT_ASSERT(pObject->isReference() == true);
239  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Time"));
240  CPPUNIT_ASSERT(pObject->getObjectParent() == pModel);
241  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getSibling());
242  CPPUNIT_ASSERT(pNode != NULL);
243  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::NUMBER);
244  const CEvaluationNodeNumber* pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pNode);
245  CPPUNIT_ASSERT(pNumberNode != NULL);
246  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 2.0) / 2.0) < 1e-6);
247  // check that there is a delay
248  pExpr = pEvent->getDelayExpressionPtr();
249  CPPUNIT_ASSERT(pExpr == NULL);
250  // check that the delayAssignment flag is set to true
251  CPPUNIT_ASSERT(pEvent->getDelayAssignment() == true);
252 
253  CPPUNIT_ASSERT(pEvent->getAssignments().size() == 1);
254  // check the event assignment
255  std::string key = pEvent->getAssignments()[0]->getTargetKey();
256  CPPUNIT_ASSERT(key == pA->getKey());
257  pExpr = pEvent->getAssignments()[0]->getExpressionPtr();
258  CPPUNIT_ASSERT(pExpr != NULL);
259  pNode = pExpr->getRoot();
260  CPPUNIT_ASSERT(pNode != NULL);
261  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
262  pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
263  CPPUNIT_ASSERT(pObjectNode != NULL);
264  objectCN = pObjectNode->getObjectCN();
265  CPPUNIT_ASSERT(!objectCN.empty());
266  pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
267  CPPUNIT_ASSERT(pObject != NULL);
268  CPPUNIT_ASSERT(pObject->isReference() == true);
269  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Value"));
270  CPPUNIT_ASSERT(pObject->getObjectParent() == pModelValue);
271 }
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 Type subType(const Type &type)
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000082.h:80
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50
static const char * MODEL_STRING2
Definition: test000082.h:56
CCopasiNode< Data > * getChild()
Definition: CCopasiNode.h:210
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
CEvaluationNode * getRoot()
CCopasiContainer * getObjectParent() const
void test000082::test_import_delayAssignment_3 ( )

Definition at line 327 of file test000082.cpp.

References 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_STRING3, CEvaluationNode::NUMBER, CEvaluationNode::OBJECT, CCopasiDataModel::ObjectFromName(), pCOPASIDATAMODEL, CModel::s, CEvaluationNode::subType(), and CEvaluationNode::type().

328 {
329  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
330  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING3));
331  CModel* pModel = pDataModel->getModel();
332  CPPUNIT_ASSERT(pModel != NULL);
333  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::mMol);
334  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::ml);
335  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
336  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
337  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 1);
338  CMetab* pA = pModel->getMetabolites()[0];
339  CPPUNIT_ASSERT(pA != NULL);
340  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
341  const CModelValue* pModelValue = pModel->getModelValues()[0];
342  CPPUNIT_ASSERT(pModelValue != NULL);
343  CPPUNIT_ASSERT(pModel->getEvents().size() == 1);
344  const CEvent* pEvent = pModel->getEvents()[0];
345  CPPUNIT_ASSERT(pEvent != NULL);
346  // check the trigger expression
347  const CExpression* pExpr = pEvent->getTriggerExpressionPtr();
348  CPPUNIT_ASSERT(pExpr != NULL);
349  const CEvaluationNode* pNode = pExpr->getRoot();
350  CPPUNIT_ASSERT(pNode != NULL);
351  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::LOGICAL);
353  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getChild());
354  CPPUNIT_ASSERT(pNode != NULL);
355  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
356  const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
357  CPPUNIT_ASSERT(pObjectNode != NULL);
358  CCopasiObjectName objectCN = pObjectNode->getObjectCN();
359  CPPUNIT_ASSERT(!objectCN.empty());
360  std::vector<CCopasiContainer*> listOfContainers;
361  listOfContainers.push_back(pModel);
362  const CCopasiObject* pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
363  CPPUNIT_ASSERT(pObject != NULL);
364  CPPUNIT_ASSERT(pObject->isReference() == true);
365  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Time"));
366  CPPUNIT_ASSERT(pObject->getObjectParent() == pModel);
367  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getSibling());
368  CPPUNIT_ASSERT(pNode != NULL);
369  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::NUMBER);
370  const CEvaluationNodeNumber* pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pNode);
371  CPPUNIT_ASSERT(pNumberNode != NULL);
372  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 2.0) / 2.0) < 1e-6);
373  // check that there is a delay
374  pExpr = pEvent->getDelayExpressionPtr();
375  CPPUNIT_ASSERT(pExpr != NULL);
376  pNode = pExpr->getRoot();
377  CPPUNIT_ASSERT(pNode != NULL);
378  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::NUMBER);
379  pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pNode);
380  CPPUNIT_ASSERT(pNumberNode != NULL);
381  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 10.0) / 10.0) < 1e-6);
382  // check that the delayAssignment flag is set to true
383  CPPUNIT_ASSERT(pEvent->getDelayAssignment() == true);
384 
385  CPPUNIT_ASSERT(pEvent->getAssignments().size() == 1);
386  // check the event assignment
387  std::string key = pEvent->getAssignments()[0]->getTargetKey();
388  CPPUNIT_ASSERT(key == pA->getKey());
389  pExpr = pEvent->getAssignments()[0]->getExpressionPtr();
390  CPPUNIT_ASSERT(pExpr != NULL);
391  pNode = pExpr->getRoot();
392  CPPUNIT_ASSERT(pNode != NULL);
393  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
394  pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
395  CPPUNIT_ASSERT(pObjectNode != NULL);
396  objectCN = pObjectNode->getObjectCN();
397  CPPUNIT_ASSERT(!objectCN.empty());
398  pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
399  CPPUNIT_ASSERT(pObject != NULL);
400  CPPUNIT_ASSERT(pObject->isReference() == true);
401  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Value"));
402  CPPUNIT_ASSERT(pObject->getObjectParent() == pModelValue);
403 }
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 Type subType(const Type &type)
static const char * MODEL_STRING3
Definition: test000082.h:59
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000082.h:80
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 test000082::test_import_delayAssignment_4 ( )

Definition at line 464 of file test000082.cpp.

References 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_STRING4, CEvaluationNode::NUMBER, CEvaluationNode::OBJECT, CCopasiDataModel::ObjectFromName(), pCOPASIDATAMODEL, CModel::s, CEvaluationNode::subType(), and CEvaluationNode::type().

465 {
466  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
467  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING4));
468  CModel* pModel = pDataModel->getModel();
469  CPPUNIT_ASSERT(pModel != NULL);
470  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::mMol);
471  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::ml);
472  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
473  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
474  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 1);
475  CMetab* pA = pModel->getMetabolites()[0];
476  CPPUNIT_ASSERT(pA != NULL);
477  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
478  const CModelValue* pModelValue = pModel->getModelValues()[0];
479  CPPUNIT_ASSERT(pModelValue != NULL);
480  CPPUNIT_ASSERT(pModel->getEvents().size() == 1);
481  const CEvent* pEvent = pModel->getEvents()[0];
482  CPPUNIT_ASSERT(pEvent != NULL);
483  // check the trigger expression
484  const CExpression* pExpr = pEvent->getTriggerExpressionPtr();
485  CPPUNIT_ASSERT(pExpr != NULL);
486  const CEvaluationNode* pNode = pExpr->getRoot();
487  CPPUNIT_ASSERT(pNode != NULL);
488  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::LOGICAL);
490  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getChild());
491  CPPUNIT_ASSERT(pNode != NULL);
492  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
493  const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
494  CPPUNIT_ASSERT(pObjectNode != NULL);
495  CCopasiObjectName objectCN = pObjectNode->getObjectCN();
496  CPPUNIT_ASSERT(!objectCN.empty());
497  std::vector<CCopasiContainer*> listOfContainers;
498  listOfContainers.push_back(pModel);
499  const CCopasiObject* pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
500  CPPUNIT_ASSERT(pObject != NULL);
501  CPPUNIT_ASSERT(pObject->isReference() == true);
502  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Time"));
503  CPPUNIT_ASSERT(pObject->getObjectParent() == pModel);
504  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getSibling());
505  CPPUNIT_ASSERT(pNode != NULL);
506  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::NUMBER);
507  const CEvaluationNodeNumber* pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pNode);
508  CPPUNIT_ASSERT(pNumberNode != NULL);
509  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 2.0) / 2.0) < 1e-6);
510  // check that there is a delay
511  pExpr = pEvent->getDelayExpressionPtr();
512  CPPUNIT_ASSERT(pExpr != NULL);
513  pNode = pExpr->getRoot();
514  CPPUNIT_ASSERT(pNode != NULL);
515  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::NUMBER);
516  pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pNode);
517  CPPUNIT_ASSERT(pNumberNode != NULL);
518  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 10.0) / 10.0) < 1e-6);
519  // check that the delayAssignment flag is set to true
520  CPPUNIT_ASSERT(pEvent->getDelayAssignment() == true);
521 
522  CPPUNIT_ASSERT(pEvent->getAssignments().size() == 1);
523  // check the event assignment
524  std::string key = pEvent->getAssignments()[0]->getTargetKey();
525  CPPUNIT_ASSERT(key == pA->getKey());
526  pExpr = pEvent->getAssignments()[0]->getExpressionPtr();
527  CPPUNIT_ASSERT(pExpr != NULL);
528  pNode = pExpr->getRoot();
529  CPPUNIT_ASSERT(pNode != NULL);
530  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
531  pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
532  CPPUNIT_ASSERT(pObjectNode != NULL);
533  objectCN = pObjectNode->getObjectCN();
534  CPPUNIT_ASSERT(!objectCN.empty());
535  pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
536  CPPUNIT_ASSERT(pObject != NULL);
537  CPPUNIT_ASSERT(pObject->isReference() == true);
538  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Value"));
539  CPPUNIT_ASSERT(pObject->getObjectParent() == pModelValue);
540 }
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_STRING4
Definition: test000082.h:61
Definition: CMetab.h:178
static Type type(const Type &type)
bool isReference() const
static Type subType(const Type &type)
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000082.h:80
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 test000082::test_import_delayAssignment_5 ( )

Definition at line 601 of file test000082.cpp.

References 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(), pCOPASIDATAMODEL, CModel::s, CEvaluationNode::subType(), and CEvaluationNode::type().

602 {
603  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
604  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING5));
605  CModel* pModel = pDataModel->getModel();
606  CPPUNIT_ASSERT(pModel != NULL);
607  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::mMol);
608  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::ml);
609  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
610  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
611  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 1);
612  CMetab* pA = pModel->getMetabolites()[0];
613  CPPUNIT_ASSERT(pA != NULL);
614  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
615  const CModelValue* pModelValue = pModel->getModelValues()[0];
616  CPPUNIT_ASSERT(pModelValue != NULL);
617  CPPUNIT_ASSERT(pModel->getEvents().size() == 1);
618  const CEvent* pEvent = pModel->getEvents()[0];
619  CPPUNIT_ASSERT(pEvent != NULL);
620  // check the trigger expression
621  const CExpression* pExpr = pEvent->getTriggerExpressionPtr();
622  CPPUNIT_ASSERT(pExpr != NULL);
623  const CEvaluationNode* pNode = pExpr->getRoot();
624  CPPUNIT_ASSERT(pNode != NULL);
625  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::LOGICAL);
627  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getChild());
628  CPPUNIT_ASSERT(pNode != NULL);
629  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
630  const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
631  CPPUNIT_ASSERT(pObjectNode != NULL);
632  CCopasiObjectName objectCN = pObjectNode->getObjectCN();
633  CPPUNIT_ASSERT(!objectCN.empty());
634  std::vector<CCopasiContainer*> listOfContainers;
635  listOfContainers.push_back(pModel);
636  const CCopasiObject* pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
637  CPPUNIT_ASSERT(pObject != NULL);
638  CPPUNIT_ASSERT(pObject->isReference() == true);
639  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Time"));
640  CPPUNIT_ASSERT(pObject->getObjectParent() == pModel);
641  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getSibling());
642  CPPUNIT_ASSERT(pNode != NULL);
643  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::NUMBER);
644  const CEvaluationNodeNumber* pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pNode);
645  CPPUNIT_ASSERT(pNumberNode != NULL);
646  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 2.0) / 2.0) < 1e-6);
647  // check that there is a delay
648  pExpr = pEvent->getDelayExpressionPtr();
649  CPPUNIT_ASSERT(pExpr != NULL);
650  pNode = pExpr->getRoot();
651  CPPUNIT_ASSERT(pNode != NULL);
652  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::NUMBER);
653  pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pNode);
654  CPPUNIT_ASSERT(pNumberNode != NULL);
655  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 10.0) / 10.0) < 1e-6);
656  // check that the delayAssignment flag is set to false
657  CPPUNIT_ASSERT(pEvent->getDelayAssignment() == false);
658 
659  CPPUNIT_ASSERT(pEvent->getAssignments().size() == 1);
660  // check the event assignment
661  std::string key = pEvent->getAssignments()[0]->getTargetKey();
662  CPPUNIT_ASSERT(key == pA->getKey());
663  pExpr = pEvent->getAssignments()[0]->getExpressionPtr();
664  CPPUNIT_ASSERT(pExpr != NULL);
665  pNode = pExpr->getRoot();
666  CPPUNIT_ASSERT(pNode != NULL);
667  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
668  pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
669  CPPUNIT_ASSERT(pObjectNode != NULL);
670  objectCN = pObjectNode->getObjectCN();
671  CPPUNIT_ASSERT(!objectCN.empty());
672  pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
673  CPPUNIT_ASSERT(pObject != NULL);
674  CPPUNIT_ASSERT(pObject->isReference() == true);
675  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Value"));
676  CPPUNIT_ASSERT(pObject->getObjectParent() == pModelValue);
677 }
Definition: CEvent.h:152
const std::string & getObjectName() const
const CRegisteredObjectName & getObjectCN() const
static const char * MODEL_STRING5
Definition: test000082.h:63
const C_FLOAT64 & getValue() const
const Type & getType() const
Definition: CMetab.h:178
static Type type(const Type &type)
bool isReference() const
static Type subType(const Type &type)
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000082.h:80
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 test000082::test_import_delayAssignment_6 ( )

Definition at line 738 of file test000082.cpp.

References 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, CModel::s, CEvaluationNode::subType(), and CEvaluationNode::type().

739 {
740  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
741  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING6));
742  CModel* pModel = pDataModel->getModel();
743  CPPUNIT_ASSERT(pModel != NULL);
744  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::mMol);
745  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::ml);
746  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
747  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
748  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 1);
749  CMetab* pA = pModel->getMetabolites()[0];
750  CPPUNIT_ASSERT(pA != NULL);
751  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
752  const CModelValue* pModelValue = pModel->getModelValues()[0];
753  CPPUNIT_ASSERT(pModelValue != NULL);
754  CPPUNIT_ASSERT(pModel->getEvents().size() == 1);
755  const CEvent* pEvent = pModel->getEvents()[0];
756  CPPUNIT_ASSERT(pEvent != NULL);
757  // check the trigger expression
758  const CExpression* pExpr = pEvent->getTriggerExpressionPtr();
759  CPPUNIT_ASSERT(pExpr != NULL);
760  const CEvaluationNode* pNode = pExpr->getRoot();
761  CPPUNIT_ASSERT(pNode != NULL);
762  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::LOGICAL);
764  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getChild());
765  CPPUNIT_ASSERT(pNode != NULL);
766  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
767  const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
768  CPPUNIT_ASSERT(pObjectNode != NULL);
769  CCopasiObjectName objectCN = pObjectNode->getObjectCN();
770  CPPUNIT_ASSERT(!objectCN.empty());
771  std::vector<CCopasiContainer*> listOfContainers;
772  listOfContainers.push_back(pModel);
773  const CCopasiObject* pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
774  CPPUNIT_ASSERT(pObject != NULL);
775  CPPUNIT_ASSERT(pObject->isReference() == true);
776  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Time"));
777  CPPUNIT_ASSERT(pObject->getObjectParent() == pModel);
778  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getSibling());
779  CPPUNIT_ASSERT(pNode != NULL);
780  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::NUMBER);
781  const CEvaluationNodeNumber* pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pNode);
782  CPPUNIT_ASSERT(pNumberNode != NULL);
783  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 2.0) / 2.0) < 1e-6);
784  // check that there is a delay
785  pExpr = pEvent->getDelayExpressionPtr();
786  CPPUNIT_ASSERT(pExpr == NULL);
787  // check that the delayAssignment flag is set to true
788  CPPUNIT_ASSERT(pEvent->getDelayAssignment() == true);
789 
790  CPPUNIT_ASSERT(pEvent->getAssignments().size() == 1);
791  // check the event assignment
792  std::string key = pEvent->getAssignments()[0]->getTargetKey();
793  CPPUNIT_ASSERT(key == pA->getKey());
794  pExpr = pEvent->getAssignments()[0]->getExpressionPtr();
795  CPPUNIT_ASSERT(pExpr != NULL);
796  pNode = pExpr->getRoot();
797  CPPUNIT_ASSERT(pNode != NULL);
798  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
799  pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
800  CPPUNIT_ASSERT(pObjectNode != NULL);
801  objectCN = pObjectNode->getObjectCN();
802  CPPUNIT_ASSERT(!objectCN.empty());
803  pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
804  CPPUNIT_ASSERT(pObject != NULL);
805  CPPUNIT_ASSERT(pObject->isReference() == true);
806  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Value"));
807  CPPUNIT_ASSERT(pObject->getObjectParent() == pModelValue);
808 }
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 Type subType(const Type &type)
static const char * MODEL_STRING6
Definition: test000082.h:65
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000082.h:80
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 test000082::test_import_delayAssignment_7 ( )

Definition at line 864 of file test000082.cpp.

References 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_STRING7, CEvaluationNode::NUMBER, CEvaluationNode::OBJECT, CCopasiDataModel::ObjectFromName(), pCOPASIDATAMODEL, CModel::s, CEvaluationNode::subType(), and CEvaluationNode::type().

865 {
866  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
867  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING7));
868  CModel* pModel = pDataModel->getModel();
869  CPPUNIT_ASSERT(pModel != NULL);
870  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::mMol);
871  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::ml);
872  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
873  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
874  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 1);
875  CMetab* pA = pModel->getMetabolites()[0];
876  CPPUNIT_ASSERT(pA != NULL);
877  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
878  const CModelValue* pModelValue = pModel->getModelValues()[0];
879  CPPUNIT_ASSERT(pModelValue != NULL);
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 a delay
911  pExpr = pEvent->getDelayExpressionPtr();
912  CPPUNIT_ASSERT(pExpr == NULL);
913  // check that the delayAssignment flag is set to true
914  CPPUNIT_ASSERT(pEvent->getDelayAssignment() == true);
915 
916  CPPUNIT_ASSERT(pEvent->getAssignments().size() == 1);
917  // check the event assignment
918  std::string key = pEvent->getAssignments()[0]->getTargetKey();
919  CPPUNIT_ASSERT(key == pA->getKey());
920  pExpr = pEvent->getAssignments()[0]->getExpressionPtr();
921  CPPUNIT_ASSERT(pExpr != NULL);
922  pNode = pExpr->getRoot();
923  CPPUNIT_ASSERT(pNode != NULL);
924  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
925  pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
926  CPPUNIT_ASSERT(pObjectNode != NULL);
927  objectCN = pObjectNode->getObjectCN();
928  CPPUNIT_ASSERT(!objectCN.empty());
929  pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
930  CPPUNIT_ASSERT(pObject != NULL);
931  CPPUNIT_ASSERT(pObject->isReference() == true);
932  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Value"));
933  CPPUNIT_ASSERT(pObject->getObjectParent() == pModelValue);
934 }
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 Type subType(const Type &type)
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000082.h:80
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50
static const char * MODEL_STRING7
Definition: test000082.h:67
CCopasiNode< Data > * getChild()
Definition: CCopasiNode.h:210
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
CEvaluationNode * getRoot()
CCopasiContainer * getObjectParent() const
void test000082::test_import_delayAssignment_8 ( )

Definition at line 990 of file test000082.cpp.

References 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_STRING8, CEvaluationNode::NUMBER, CEvaluationNode::OBJECT, CCopasiDataModel::ObjectFromName(), pCOPASIDATAMODEL, CModel::s, CEvaluationNode::subType(), and CEvaluationNode::type().

991 {
992  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
993  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING8));
994  CModel* pModel = pDataModel->getModel();
995  CPPUNIT_ASSERT(pModel != NULL);
996  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::mMol);
997  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::ml);
998  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
999  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
1000  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 1);
1001  CMetab* pA = pModel->getMetabolites()[0];
1002  CPPUNIT_ASSERT(pA != NULL);
1003  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
1004  const CModelValue* pModelValue = pModel->getModelValues()[0];
1005  CPPUNIT_ASSERT(pModelValue != NULL);
1006  CPPUNIT_ASSERT(pModel->getEvents().size() == 1);
1007  const CEvent* pEvent = pModel->getEvents()[0];
1008  CPPUNIT_ASSERT(pEvent != NULL);
1009  // check the trigger expression
1010  const CExpression* pExpr = pEvent->getTriggerExpressionPtr();
1011  CPPUNIT_ASSERT(pExpr != NULL);
1012  const CEvaluationNode* pNode = pExpr->getRoot();
1013  CPPUNIT_ASSERT(pNode != NULL);
1014  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::LOGICAL);
1016  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getChild());
1017  CPPUNIT_ASSERT(pNode != NULL);
1018  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
1019  const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
1020  CPPUNIT_ASSERT(pObjectNode != NULL);
1021  CCopasiObjectName objectCN = pObjectNode->getObjectCN();
1022  CPPUNIT_ASSERT(!objectCN.empty());
1023  std::vector<CCopasiContainer*> listOfContainers;
1024  listOfContainers.push_back(pModel);
1025  const CCopasiObject* pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
1026  CPPUNIT_ASSERT(pObject != NULL);
1027  CPPUNIT_ASSERT(pObject->isReference() == true);
1028  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Time"));
1029  CPPUNIT_ASSERT(pObject->getObjectParent() == pModel);
1030  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getSibling());
1031  CPPUNIT_ASSERT(pNode != NULL);
1032  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::NUMBER);
1033  const CEvaluationNodeNumber* pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pNode);
1034  CPPUNIT_ASSERT(pNumberNode != NULL);
1035  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 2.0) / 2.0) < 1e-6);
1036  // check that there is a delay
1037  pExpr = pEvent->getDelayExpressionPtr();
1038  CPPUNIT_ASSERT(pExpr == NULL);
1039  // check that the delayAssignment flag is set to true
1040  CPPUNIT_ASSERT(pEvent->getDelayAssignment() == true);
1041 
1042  CPPUNIT_ASSERT(pEvent->getAssignments().size() == 1);
1043  // check the event assignment
1044  std::string key = pEvent->getAssignments()[0]->getTargetKey();
1045  CPPUNIT_ASSERT(key == pA->getKey());
1046  pExpr = pEvent->getAssignments()[0]->getExpressionPtr();
1047  CPPUNIT_ASSERT(pExpr != NULL);
1048  pNode = pExpr->getRoot();
1049  CPPUNIT_ASSERT(pNode != NULL);
1050  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
1051  pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
1052  CPPUNIT_ASSERT(pObjectNode != NULL);
1053  objectCN = pObjectNode->getObjectCN();
1054  CPPUNIT_ASSERT(!objectCN.empty());
1055  pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
1056  CPPUNIT_ASSERT(pObject != NULL);
1057  CPPUNIT_ASSERT(pObject->isReference() == true);
1058  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Value"));
1059  CPPUNIT_ASSERT(pObject->getObjectParent() == pModelValue);
1060 }
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 Type subType(const Type &type)
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000082.h:80
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50
CCopasiNode< Data > * getChild()
Definition: CCopasiNode.h:210
static const char * MODEL_STRING8
Definition: test000082.h:69
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
CEvaluationNode * getRoot()
CCopasiContainer * getObjectParent() const

Member Data Documentation

const char * test000082::MODEL_STRING1
staticprotected

Definition at line 53 of file test000082.h.

Referenced by test_import_delayAssignment_1().

const char * test000082::MODEL_STRING101
staticprotected

Definition at line 74 of file test000082.h.

Referenced by test_export_delayAssignment_1(), and test_export_delayAssignment_2().

const char * test000082::MODEL_STRING102
staticprotected

Definition at line 76 of file test000082.h.

Referenced by test_export_delayAssignment_3(), and test_export_delayAssignment_4().

const char * test000082::MODEL_STRING103
staticprotected

Definition at line 78 of file test000082.h.

Referenced by test_export_delayAssignment_5(), and test_export_delayAssignment_6().

const char * test000082::MODEL_STRING2
staticprotected

Definition at line 56 of file test000082.h.

Referenced by test_import_delayAssignment_2().

const char * test000082::MODEL_STRING3
staticprotected

Definition at line 59 of file test000082.h.

Referenced by test_import_delayAssignment_3().

const char * test000082::MODEL_STRING4
staticprotected

Definition at line 61 of file test000082.h.

Referenced by test_import_delayAssignment_4().

const char * test000082::MODEL_STRING5
staticprotected

Definition at line 63 of file test000082.h.

Referenced by test_import_delayAssignment_5().

const char * test000082::MODEL_STRING6
staticprotected

Definition at line 65 of file test000082.h.

Referenced by test_import_delayAssignment_6().

const char * test000082::MODEL_STRING7
staticprotected

Definition at line 67 of file test000082.h.

Referenced by test_import_delayAssignment_7().

const char * test000082::MODEL_STRING8
staticprotected

Definition at line 69 of file test000082.h.

Referenced by test_import_delayAssignment_8().

CCopasiDataModel * test000082::pCOPASIDATAMODEL = NULL
staticprotected

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