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

#include <test000098.h>

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

Public Member Functions

void setUp ()
 
void tearDown ()
 
void test_export_notes ()
 
void test_import_notes ()
 

Protected Attributes

CCopasiDataModelpDataModel
 

Static Protected Attributes

static const char * CPS_MODEL_1
 
static const char * SBML_MODEL_1
 

Private Member Functions

 CPPUNIT_TEST (test_import_notes)
 
 CPPUNIT_TEST (test_export_notes)
 
 CPPUNIT_TEST_SUITE (test000098)
 
 CPPUNIT_TEST_SUITE_END ()
 

Detailed Description

Definition at line 28 of file test000098.h.

Member Function Documentation

test000098::CPPUNIT_TEST ( test_import_notes  )
private
test000098::CPPUNIT_TEST ( test_export_notes  )
private
test000098::CPPUNIT_TEST_SUITE ( test000098  )
private
test000098::CPPUNIT_TEST_SUITE_END ( )
private
void test000098::setUp ( )

Definition at line 33 of file test000098.cpp.

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

34 {
35  // Create the root container.
36  CCopasiRootContainer::init(0, NULL, false);
38 }
static CCopasiDataModel * addDatamodel()
static void init(int argc, char *argv[], const bool &withGui=false)
CCopasiDataModel * pDataModel
Definition: test000098.h:41
void test000098::tearDown ( )

Definition at line 40 of file test000098.cpp.

References CCopasiRootContainer::destroy().

void test000098::test_export_notes ( )

Definition at line 96 of file test000098.cpp.

References CPS_MODEL_1, CCopasiDataModel::exportSBMLToString(), load_cps_model_from_stream(), and pDataModel.

97 {
98  CPPUNIT_ASSERT(pDataModel != NULL);
99  std::istringstream iss(test000098::CPS_MODEL_1);
100  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
101  std::string s;
102 
103  try
104  {
105  s = pDataModel->exportSBMLToString(NULL, 2, 1);
106  }
107  catch (...)
108  {
109  CPPUNIT_ASSERT(false);
110  }
111 
112  CPPUNIT_ASSERT(!s.empty());
113  SBMLReader reader;
114  SBMLDocument* pSBMLDocument = NULL;
115 
116  try
117  {
118  pSBMLDocument = reader.readSBMLFromString(s);
119  }
120  catch (...)
121  {
122  CPPUNIT_ASSERT(false);
123  }
124 
125  CPPUNIT_ASSERT(pSBMLDocument != NULL);
126  Model* pModel = pSBMLDocument->getModel();
127  CPPUNIT_ASSERT(pModel != NULL);
128  CPPUNIT_ASSERT(pModel->isSetNotes() == true);
129  std::string notes = pModel->getNotesString();
130  CPPUNIT_ASSERT(!notes.empty());
131  CPPUNIT_ASSERT(notes.find("Simple note on model") != std::string::npos);
132 
133  CPPUNIT_ASSERT(pModel->getNumCompartments() == 1);
134  CPPUNIT_ASSERT(pModel->getNumSpecies() == 1);
135  CPPUNIT_ASSERT(pModel->getNumParameters() == 1);
136  CPPUNIT_ASSERT(pModel->getNumReactions() == 1);
137  CPPUNIT_ASSERT(pModel->getNumEvents() == 1);
138  // compartment
139  SBase* pObject = pModel->getCompartment(0);
140  CPPUNIT_ASSERT(pObject != NULL);
141  CPPUNIT_ASSERT(pObject->isSetNotes() == true);
142  notes = pObject->getNotesString();
143  CPPUNIT_ASSERT(!notes.empty());
144  CPPUNIT_ASSERT(notes.find("Simple note on compartment") != std::string::npos);
145  // species
146  pObject = pModel->getSpecies(0);
147  CPPUNIT_ASSERT(pObject != NULL);
148  CPPUNIT_ASSERT(pObject->isSetNotes() == true);
149  notes = pObject->getNotesString();
150  CPPUNIT_ASSERT(!notes.empty());
151  CPPUNIT_ASSERT(notes.find("Simple note on species") != std::string::npos);
152  // parameter
153  pObject = pModel->getParameter(0);
154  CPPUNIT_ASSERT(pObject != NULL);
155  CPPUNIT_ASSERT(pObject->isSetNotes() == true);
156  notes = pObject->getNotesString();
157  CPPUNIT_ASSERT(!notes.empty());
158  CPPUNIT_ASSERT(notes.find("Simple note on parameter") != std::string::npos);
159  // reaction
160  pObject = pModel->getReaction(0);
161  CPPUNIT_ASSERT(pObject != NULL);
162  CPPUNIT_ASSERT(pObject->isSetNotes() == true);
163  notes = pObject->getNotesString();
164  CPPUNIT_ASSERT(!notes.empty());
165  CPPUNIT_ASSERT(notes.find("Simple note on reaction") != std::string::npos);
166  // event
167  pObject = pModel->getEvent(0);
168  CPPUNIT_ASSERT(pObject != NULL);
169  CPPUNIT_ASSERT(pObject->isSetNotes() == true);
170  notes = pObject->getNotesString();
171  CPPUNIT_ASSERT(!notes.empty());
172  CPPUNIT_ASSERT(notes.find("Simple note on event") != std::string::npos);
173 
174 
175 }
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static const char * CPS_MODEL_1
Definition: test000098.h:39
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
CCopasiDataModel * pDataModel
Definition: test000098.h:41
void test000098::test_import_notes ( )

