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

#include <test000054.h>

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

Public Member Functions

void setUp ()
 
void tearDown ()
 
void test_bug1002 ()
 

Static Protected Attributes

static const char * MODEL_STRING
 
static CCopasiDataModelpCOPASIDATAMODEL = NULL
 

Private Member Functions

 CPPUNIT_TEST (test_bug1002)
 
 CPPUNIT_TEST_SUITE (test000054)
 
 CPPUNIT_TEST_SUITE_END ()
 

Detailed Description

Definition at line 24 of file test000054.h.

Member Function Documentation

test000054::CPPUNIT_TEST ( test_bug1002  )
private
test000054::CPPUNIT_TEST_SUITE ( test000054  )
private
test000054::CPPUNIT_TEST_SUITE_END ( )
private
void test000054::setUp ( )

Definition at line 36 of file test000054.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: test000054.h:32
static CCopasiDataModel * addDatamodel()
static void init(int argc, char *argv[], const bool &withGui=false)
void test000054::tearDown ( )

Definition at line 44 of file test000054.cpp.

References CCopasiRootContainer::destroy().

void test000054::test_bug1002 ( )

Definition at line 49 of file test000054.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(test000054::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* pSBMLModel = pDocument->getModel();
62  CPPUNIT_ASSERT(pSBMLModel != NULL);
63  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 0);
64  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 0);
65  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 0);
66  CPPUNIT_ASSERT(pSBMLModel->getNumInitialAssignments() == 0);
67  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 5);
68  const Parameter* pParameter1 = pSBMLModel->getParameter(0);
69  CPPUNIT_ASSERT(pParameter1 != NULL);
70  CPPUNIT_ASSERT(pParameter1->getConstant() == false);
71  const Parameter* pParameter2 = pSBMLModel->getParameter(1);
72  CPPUNIT_ASSERT(pParameter2 != NULL);
73  CPPUNIT_ASSERT(pParameter2->getConstant() == false);
74  const Parameter* pParameter3 = pSBMLModel->getParameter(2);
75  CPPUNIT_ASSERT(pParameter3 != NULL);
76  CPPUNIT_ASSERT(pParameter3->getConstant() == false);
77  const Parameter* pParameter4 = pSBMLModel->getParameter(3);
78  CPPUNIT_ASSERT(pParameter4 != NULL);
79  CPPUNIT_ASSERT(pParameter4->getConstant() == false);
80  const Parameter* pParameter5 = pSBMLModel->getParameter(4);
81  CPPUNIT_ASSERT(pParameter5 != NULL);
82  CPPUNIT_ASSERT(pParameter5->getConstant() == false);
83  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 5);
84 
85  const Rule* pRule = pSBMLModel->getRule(0);
86  CPPUNIT_ASSERT(pRule != NULL);
87  CPPUNIT_ASSERT(pRule->getTypeCode() == SBML_ASSIGNMENT_RULE);
88  const AssignmentRule* pARule = dynamic_cast<const AssignmentRule*>(pRule);
89  CPPUNIT_ASSERT(pARule != NULL);
90  CPPUNIT_ASSERT(pARule->getVariable() == pParameter4->getId());
91  CPPUNIT_ASSERT(pARule->isSetMath() == true);
92  const ASTNode* pMath = pARule->getMath();
93  CPPUNIT_ASSERT(pMath != NULL);
94  CPPUNIT_ASSERT(pMath->getType() == AST_PLUS);
95  CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
96  const ASTNode* pChild1 = pMath->getChild(0);
97  CPPUNIT_ASSERT(pChild1 != NULL);
98  CPPUNIT_ASSERT(pChild1->getType() == AST_REAL);
99  CPPUNIT_ASSERT(fabs((pChild1->getReal() - 2.0) / 2.0) < 1e-15);
100  const ASTNode* pChild2 = pMath->getChild(1);
101  CPPUNIT_ASSERT(pChild2 != NULL);
102  CPPUNIT_ASSERT(pChild2->getType() == AST_REAL);
103  CPPUNIT_ASSERT(fabs((pChild2->getReal() - 4.0) / 4.0) < 1e-15);
104 
105  pRule = pSBMLModel->getRule(1);
106  CPPUNIT_ASSERT(pRule != NULL);
107  CPPUNIT_ASSERT(pRule->getTypeCode() == SBML_ASSIGNMENT_RULE);
108  pARule = dynamic_cast<const AssignmentRule*>(pRule);
109  CPPUNIT_ASSERT(pARule != NULL);
110  CPPUNIT_ASSERT(pARule->getVariable() == pParameter1->getId());
111  CPPUNIT_ASSERT(pARule->isSetMath() == true);
112  pMath = pARule->getMath();
113  CPPUNIT_ASSERT(pMath != NULL);
114  CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
115  CPPUNIT_ASSERT(pMath->getName() == pParameter4->getId());
116  CPPUNIT_ASSERT(pMath->getNumChildren() == 0);
117 
118  pRule = pSBMLModel->getRule(2);
119  CPPUNIT_ASSERT(pRule != NULL);
120  CPPUNIT_ASSERT(pRule->getTypeCode() == SBML_ASSIGNMENT_RULE);
121  pARule = dynamic_cast<const AssignmentRule*>(pRule);
122  CPPUNIT_ASSERT(pARule != NULL);
123  CPPUNIT_ASSERT(pARule->getVariable() == pParameter3->getId());
124  CPPUNIT_ASSERT(pARule->isSetMath() == true);
125  pMath = pARule->getMath();
126  CPPUNIT_ASSERT(pMath != NULL);
127  CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
128  CPPUNIT_ASSERT(pMath->getName() == pParameter1->getId());
129  CPPUNIT_ASSERT(pMath->getNumChildren() == 0);
130 
131  pRule = pSBMLModel->getRule(3);
132  CPPUNIT_ASSERT(pRule != NULL);
133  CPPUNIT_ASSERT(pRule->getTypeCode() == SBML_ASSIGNMENT_RULE);
134  pARule = dynamic_cast<const AssignmentRule*>(pRule);
135  CPPUNIT_ASSERT(pARule != NULL);
136  CPPUNIT_ASSERT(pARule->getVariable() == pParameter5->getId());
137  CPPUNIT_ASSERT(pARule->isSetMath() == true);
138  pMath = pARule->getMath();
139  CPPUNIT_ASSERT(pMath != NULL);
140  CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
141  CPPUNIT_ASSERT(pMath->getName() == pParameter3->getId());
142  CPPUNIT_ASSERT(pMath->getNumChildren() == 0);
143 
144  pRule = pSBMLModel->getRule(4);
145  CPPUNIT_ASSERT(pRule != NULL);
146  CPPUNIT_ASSERT(pRule->getTypeCode() == SBML_ASSIGNMENT_RULE);
147  pARule = dynamic_cast<const AssignmentRule*>(pRule);
148  CPPUNIT_ASSERT(pARule != NULL);
149  CPPUNIT_ASSERT(pARule->getVariable() == pParameter2->getId());
150  CPPUNIT_ASSERT(pARule->isSetMath() == true);
151  pMath = pARule->getMath();
152  CPPUNIT_ASSERT(pMath != NULL);
153  CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
154  CPPUNIT_ASSERT(pMath->getName() == pParameter5->getId());
155  CPPUNIT_ASSERT(pMath->getNumChildren() == 0);
156 }
SBMLDocument * getCurrentSBMLDocument()
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000054.h:32
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
static const char * MODEL_STRING
Definition: test000054.h:31

Member Data Documentation

const char * test000054::MODEL_STRING
staticprotected

Definition at line 31 of file test000054.h.

Referenced by test_bug1002().

CCopasiDataModel * test000054::pCOPASIDATAMODEL = NULL
staticprotected

Definition at line 32 of file test000054.h.

Referenced by setUp(), and test_bug1002().


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