COPASI API  4.16.103
test000061.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/sbml/unittests/test000061.cpp,v $
3 // $Revision: 1.6 $
4 // $Name: $
5 // $Author: gauges $
6 // $Date: 2010/03/11 11:52:00 $
7 // End CVS Header
8 
9 // Copyright (C) 2010 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., University of Heidelberg, and The University
11 // of Manchester.
12 // All rights reserved.
13 
14 // Copyright (C) 2008 by Pedro Mendes, Virginia Tech Intellectual
15 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
16 // and The University of Manchester.
17 // All rights reserved.
18 
19 #include "test000061.h"
20 
21 #include <sstream>
22 #include "utilities.hpp"
24 #include "copasi/model/CModel.h"
28 
29 #include "sbml/SBMLDocument.h"
30 #include "sbml/Model.h"
31 #include "sbml/Species.h"
32 
34 
35 CCopasiDataModel* test000061::pCOPASIDATAMODEL = NULL;
36 
38 {
39  // Create the root container.
40  CCopasiRootContainer::init(0, NULL, false);
41  // Create the global data model.
43 }
44 
46 {
48 }
49 
51 {
52  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
53  std::istringstream iss(test000061::MODEL_STRING1);
54  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
55  CModel* pModel = pDataModel->getModel();
56  CPPUNIT_ASSERT(pModel != NULL);
57  // check if the model has been loaded correctly
58  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
59  const CModelValue* pModelValue = pModel->getModelValues()[0];
60  CPPUNIT_ASSERT(pModelValue != NULL);
61  CPPUNIT_ASSERT(pModelValue->getObjectName() == "A");
62  CPPUNIT_ASSERT(pModelValue->getStatus() == CModelEntity::ASSIGNMENT);
63  CPPUNIT_ASSERT(pModelValue->getExpressionPtr() != NULL);
64  const CEvaluationNode* pRoot = pModelValue->getExpressionPtr()->getRoot();
65  CPPUNIT_ASSERT(pRoot != NULL);
66  CPPUNIT_ASSERT(CEvaluationNode::type(pRoot->getType()) == CEvaluationNode::INVALID);
67  const SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
68  CPPUNIT_ASSERT(pDocument == NULL);
69  // export the model to SBML
70  bool exception = false;
71 
72  try
73  {
74  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 1).empty() == true);
75  }
76  catch (...)
77  {
78  exception = true;
79  }
80 
81  CPPUNIT_ASSERT(exception == true);
82  CPPUNIT_ASSERT(pDataModel->getCurrentSBMLDocument() == NULL);
83  // check if the correct error message has been created.
85  CPPUNIT_ASSERT(message.getNumber() == MCSBML + 70);
86  CPPUNIT_ASSERT(message.getType() == CCopasiMessage::EXCEPTION);
87  CPPUNIT_ASSERT(CCopasiMessage::size() == 0);
88 }
89 
90 const char* test000061::MODEL_STRING1 =
91  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
92  "<!-- generated with COPASI 4.4.26 (Debug) (http://www.copasi.org) at 2008-06-09 07:46:05 UTC -->"
93  "<COPASI xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://www.copasi.org/static/schema.xsd\" versionMajor=\"1\" versionMinor=\"0\" versionDevel=\"26\">"
94  " <Model key=\"Model_0\" name=\"Bug 1044\" timeUnit=\"s\" volumeUnit=\"ml\" quantityUnit=\"mmol\" type=\"deterministic\">"
95  " <Comment>"
96  " <body xmlns=\"http://www.w3.org/1999/xhtml\">"
97  " "
98  " </body>"
99  " </Comment>"
100  " <ListOfModelValues>"
101  " <ModelValue key=\"ModelValue_0\" name=\"A\" simulationType=\"assignment\">"
102  " </ModelValue>"
103  " </ListOfModelValues>"
104  " <StateTemplate>"
105  " <StateTemplateVariable objectReference=\"Model_0\"/>"
106  " <StateTemplateVariable objectReference=\"ModelValue_0\"/>"
107  " </StateTemplate>"
108  " <InitialState type=\"initialState\">"
109  " 0 0"
110  " </InitialState>"
111  " </Model>"
112  "</COPASI>"
113  ;
Header file of class CExpression.
SBMLDocument * getCurrentSBMLDocument()
Header file of class CModelEntity and CModelValue.
static const char * MODEL_STRING1
Definition: test000061.h:38
const CCopasiVectorN< CModelValue > & getModelValues() const
Definition: CModel.cpp:1060
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
virtual size_t size() const
void setUp()
Definition: test000061.cpp:37
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
static Type type(const Type &type)
void tearDown()
Definition: test000061.cpp:45
#define MCSBML
void test_bug_1044()
Definition: test000061.cpp:50
static size_t size()
static CCopasiDataModel * addDatamodel()
static CCopasiMessage getLastMessage()
static void init(int argc, char *argv[], const bool &withGui=false)
Definition: CModel.h:50
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000061.h:39