Definition at line 47 of file test000098.cpp.

References CCopasiDataModel::getModel(), CCopasiDataModel::importSBMLFromString(), pDataModel, and SBML_MODEL_1.

48 {
49  CPPUNIT_ASSERT(pDataModel != NULL);
50  // import the file and check if we find all the notes
52  // check if all the elements have notes
53  const CModel* pModel = pDataModel->getModel();
54  CPPUNIT_ASSERT(pModel != NULL);
55  std::string notes = pModel->getNotes();
56  CPPUNIT_ASSERT(!notes.empty());
57  CPPUNIT_ASSERT(notes.find("Simple note on model") != std::string::npos);
58  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
59  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 1);
60  CPPUNIT_ASSERT(pModel->getReactions().size() == 1);
61  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
62  CPPUNIT_ASSERT(pModel->getEvents().size() == 1);
63  // compartment
64  const CCompartment* pCompartment = pModel->getCompartments()[0];
65  CPPUNIT_ASSERT(pCompartment != NULL);
66  notes = pCompartment->getNotes();
67  CPPUNIT_ASSERT(!notes.empty());
68  CPPUNIT_ASSERT(notes.find("Simple note on compartment") != std::string::npos);
69  // species
70  const CMetab* pMetab = pModel->getMetabolites()[0];
71  CPPUNIT_ASSERT(pMetab != NULL);
72  notes = pMetab->getNotes();
73  CPPUNIT_ASSERT(!notes.empty());
74  CPPUNIT_ASSERT(notes.find("Simple note on species") != std::string::npos);
75  // reaction
76  const CReaction* pReaction = pModel->getReactions()[0];
77  CPPUNIT_ASSERT(pReaction != NULL);
78  notes = pReaction->getNotes();
79  CPPUNIT_ASSERT(!notes.empty());
80  CPPUNIT_ASSERT(notes.find("Simple note on reaction") != std::string::npos);
81  // parameter
82  const CModelValue* pModelValue = pModel->getModelValues()[0];
83  CPPUNIT_ASSERT(pModelValue != NULL);
84  notes = pModelValue->getNotes();
85  CPPUNIT_ASSERT(!notes.empty());
86  CPPUNIT_ASSERT(notes.find("Simple note on parameter") != std::string::npos);
87  // event
88  const CEvent* pEvent = pModel->getEvents()[0];
89  CPPUNIT_ASSERT(pEvent != NULL);
90  notes = pEvent->getNotes();
91  CPPUNIT_ASSERT(!notes.empty());
92  CPPUNIT_ASSERT(notes.find("Simple note on event") != std::string::npos);
93 }
Definition: CEvent.h:152
Definition: CMetab.h:178
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50
static const char * SBML_MODEL_1
Definition: test000098.h:37
CCopasiDataModel * pDataModel
Definition: test000098.h:41

Member Data Documentation

const char * test000098::CPS_MODEL_1
staticprotected

Definition at line 39 of file test000098.h.

Referenced by test_export_notes().

CCopasiDataModel* test000098::pDataModel
protected

Definition at line 41 of file test000098.h.

Referenced by setUp(), test_export_notes(), and test_import_notes().

const char * test000098::SBML_MODEL_1
staticprotected

Definition at line 37 of file test000098.h.

Referenced by test_import_notes().


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