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

#include <test000071.h>

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

Public Member Functions

void setUp ()
 
void tearDown ()
 
void test_bug1085 ()
 

Static Protected Attributes

static const char * MODEL_STRING1
 
static CCopasiDataModelpCOPASIDATAMODEL = NULL
 

Private Member Functions

 CPPUNIT_TEST (test_bug1085)
 
 CPPUNIT_TEST_SUITE (test000071)
 
 CPPUNIT_TEST_SUITE_END ()
 

Detailed Description

Definition at line 26 of file test000071.h.

Member Function Documentation

test000071::CPPUNIT_TEST ( test_bug1085  )
private
test000071::CPPUNIT_TEST_SUITE ( test000071  )
private
test000071::CPPUNIT_TEST_SUITE_END ( )
private
void test000071::setUp ( )

Definition at line 44 of file test000071.cpp.

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

45 {
46  // Create the root container.
47  CCopasiRootContainer::init(0, NULL, false);
48  // Create the global data model.
50 }
static CCopasiDataModel * addDatamodel()
static void init(int argc, char *argv[], const bool &withGui=false)
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000071.h:34
void test000071::tearDown ( )

Definition at line 52 of file test000071.cpp.

References CCopasiRootContainer::destroy().

void test000071::test_bug1085 ( )

Definition at line 57 of file test000071.cpp.

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

58 {
59  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
60  std::istringstream iss(test000071::MODEL_STRING1);
61  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
62  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
63  const SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
64  CPPUNIT_ASSERT(pDocument == NULL);
65  CModel* pModel = pDataModel->getModel();
66  CPPUNIT_ASSERT(pModel != NULL);
67  std::string sbmlString = pDataModel->exportSBMLToString(NULL, 2, 1);
68  CPPUNIT_ASSERT(!sbmlString.empty());
69  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(sbmlString));
70  pDocument = pDataModel->getCurrentSBMLDocument();
71  CPPUNIT_ASSERT(pDocument != NULL);
72  const Model* pSBMLModel = pDocument->getModel();
73  CPPUNIT_ASSERT(pSBMLModel != NULL);
74  // check if there is one function defintition
75  CPPUNIT_ASSERT(pSBMLModel->getListOfFunctionDefinitions()->size() == 1);
76  const FunctionDefinition* pFunDef = pSBMLModel->getFunctionDefinition(0);
77  CPPUNIT_ASSERT(pFunDef != NULL);
78  CPPUNIT_ASSERT(pFunDef->getName() == "sqrt_call");
79  const ASTNode* pMath = pFunDef->getMath();
80  CPPUNIT_ASSERT(pMath != NULL);
81  // the last child should be the actual function expression
82  pMath = pMath->getChild(pMath->getNumChildren() - 1);
83  CPPUNIT_ASSERT(pMath != NULL);
84  // check that the root node is a root function call
85  CPPUNIT_ASSERT(pMath->getType() == AST_FUNCTION_ROOT);
86  // the root function can have either one or two arguments
87  // if there are two arguments the first one is the degree and needs to be 2
88  // since we have a sqrt call
89  CPPUNIT_ASSERT(pMath->getNumChildren() == 1 || pMath->getNumChildren() == 2);
90 
91  if (pMath->getNumChildren() == 2)
92  {
93  CPPUNIT_ASSERT(pMath->getChild(0) != NULL);
94  CPPUNIT_ASSERT(pMath->getChild(0)->getType() == AST_INTEGER);
95  CPPUNIT_ASSERT(pMath->getChild(0)->getInteger() == 2);
96  pMath = pMath->getChild(1);
97  CPPUNIT_ASSERT(pMath != NULL);
98  CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
99  CPPUNIT_ASSERT(pMath->getName() == std::string("k"));
100  }
101  else if (pMath->getNumChildren() == 1)
102  {
103  pMath = pMath->getChild(0);
104  CPPUNIT_ASSERT(pMath != NULL);
105  CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
106  CPPUNIT_ASSERT(pMath->getName() == std::string("k"));
107  }
108 }
SBMLDocument * getCurrentSBMLDocument()
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
static const char * MODEL_STRING1
Definition: test000071.h:33
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000071.h:34

Member Data Documentation

const char * test000071::MODEL_STRING1
staticprotected

Definition at line 33 of file test000071.h.

Referenced by test_bug1085().

CCopasiDataModel * test000071::pCOPASIDATAMODEL = NULL
staticprotected

This test checks if the workaround for bug 1085 works. Or once libSBML has been fixed, it checks that the bug no longer occurs.

Definition at line 34 of file test000071.h.

Referenced by setUp(), and test_bug1085().


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