COPASI API  4.16.103
Public Member Functions | Private Member Functions | List of all members
test_depth_first_iterator Class Reference

#include <test_depth_first_iterator.h>

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

Public Member Functions

void setUp ()
 
void tearDown ()
 
void test_dfi ()
 

Private Member Functions

 CPPUNIT_TEST (test_dfi)
 
 CPPUNIT_TEST_SUITE (test_depth_first_iterator)
 
 CPPUNIT_TEST_SUITE_END ()
 

Detailed Description

Definition at line 25 of file test_depth_first_iterator.h.

Member Function Documentation

test_depth_first_iterator::CPPUNIT_TEST ( test_dfi  )
private
test_depth_first_iterator::CPPUNIT_TEST_SUITE ( test_depth_first_iterator  )
private
test_depth_first_iterator::CPPUNIT_TEST_SUITE_END ( )
private
void test_depth_first_iterator::setUp ( )

Definition at line 28 of file test_depth_first_iterator.cpp.

References CCopasiRootContainer::init().

29 {
30  CCopasiRootContainer::init(false, 0, NULL);
31 }
static void init(int argc, char *argv[], const bool &withGui=false)
void test_depth_first_iterator::tearDown ( )

Definition at line 33 of file test_depth_first_iterator.cpp.

References CCopasiRootContainer::destroy().

void test_depth_first_iterator::test_dfi ( )

Definition at line 38 of file test_depth_first_iterator.cpp.

References CEvaluationTree::getInfix(), CEvaluationTree::getRoot(), CEvaluationNode::getType(), CEvaluationNode::getValue(), min, CEvaluationNodeOperator::MINUS, CEvaluationNodeOperator::MULTIPLY, CEvaluationNode::NUMBER, CEvaluationNode::OPERATOR, CEvaluationNodeOperator::PLUS, CEvaluationTree::setInfix(), CEvaluationNode::subType(), and CEvaluationNode::type().

