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

#include <test000051.h>

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

Public Member Functions

void setUp ()
 
void tearDown ()
 
void test_bug988 ()
 

Static Protected Attributes

static const char * MODEL_STRING
 
static CCopasiDataModelpCOPASIDATAMODEL = NULL
 

Private Member Functions

 CPPUNIT_TEST (test_bug988)
 
 CPPUNIT_TEST_SUITE (test000051)
 
 CPPUNIT_TEST_SUITE_END ()
 

Detailed Description

Definition at line 24 of file test000051.h.

Member Function Documentation

test000051::CPPUNIT_TEST ( test_bug988  )
private
test000051::CPPUNIT_TEST_SUITE ( test000051  )
private
test000051::CPPUNIT_TEST_SUITE_END ( )
private
void test000051::setUp ( )

Definition at line 36 of file test000051.cpp.

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

37 {
38  // Create the root container.
39  CCopasiRootContainer::init(0, NULL, false);
40  // Create the global data model.
42 }
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000051.h:32
static CCopasiDataModel * addDatamodel()
static void init(int argc, char *argv[], const bool &withGui=false)
void test000051::tearDown ( )

Definition at line 44 of file test000051.cpp.

References CCopasiRootContainer::destroy().

void test000051::test_bug988 ( )

Definition at line 49 of file test000051.cpp.

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

50 {
51  // load the CPS file
52  // export to SBML
53  // check the resulting SBML model
54  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
55  std::istringstream iss(test000051::MODEL_STRING);
56  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
57  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
58  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 3).empty() == false);
59  SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
60  CPPUNIT_ASSERT(pDocument != NULL);
61  Model* pModel = pDocument->getModel();
62  CPPUNIT_ASSERT(pModel != NULL);
63  // assert that there is only one compartment and
64  // assert the compartment is constant
65  CPPUNIT_ASSERT(pModel->getNumCompartments() == 1);
66  Compartment* pCompartment = pModel->getCompartment(0);
67  CPPUNIT_ASSERT(pCompartment->getConstant() == true);
68  CPPUNIT_ASSERT(pModel->getNumParameters() == 0);
69  CPPUNIT_ASSERT(pModel->getNumSpecies() == 1);
70  const Species* pSpecies = pModel->getSpecies(0);
71  std::string idSpeciesA = pSpecies->getId();
72  CPPUNIT_ASSERT(pSpecies->getHasOnlySubstanceUnits() == false);
73  CPPUNIT_ASSERT(pModel->getNumRules() == 1);
74  AssignmentRule* pRule = dynamic_cast<AssignmentRule*>(pModel->getRule(0));
75  CPPUNIT_ASSERT(pRule != NULL);
76  CPPUNIT_ASSERT(pRule->getVariable() == idSpeciesA);
77  const ASTNode* pMath = pRule->getMath();
78  CPPUNIT_ASSERT(pMath != NULL);
79  // make sure the mathematical expression contains a piecewise
80  // function definition
81  CPPUNIT_ASSERT(pMath->getType() == AST_FUNCTION_PIECEWISE);
82  CPPUNIT_ASSERT(pMath->getNumChildren() == 3);
83  CPPUNIT_ASSERT(pMath->getChild(0) != NULL);
84  CPPUNIT_ASSERT(pMath->getChild(0)->getType() == AST_REAL);
85  CPPUNIT_ASSERT(pMath->getChild(0)->getReal() < 1e-6);
86  CPPUNIT_ASSERT(pMath->getChild(2) != NULL);
87  CPPUNIT_ASSERT(pMath->getChild(2)->getType() == AST_REAL);
88  CPPUNIT_ASSERT(fabs((pMath->getChild(2)->getReal() - 10.0) / 10.0) < 1e-3);
89  pMath = pMath->getChild(1);
90  CPPUNIT_ASSERT(pMath != NULL);
91  CPPUNIT_ASSERT(pMath->getType() == AST_RELATIONAL_LT);
92  CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
93  CPPUNIT_ASSERT(pMath->getChild(0) != NULL);
94  CPPUNIT_ASSERT(pMath->getChild(0)->getType() == AST_NAME_TIME);
95  CPPUNIT_ASSERT(pMath->getChild(1) != NULL);
96  CPPUNIT_ASSERT(pMath->getChild(1)->getType() == AST_REAL);
97  CPPUNIT_ASSERT(fabs((pMath->getChild(1)->getReal() - 5.0) / 5.0) < 1e-3);
98  CPPUNIT_ASSERT(pModel->getNumReactions() == 0);
99 }
SBMLDocument * getCurrentSBMLDocument()
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static const char * MODEL_STRING
Definition: test000051.h:31
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000051.h:32

Member Data Documentation

const char * test000051::MODEL_STRING
staticprotected

Definition at line 31 of file test000051.h.

Referenced by test_bug988().

CCopasiDataModel * test000051::pCOPASIDATAMODEL = NULL
staticprotected

Definition at line 32 of file test000051.h.

Referenced by setUp(), and test_bug988().


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