39 {
40  std::string infix("7-(3+(4-6))+1*8");
41  CEvaluationTree* pTree = new CEvaluationTree();
42  pTree->setInfix(infix);
43  std::string s = pTree->getInfix();
44  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
46  CPPUNIT_ASSERT(it.isValid());
47  CEvaluationNode* pNode = NULL;
48  CEvaluationNodeNumber* pNumberNode = NULL;
49  CEvaluationNodeOperator* pOperatorNode = NULL;
50  // 7
51  pNode = *it;
52  CPPUNIT_ASSERT(pNode != NULL);
53  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::NUMBER);
54  pNumberNode = dynamic_cast<CEvaluationNodeNumber*>(pNode);
55  CPPUNIT_ASSERT(pNumberNode != NULL);
56  CPPUNIT_ASSERT((fabs(pNumberNode->getValue() - 7) / 7.0) <= std::numeric_limits<double>::min());
57  // 3
58  ++it;
59  CPPUNIT_ASSERT(it.isValid() == true);
60  pNode = *it;
61  CPPUNIT_ASSERT(pNode != NULL);
62  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::NUMBER);
63  pNumberNode = dynamic_cast<CEvaluationNodeNumber*>(pNode);
64  CPPUNIT_ASSERT(pNumberNode != NULL);
65  CPPUNIT_ASSERT((fabs(pNumberNode->getValue() - 3) / 3.0) <= std::numeric_limits<double>::min());
66  // 4
67  ++it;
68  CPPUNIT_ASSERT(it.isValid() == true);
69  pNode = *it;
70  CPPUNIT_ASSERT(pNode != NULL);
71  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::NUMBER);
72  pNumberNode = dynamic_cast<CEvaluationNodeNumber*>(pNode);
73  CPPUNIT_ASSERT(pNumberNode != NULL);
74  CPPUNIT_ASSERT((fabs(pNumberNode->getValue() - 4) / 4.0) <= std::numeric_limits<double>::min());
75  // 6
76  ++it;
77  CPPUNIT_ASSERT(it.isValid() == true);
78  pNode = *it;
79  CPPUNIT_ASSERT(pNode != NULL);
80  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::NUMBER);
81  pNumberNode = dynamic_cast<CEvaluationNodeNumber*>(pNode);
82  CPPUNIT_ASSERT(pNumberNode != NULL);
83  CPPUNIT_ASSERT((fabs(pNumberNode->getValue() - 6) / 6.0) <= std::numeric_limits<double>::min());
84  // -
85  ++it;
86  CPPUNIT_ASSERT(it.isValid() == true);
87  pNode = *it;
88  CPPUNIT_ASSERT(pNode != NULL);
89  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OPERATOR);
90  pOperatorNode = dynamic_cast<CEvaluationNodeOperator*>(pNode);
91  CPPUNIT_ASSERT(pOperatorNode != NULL);
93  // +
94  ++it;
95  CPPUNIT_ASSERT(it.isValid() == true);
96  pNode = *it;
97  CPPUNIT_ASSERT(pNode != NULL);
98  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OPERATOR);
99  pOperatorNode = dynamic_cast<CEvaluationNodeOperator*>(pNode);
100  CPPUNIT_ASSERT(pOperatorNode != NULL);
102  // -
103  ++it;
104  CPPUNIT_ASSERT(it.isValid() == true);
105  pNode = *it;
106  CPPUNIT_ASSERT(pNode != NULL);
107  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OPERATOR);
108  pOperatorNode = dynamic_cast<CEvaluationNodeOperator*>(pNode);
109  CPPUNIT_ASSERT(pOperatorNode != NULL);
111  // 1
112  ++it;
113  CPPUNIT_ASSERT(it.isValid() == true);
114  pNode = *it;
115  CPPUNIT_ASSERT(pNode != NULL);
116  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::NUMBER);
117  pNumberNode = dynamic_cast<CEvaluationNodeNumber*>(pNode);
118  CPPUNIT_ASSERT(pNumberNode != NULL);
119  CPPUNIT_ASSERT((fabs(pNumberNode->getValue() - 1) / 1.0) <= std::numeric_limits<double>::min());
120  // 8
121  ++it;
122  CPPUNIT_ASSERT(it.isValid() == true);
123  pNode = *it;
124  CPPUNIT_ASSERT(pNode != NULL);
125  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::NUMBER);
126  pNumberNode = dynamic_cast<CEvaluationNodeNumber*>(pNode);
127  CPPUNIT_ASSERT(pNumberNode != NULL);
128  CPPUNIT_ASSERT((fabs(pNumberNode->getValue() - 8) / 8.0) <= std::numeric_limits<double>::min());
129  // *
130  ++it;
131  CPPUNIT_ASSERT(it.isValid() == true);
132  pNode = *it;
133  CPPUNIT_ASSERT(pNode != NULL);
134  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OPERATOR);
135  pOperatorNode = dynamic_cast<CEvaluationNodeOperator*>(pNode);
136  CPPUNIT_ASSERT(pOperatorNode != NULL);
138  // +
139  ++it;
140  CPPUNIT_ASSERT(it.isValid() == true);
141  pNode = *it;
142  CPPUNIT_ASSERT(pNode != NULL);
143  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OPERATOR);
144  pOperatorNode = dynamic_cast<CEvaluationNodeOperator*>(pNode);
145  CPPUNIT_ASSERT(pOperatorNode != NULL);
147 
148  ++it;
149  CPPUNIT_ASSERT(it.isValid() == false);
150  CPPUNIT_ASSERT(*it == NULL);
151 
152  delete pTree;
153 }
const C_FLOAT64 & getValue() const
const Type & getType() const
static Type type(const Type &type)
static Type subType(const Type &type)
#define min(a, b)
Definition: f2c.h:175
CEvaluationNode * getRoot()
const std::string & getInfix() const
virtual bool setInfix(const std::string &infix)

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