COPASI API  4.16.103
test_normalform.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/compareExpressions/unittests/test_normalform.cpp,v $
3 // $Revision: 1.43 $
4 // $Name: $
5 // $Author: ssahle $
6 // $Date: 2012/04/22 14:51:18 $
7 // End CVS Header
8 
9 // Copyright (C) 2012 - 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 // Copyright (C) 2001 - 2007 by Pedro Mendes, Virginia Tech Intellectual
20 // Properties, Inc. and EML Research, gGmbH.
21 // All rights reserved.
22 
23 #include "test_normalform.hpp"
24 
25 #include <string>
26 #include <set>
27 #include <cmath>
28 
44 
45 #ifdef __SUNPRO_CC
46 typedef std::set<CNormalProduct*, compareProducts>::iterator ProductIterator;
47 typedef std::set<CNormalItemPower*, compareItemPowers>::iterator ItemPowerIterator;
48 #else
49 typedef std::set<CNormalProduct*, compareProducts>::const_iterator ProductIterator;
50 typedef std::set<CNormalItemPower*, compareItemPowers>::const_iterator ItemPowerIterator;
51 #endif // __SUNPRO_CC
52 
53 void test_normalform::setUp()
54 {
55  CCopasiRootContainer::init(false, 0, NULL);
56  pFraction = NULL;
57 }
58 
59 void test_normalform::tearDown()
60 {
61  if (pFraction != NULL) delete pFraction;
62 
64 }
65 
66 void test_normalform::test_item_number()
67 {
68  std::string infix("7.0");
69  CEvaluationTree* pTree = new CEvaluationTree();
70  pTree->setInfix(infix);
71  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
73  delete pTree;
74  CPPUNIT_ASSERT(pFraction != NULL);
75  CPPUNIT_ASSERT(pFraction->checkDenominatorOne() == true);
76 
77  const CNormalSum& numerator = pFraction->getNumerator();
78  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
79  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
80  CPPUNIT_ASSERT(products.size() == 1);
81  const CNormalProduct* pProduct = *(products.begin());
82  CPPUNIT_ASSERT(pProduct != NULL);
83  CPPUNIT_ASSERT(pProduct->getFactor() == 7.0);
84  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
85 }
86 
87 void test_normalform::test_item_variable()
88 {
89  std::string infix("Vmax");
90  CEvaluationTree* pTree = new CEvaluationTree();
91  pTree->setInfix(infix);
92  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
94  delete pTree;
95  CPPUNIT_ASSERT(pFraction != NULL);
96  CPPUNIT_ASSERT(pFraction->checkDenominatorOne() == true);
97 
98  const CNormalSum& numerator = pFraction->getNumerator();
99  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
100  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
101  CPPUNIT_ASSERT(products.size() == 1);
102  const CNormalProduct* pProduct = *(products.begin());
103  CPPUNIT_ASSERT(pProduct != NULL);
104  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
105  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
106  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
107  CPPUNIT_ASSERT(pItemPower != NULL);
108  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
109  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
110  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
111  CPPUNIT_ASSERT(pItem != NULL);
112  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
113  CPPUNIT_ASSERT(pItem->getName() == "Vmax");
114 }
115 
116 void test_normalform::test_item_constant()
117 {
118  std::string infix("PI");
119  CEvaluationTree* pTree = new CEvaluationTree();
120  pTree->setInfix(infix);
121  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
123  delete pTree;
124  CPPUNIT_ASSERT(pFraction != NULL);
125  CPPUNIT_ASSERT(pFraction->checkDenominatorOne() == true);
126 
127  const CNormalSum& numerator = pFraction->getNumerator();
128  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
129  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
130  CPPUNIT_ASSERT(products.size() == 1);
131  const CNormalProduct* pProduct = *(products.begin());
132  CPPUNIT_ASSERT(pProduct != NULL);
133  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
134  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
135  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
136  CPPUNIT_ASSERT(pItemPower != NULL);
137  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
138  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
139  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
140  CPPUNIT_ASSERT(pItem != NULL);
141  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::CONSTANT);
142  CPPUNIT_ASSERT(pItem->getName() == "PI");
143 }
144 
145 void test_normalform::test_item_function()
146 {
147  std::string infix("SIN(3.0)");
148  CEvaluationTree* pTree = new CEvaluationTree();
149  pTree->setInfix(infix);
150  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
152  delete pTree;
153  CPPUNIT_ASSERT(pFraction != NULL);
154  CPPUNIT_ASSERT(pFraction->checkDenominatorOne() == true);
155 
156  const CNormalSum& numerator = pFraction->getNumerator();
157  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
158  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
159  CPPUNIT_ASSERT(products.size() == 1);
160  const CNormalProduct* pProduct = *(products.begin());
161  CPPUNIT_ASSERT(pProduct != NULL);
162  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
163  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
164  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
165  CPPUNIT_ASSERT(pItemPower != NULL);
166  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
167  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::FUNCTION);
168  const CNormalFunction* pFunction = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
169  CPPUNIT_ASSERT(pFunction != NULL);
170  CPPUNIT_ASSERT(pFunction->getType() == CNormalFunction::SIN);
171 
172  const CNormalFraction* pFraction2 = &pFunction->getFraction();
173  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
174  const CNormalSum& numerator2 = pFraction2->getNumerator();
175  CPPUNIT_ASSERT(numerator2.getFractions().size() == 0);
176  const std::set<CNormalProduct*, compareProducts >& products2 = numerator2.getProducts();
177  CPPUNIT_ASSERT(products2.size() == 1);
178  pProduct = *(products2.begin());
179  CPPUNIT_ASSERT(pProduct != NULL);
180  CPPUNIT_ASSERT(pProduct->getFactor() == 3.0);
181  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
182 }
183 
184 void test_normalform::test_sum_numbers()
185 {
186  std::string infix("7.0+3.0");
187  CEvaluationTree* pTree = new CEvaluationTree();
188  pTree->setInfix(infix);
189  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
191  delete pTree;
192  CPPUNIT_ASSERT(pFraction != NULL);
193 
194  const CNormalSum& numerator = pFraction->getNumerator();
195  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
196  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
197  ProductIterator it = products.begin();
198  CPPUNIT_ASSERT(products.size() == 1);
199  const CNormalProduct* pProduct = *(it);
200  CPPUNIT_ASSERT(pProduct != NULL);
201  CPPUNIT_ASSERT(pProduct->getFactor() == 10.0);
202  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
203 }
204 
205 void test_normalform::test_sum_variables()
206 {
207  std::string infix("A+B");
208  CEvaluationTree* pTree = new CEvaluationTree();
209  pTree->setInfix(infix);
210  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
212  delete pTree;
213  CPPUNIT_ASSERT(pFraction != NULL);
214 
215  const CNormalSum& numerator = pFraction->getNumerator();
216  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
217  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
218  CPPUNIT_ASSERT(products.size() == 2);
219  ProductIterator it = products.begin();
220  const CNormalProduct* pProduct = *(it);
221  CPPUNIT_ASSERT(pProduct != NULL);
222  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
223  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
224  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
225  CPPUNIT_ASSERT(pItemPower != NULL);
226  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
227  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
228  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
229  CPPUNIT_ASSERT(pItem != NULL);
230  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
231  CPPUNIT_ASSERT(pItem->getName() == "A");
232  ++it;
233  pProduct = *(it);
234  CPPUNIT_ASSERT(pProduct != NULL);
235  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
236  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
237  pItemPower = *(pProduct->getItemPowers().begin());
238  CPPUNIT_ASSERT(pItemPower != NULL);
239  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
240  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
241  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
242  CPPUNIT_ASSERT(pItem != NULL);
243  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
244  CPPUNIT_ASSERT(pItem->getName() == "B");
245 }
246 
247 void test_normalform::test_sum_constants()
248 {
249  std::string infix("PI+EXPONENTIALE");
250  CEvaluationTree* pTree = new CEvaluationTree();
251  pTree->setInfix(infix);
252  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
254  delete pTree;
255  CPPUNIT_ASSERT(pFraction != NULL);
256 
257  const CNormalSum& numerator = pFraction->getNumerator();
258  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
259  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
260  CPPUNIT_ASSERT(products.size() == 2);
261  ProductIterator it = products.begin();
262  const CNormalProduct* pProduct = *(it);
263  CPPUNIT_ASSERT(pProduct != NULL);
264  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
265  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
266  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
267  CPPUNIT_ASSERT(pItemPower != NULL);
268  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
269  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
270  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
271  CPPUNIT_ASSERT(pItem != NULL);
272  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::CONSTANT);
273  CPPUNIT_ASSERT(pItem->getName() == "EXPONENTIALE");
274  ++it;
275  pProduct = *(it);
276  CPPUNIT_ASSERT(pProduct != NULL);
277  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
278  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
279  pItemPower = *(pProduct->getItemPowers().begin());
280  CPPUNIT_ASSERT(pItemPower != NULL);
281  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
282  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
283  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
284  CPPUNIT_ASSERT(pItem != NULL);
285  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::CONSTANT);
286  CPPUNIT_ASSERT(pItem->getName() == "PI");
287 }
288 
289 void test_normalform::test_sum_functions()
290 {
291  std::string infix("SIN(5.0)+COS(3.0)");
292  CEvaluationTree* pTree = new CEvaluationTree();
293  pTree->setInfix(infix);
294  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
296  delete pTree;
297  CPPUNIT_ASSERT(pFraction != NULL);
298 
299  const CNormalSum& numerator = pFraction->getNumerator();
300  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
301  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
302  CPPUNIT_ASSERT(products.size() == 2);
303  std::set<CNormalProduct*, compareProducts >::iterator it = products.begin();
304  const CNormalProduct* pProduct = *(it);
305  CPPUNIT_ASSERT(pProduct != NULL);
306  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
307  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
308  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
309  CPPUNIT_ASSERT(pItemPower != NULL);
310  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
311  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::FUNCTION);
312  const CNormalFunction* pFunction = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
313  CPPUNIT_ASSERT(pFunction != NULL);
314  CPPUNIT_ASSERT(pFunction->getType() == CNormalFunction::SIN);
315 
316  const CNormalFraction* pFraction2 = &pFunction->getFraction();
317  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
318  const CNormalSum& numerator2 = pFraction2->getNumerator();
319  CPPUNIT_ASSERT(numerator2.getFractions().size() == 0);
320  const std::set<CNormalProduct*, compareProducts >& products2 = numerator2.getProducts();
321  CPPUNIT_ASSERT(products2.size() == 1);
322  pProduct = *(products2.begin());
323  CPPUNIT_ASSERT(pProduct != NULL);
324  CPPUNIT_ASSERT(pProduct->getFactor() == 5.0);
325  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
326  ++it;
327  pProduct = *(it);
328  CPPUNIT_ASSERT(pProduct != NULL);
329  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
330  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
331  pItemPower = *(pProduct->getItemPowers().begin());
332  CPPUNIT_ASSERT(pItemPower != NULL);
333  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
334  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::FUNCTION);
335  pFunction = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
336  CPPUNIT_ASSERT(pFunction != NULL);
337  CPPUNIT_ASSERT(pFunction->getType() == CNormalFunction::COS);
338 
339  pFraction2 = &pFunction->getFraction();
340  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
341  const CNormalSum& numerator3 = pFraction2->getNumerator();
342  CPPUNIT_ASSERT(numerator3.getFractions().size() == 0);
343  const std::set<CNormalProduct*, compareProducts >& products3 = numerator3.getProducts();
344  CPPUNIT_ASSERT(products3.size() == 1);
345  pProduct = *(products3.begin());
346  CPPUNIT_ASSERT(pProduct != NULL);
347  CPPUNIT_ASSERT(pProduct->getFactor() == 3.0);
348  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
349 }
350 
351 void test_normalform::test_sum_functions_reversed()
352 {
353  std::string infix("COS(3.0)+SIN(5.0)");
354  CEvaluationTree* pTree = new CEvaluationTree();
355  pTree->setInfix(infix);
356  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
358  delete pTree;
359  CPPUNIT_ASSERT(pFraction != NULL);
360 
361  const CNormalSum& numerator = pFraction->getNumerator();
362  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
363  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
364  CPPUNIT_ASSERT(products.size() == 2);
365  std::set<CNormalProduct*, compareProducts >::iterator it = products.begin();
366  const CNormalProduct* pProduct = *(it);
367  CPPUNIT_ASSERT(pProduct != NULL);
368  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
369  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
370  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
371  CPPUNIT_ASSERT(pItemPower != NULL);
372  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
373  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::FUNCTION);
374  const CNormalFunction* pFunction = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
375  CPPUNIT_ASSERT(pFunction != NULL);
376  CPPUNIT_ASSERT(pFunction->getType() == CNormalFunction::SIN);
377 
378  const CNormalFraction* pFraction2 = &pFunction->getFraction();
379  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
380  const CNormalSum& numerator2 = pFraction2->getNumerator();
381  CPPUNIT_ASSERT(numerator2.getFractions().size() == 0);
382  const std::set<CNormalProduct*, compareProducts >& products2 = numerator2.getProducts();
383  CPPUNIT_ASSERT(products2.size() == 1);
384  pProduct = *(products2.begin());
385  CPPUNIT_ASSERT(pProduct != NULL);
386  CPPUNIT_ASSERT(pProduct->getFactor() == 5.0);
387  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
388  ++it;
389  pProduct = *(it);
390  CPPUNIT_ASSERT(pProduct != NULL);
391  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
392  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
393  pItemPower = *(pProduct->getItemPowers().begin());
394  CPPUNIT_ASSERT(pItemPower != NULL);
395  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
396  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::FUNCTION);
397  pFunction = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
398  CPPUNIT_ASSERT(pFunction != NULL);
399  CPPUNIT_ASSERT(pFunction->getType() == CNormalFunction::COS);
400 
401  pFraction2 = &pFunction->getFraction();
402  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
403  const CNormalSum& numerator3 = pFraction2->getNumerator();
404  CPPUNIT_ASSERT(numerator3.getFractions().size() == 0);
405  const std::set<CNormalProduct*, compareProducts >& products3 = numerator3.getProducts();
406  CPPUNIT_ASSERT(products3.size() == 1);
407  pProduct = *(products3.begin());
408  CPPUNIT_ASSERT(pProduct != NULL);
409  CPPUNIT_ASSERT(pProduct->getFactor() == 3.0);
410  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
411 }
412 
413 void test_normalform::test_sum_mixed_1()
414 {
415  std::string infix("7.0+SIN(4.0)");
416  CEvaluationTree* pTree = new CEvaluationTree();
417  pTree->setInfix(infix);
418  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
420  delete pTree;
421  CPPUNIT_ASSERT(pFraction != NULL);
422 
423  const CNormalSum& numerator = pFraction->getNumerator();
424  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
425  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
426  std::set<CNormalProduct*, compareProducts >::iterator it = products.begin();
427  CPPUNIT_ASSERT(products.size() == 2);
428  const CNormalProduct* pProduct = *(it);
429  CPPUNIT_ASSERT(pProduct != NULL);
430  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
431  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
432  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
433  CPPUNIT_ASSERT(pItemPower != NULL);
434  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
435  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::FUNCTION);
436  const CNormalFunction* pFunction = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
437  CPPUNIT_ASSERT(pFunction != NULL);
438  CPPUNIT_ASSERT(pFunction->getType() == CNormalFunction::SIN);
439 
440  const CNormalFraction* pFraction2 = &pFunction->getFraction();
441  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
442  const CNormalSum& numerator3 = pFraction2->getNumerator();
443  CPPUNIT_ASSERT(numerator3.getFractions().size() == 0);
444  const std::set<CNormalProduct*, compareProducts >& products3 = numerator3.getProducts();
445  CPPUNIT_ASSERT(products3.size() == 1);
446  pProduct = *(products3.begin());
447  CPPUNIT_ASSERT(pProduct != NULL);
448  CPPUNIT_ASSERT(pProduct->getFactor() == 4.0);
449  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
450 
451  ++it;
452  pProduct = *(it);
453  CPPUNIT_ASSERT(pProduct != NULL);
454  CPPUNIT_ASSERT(pProduct->getFactor() == 7.0);
455  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
456 }
457 
458 void test_normalform::test_sum_mixed_1_reversed()
459 {
460  std::string infix("SIN(4.0)+7.0");
461  CEvaluationTree* pTree = new CEvaluationTree();
462  pTree->setInfix(infix);
463  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
465  delete pTree;
466  CPPUNIT_ASSERT(pFraction != NULL);
467 
468  const CNormalSum& numerator = pFraction->getNumerator();
469  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
470  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
471  std::set<CNormalProduct*, compareProducts >::iterator it = products.begin();
472  CPPUNIT_ASSERT(products.size() == 2);
473  const CNormalProduct* pProduct = *(it);
474  CPPUNIT_ASSERT(pProduct != NULL);
475  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
476  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
477  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
478  CPPUNIT_ASSERT(pItemPower != NULL);
479  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
480  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::FUNCTION);
481  const CNormalFunction* pFunction = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
482  CPPUNIT_ASSERT(pFunction != NULL);
483  CPPUNIT_ASSERT(pFunction->getType() == CNormalFunction::SIN);
484 
485  const CNormalFraction* pFraction2 = &pFunction->getFraction();
486  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
487  const CNormalSum& numerator3 = pFraction2->getNumerator();
488  CPPUNIT_ASSERT(numerator3.getFractions().size() == 0);
489  const std::set<CNormalProduct*, compareProducts >& products3 = numerator3.getProducts();
490  CPPUNIT_ASSERT(products3.size() == 1);
491  pProduct = *(products3.begin());
492  CPPUNIT_ASSERT(pProduct != NULL);
493  CPPUNIT_ASSERT(pProduct->getFactor() == 4.0);
494  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
495 
496  ++it;
497  pProduct = *(it);
498  CPPUNIT_ASSERT(pProduct != NULL);
499  CPPUNIT_ASSERT(pProduct->getFactor() == 7.0);
500  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
501 }
502 
503 void test_normalform::test_sum_mixed_2()
504 {
505  std::string infix("A+COS(0.0)+PI");
506  CEvaluationTree* pTree = new CEvaluationTree();
507  pTree->setInfix(infix);
508  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
510  delete pTree;
511  CPPUNIT_ASSERT(pFraction != NULL);
512 
513  const CNormalSum& numerator = pFraction->getNumerator();
514  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
515  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
516  std::set<CNormalProduct*, compareProducts >::iterator it = products.begin();
517  CPPUNIT_ASSERT(products.size() == 3);
518  const CNormalProduct* pProduct = *(it);
519  CPPUNIT_ASSERT(pProduct != NULL);
520  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
521  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
522  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
523  CPPUNIT_ASSERT(pItemPower != NULL);
524  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
525  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
526  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
527  CPPUNIT_ASSERT(pItem != NULL);
528  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::CONSTANT);
529  CPPUNIT_ASSERT(pItem->getName() == "PI");
530 
531  ++it;
532  pProduct = *(it);
533  CPPUNIT_ASSERT(pProduct != NULL);
534  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
535  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
536  pItemPower = *(pProduct->getItemPowers().begin());
537  CPPUNIT_ASSERT(pItemPower != NULL);
538  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
539  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
540  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
541  CPPUNIT_ASSERT(pItem != NULL);
542  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
543  CPPUNIT_ASSERT(pItem->getName() == "A");
544 
545  ++it;
546  pProduct = *(it);
547  CPPUNIT_ASSERT(pProduct != NULL);
548  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
549  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
550  pItemPower = *(pProduct->getItemPowers().begin());
551  CPPUNIT_ASSERT(pItemPower != NULL);
552  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
553  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::FUNCTION);
554  const CNormalFunction* pFunction = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
555  CPPUNIT_ASSERT(pFunction != NULL);
556  CPPUNIT_ASSERT(pFunction->getType() == CNormalFunction::COS);
557 
558  const CNormalFraction* pFraction2 = &pFunction->getFraction();
559  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
560  const CNormalSum& numerator3 = pFraction2->getNumerator();
561  CPPUNIT_ASSERT(numerator3.getFractions().size() == 0);
562  const std::set<CNormalProduct*, compareProducts >& products3 = numerator3.getProducts();
563  CPPUNIT_ASSERT(products3.size() == 0);
564 }
565 
566 void test_normalform::test_sum_mixed_2_reversed()
567 {
568  std::string infix("PI+COS(0.0)+A");
569  CEvaluationTree* pTree = new CEvaluationTree();
570  pTree->setInfix(infix);
571  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
573  delete pTree;
574  CPPUNIT_ASSERT(pFraction != NULL);
575 
576  const CNormalSum& numerator = pFraction->getNumerator();
577  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
578  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
579  std::set<CNormalProduct*, compareProducts >::iterator it = products.begin();
580  CPPUNIT_ASSERT(products.size() == 3);
581  const CNormalProduct* pProduct = *(it);
582  CPPUNIT_ASSERT(pProduct != NULL);
583  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
584  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
585  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
586  CPPUNIT_ASSERT(pItemPower != NULL);
587  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
588  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
589  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
590  CPPUNIT_ASSERT(pItem != NULL);
591  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::CONSTANT);
592  CPPUNIT_ASSERT(pItem->getName() == "PI");
593 
594  ++it;
595  pProduct = *(it);
596  CPPUNIT_ASSERT(pProduct != NULL);
597  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
598  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
599  pItemPower = *(pProduct->getItemPowers().begin());
600  CPPUNIT_ASSERT(pItemPower != NULL);
601  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
602  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
603  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
604  CPPUNIT_ASSERT(pItem != NULL);
605  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
606  CPPUNIT_ASSERT(pItem->getName() == "A");
607 
608  ++it;
609  pProduct = *(it);
610  CPPUNIT_ASSERT(pProduct != NULL);
611  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
612  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
613  pItemPower = *(pProduct->getItemPowers().begin());
614  CPPUNIT_ASSERT(pItemPower != NULL);
615  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
616  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::FUNCTION);
617  const CNormalFunction* pFunction = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
618  CPPUNIT_ASSERT(pFunction != NULL);
619  CPPUNIT_ASSERT(pFunction->getType() == CNormalFunction::COS);
620 
621  const CNormalFraction* pFraction2 = &pFunction->getFraction();
622  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
623  const CNormalSum& numerator3 = pFraction2->getNumerator();
624  CPPUNIT_ASSERT(numerator3.getFractions().size() == 0);
625  const std::set<CNormalProduct*, compareProducts >& products3 = numerator3.getProducts();
626  CPPUNIT_ASSERT(products3.size() == 0);
627 }
628 
629 void test_normalform::test_product_numbers()
630 {
631  std::string infix("7.0*3.0");
632  CEvaluationTree* pTree = new CEvaluationTree();
633  pTree->setInfix(infix);
634  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
636  delete pTree;
637  CPPUNIT_ASSERT(pFraction != NULL);
638 
639  const CNormalSum& numerator = pFraction->getNumerator();
640  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
641  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
642  CPPUNIT_ASSERT(products.size() == 1);
643  const CNormalProduct* pProduct = *(products.begin());
644  CPPUNIT_ASSERT(pProduct != NULL);
645  CPPUNIT_ASSERT(pProduct->getFactor() == 21.0);
646  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
647 }
648 
649 void test_normalform::test_product_variables()
650 {
651  std::string infix("A*B");
652  CEvaluationTree* pTree = new CEvaluationTree();
653  pTree->setInfix(infix);
654  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
656  delete pTree;
657  CPPUNIT_ASSERT(pFraction != NULL);
658 
659  const CNormalSum& numerator = pFraction->getNumerator();
660  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
661  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
662  CPPUNIT_ASSERT(products.size() == 1);
663  std::set<CNormalProduct*, compareProducts >::const_iterator it = products.begin();
664  const CNormalProduct* pProduct = *(it);
665  CPPUNIT_ASSERT(pProduct != NULL);
666  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
667  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 2);
668  std::set<CNormalItemPower*, compareItemPowers>::const_iterator it2 = pProduct->getItemPowers().begin();
669  const CNormalItemPower* pItemPower = *(it2);
670  CPPUNIT_ASSERT(pItemPower != NULL);
671  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
672  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
673  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
674  CPPUNIT_ASSERT(pItem != NULL);
675  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
676  CPPUNIT_ASSERT(pItem->getName() == "A");
677  ++it2;
678  pItemPower = *(it2);
679  CPPUNIT_ASSERT(pItemPower != NULL);
680  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
681  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
682  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
683  CPPUNIT_ASSERT(pItem != NULL);
684  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
685  CPPUNIT_ASSERT(pItem->getName() == "B");
686 }
687 
688 void test_normalform::test_product_variables_reversed()
689 {
690  std::string infix("B*A");
691  CEvaluationTree* pTree = new CEvaluationTree();
692  pTree->setInfix(infix);
693  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
695  delete pTree;
696  CPPUNIT_ASSERT(pFraction != NULL);
697 
698  const CNormalSum& numerator = pFraction->getNumerator();
699  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
700  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
701  CPPUNIT_ASSERT(products.size() == 1);
702  std::set<CNormalProduct*, compareProducts >::const_iterator it = products.begin();
703  const CNormalProduct* pProduct = *(it);
704  CPPUNIT_ASSERT(pProduct != NULL);
705  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
706  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 2);
707  std::set<CNormalItemPower*, compareItemPowers>::const_iterator it2 = pProduct->getItemPowers().begin();
708  const CNormalItemPower* pItemPower = *(it2);
709  CPPUNIT_ASSERT(pItemPower != NULL);
710  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
711  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
712  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
713  CPPUNIT_ASSERT(pItem != NULL);
714  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
715  CPPUNIT_ASSERT(pItem->getName() == "A");
716  ++it2;
717  pItemPower = *(it2);
718  CPPUNIT_ASSERT(pItemPower != NULL);
719  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
720  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
721  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
722  CPPUNIT_ASSERT(pItem != NULL);
723  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
724  CPPUNIT_ASSERT(pItem->getName() == "B");
725 }
726 
727 void test_normalform::test_product_constants()
728 {
729  std::string infix("PI*EXPONENTIALE");
730  CEvaluationTree* pTree = new CEvaluationTree();
731  pTree->setInfix(infix);
732  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
734  delete pTree;
735  CPPUNIT_ASSERT(pFraction != NULL);
736 
737  const CNormalSum& numerator = pFraction->getNumerator();
738  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
739  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
740  CPPUNIT_ASSERT(products.size() == 1);
741  std::set<CNormalProduct*, compareProducts >::const_iterator it = products.begin();
742  const CNormalProduct* pProduct = *(it);
743  CPPUNIT_ASSERT(pProduct != NULL);
744  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
745  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 2);
746  std::set<CNormalItemPower*, compareItemPowers>::const_iterator it2 = pProduct->getItemPowers().begin();
747  const CNormalItemPower* pItemPower = *(it2);
748  CPPUNIT_ASSERT(pItemPower != NULL);
749  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
750  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
751  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
752  CPPUNIT_ASSERT(pItem != NULL);
753  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::CONSTANT);
754  CPPUNIT_ASSERT(pItem->getName() == "EXPONENTIALE");
755  ++it2;
756  pItemPower = *(it2);
757  CPPUNIT_ASSERT(pItemPower != NULL);
758  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
759  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
760  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
761  CPPUNIT_ASSERT(pItem != NULL);
762  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::CONSTANT);
763  CPPUNIT_ASSERT(pItem->getName() == "PI");
764 }
765 
766 void test_normalform::test_product_constants_reversed()
767 {
768  std::string infix("EXPONENTIALE*PI");
769  CEvaluationTree* pTree = new CEvaluationTree();
770  pTree->setInfix(infix);
771  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
773  delete pTree;
774  CPPUNIT_ASSERT(pFraction != NULL);
775 
776  const CNormalSum& numerator = pFraction->getNumerator();
777  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
778  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
779  CPPUNIT_ASSERT(products.size() == 1);
780  std::set<CNormalProduct*, compareProducts >::const_iterator it = products.begin();
781  const CNormalProduct* pProduct = *(it);
782  CPPUNIT_ASSERT(pProduct != NULL);
783  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
784  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 2);
785  std::set<CNormalItemPower*, compareItemPowers>::const_iterator it2 = pProduct->getItemPowers().begin();
786  const CNormalItemPower* pItemPower = *(it2);
787  CPPUNIT_ASSERT(pItemPower != NULL);
788  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
789  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
790  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
791  CPPUNIT_ASSERT(pItem != NULL);
792  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::CONSTANT);
793  CPPUNIT_ASSERT(pItem->getName() == "EXPONENTIALE");
794  ++it2;
795  pItemPower = *(it2);
796  CPPUNIT_ASSERT(pItemPower != NULL);
797  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
798  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
799  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
800  CPPUNIT_ASSERT(pItem != NULL);
801  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::CONSTANT);
802  CPPUNIT_ASSERT(pItem->getName() == "PI");
803 }
804 
805 void test_normalform::test_product_functions()
806 {
807  std::string infix("SIN(2.1)*COS(3.5)");
808  CEvaluationTree* pTree = new CEvaluationTree();
809  pTree->setInfix(infix);
810  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
812  delete pTree;
813  CPPUNIT_ASSERT(pFraction != NULL);
814 
815  const CNormalSum& numerator = pFraction->getNumerator();
816  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
817  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
818  CPPUNIT_ASSERT(products.size() == 1);
819  std::set<CNormalProduct*, compareProducts >::const_iterator it = products.begin();
820  const CNormalProduct* pProduct = *(it);
821  CPPUNIT_ASSERT(pProduct != NULL);
822  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
823  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 2);
824  std::set<CNormalItemPower*, compareItemPowers>::const_iterator it2 = pProduct->getItemPowers().begin();
825  const CNormalItemPower* pItemPower = *(it2);
826  CPPUNIT_ASSERT(pItemPower != NULL);
827  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
828  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::FUNCTION);
829  const CNormalFunction* pItem = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
830  CPPUNIT_ASSERT(pItem != NULL);
831  CPPUNIT_ASSERT(pItem->getType() == CNormalFunction::SIN);
832 
833  const CNormalFraction* pFraction2 = &pItem->getFraction();
834  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
835  const CNormalSum& numerator2 = pFraction2->getNumerator();
836  CPPUNIT_ASSERT(numerator2.getFractions().size() == 0);
837  const std::set<CNormalProduct*, compareProducts >& products2 = numerator2.getProducts();
838  CPPUNIT_ASSERT(products2.size() == 1);
839  pProduct = *(products2.begin());
840  CPPUNIT_ASSERT(pProduct != NULL);
841  CPPUNIT_ASSERT(pProduct->getFactor() == 2.1);
842  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
843  ++it2;
844  pItemPower = *(it2);
845  CPPUNIT_ASSERT(pItemPower != NULL);
846  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
847  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::FUNCTION);
848  pItem = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
849  CPPUNIT_ASSERT(pItem != NULL);
850  CPPUNIT_ASSERT(pItem->getType() == CNormalFunction::COS);
851 
852  const CNormalFraction* pFraction3 = &pItem->getFraction();
853  CPPUNIT_ASSERT(pFraction3->checkDenominatorOne() == true);
854  const CNormalSum& numerator3 = pFraction3->getNumerator();
855  CPPUNIT_ASSERT(numerator3.getFractions().size() == 0);
856  const std::set<CNormalProduct*, compareProducts >& products3 = numerator3.getProducts();
857  CPPUNIT_ASSERT(products3.size() == 1);
858  pProduct = *(products3.begin());
859  CPPUNIT_ASSERT(pProduct != NULL);
860  CPPUNIT_ASSERT(pProduct->getFactor() == 3.5);
861  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
862 }
863 
864 void test_normalform::test_product_functions_reversed()
865 {
866  std::string infix("COS(3.5)*SIN(2.1)");
867  CEvaluationTree* pTree = new CEvaluationTree();
868  pTree->setInfix(infix);
869  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
871  delete pTree;
872  CPPUNIT_ASSERT(pFraction != NULL);
873 
874  const CNormalSum& numerator = pFraction->getNumerator();
875  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
876  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
877  CPPUNIT_ASSERT(products.size() == 1);
878  std::set<CNormalProduct*, compareProducts >::const_iterator it = products.begin();
879  const CNormalProduct* pProduct = *(it);
880  CPPUNIT_ASSERT(pProduct != NULL);
881  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
882  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 2);
883  std::set<CNormalItemPower*, compareItemPowers>::const_iterator it2 = pProduct->getItemPowers().begin();
884  const CNormalItemPower* pItemPower = *(it2);
885  CPPUNIT_ASSERT(pItemPower != NULL);
886  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
887  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::FUNCTION);
888  const CNormalFunction* pItem = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
889  CPPUNIT_ASSERT(pItem != NULL);
890  CPPUNIT_ASSERT(pItem->getType() == CNormalFunction::SIN);
891 
892  const CNormalFraction* pFraction2 = &pItem->getFraction();
893  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
894  const CNormalSum& numerator2 = pFraction2->getNumerator();
895  CPPUNIT_ASSERT(numerator2.getFractions().size() == 0);
896  const std::set<CNormalProduct*, compareProducts >& products2 = numerator2.getProducts();
897  CPPUNIT_ASSERT(products2.size() == 1);
898  pProduct = *(products2.begin());
899  CPPUNIT_ASSERT(pProduct != NULL);
900  CPPUNIT_ASSERT(pProduct->getFactor() == 2.1);
901  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
902  ++it2;
903  pItemPower = *(it2);
904  CPPUNIT_ASSERT(pItemPower != NULL);
905  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
906  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::FUNCTION);
907  pItem = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
908  CPPUNIT_ASSERT(pItem != NULL);
909  CPPUNIT_ASSERT(pItem->getType() == CNormalFunction::COS);
910 
911  const CNormalFraction* pFraction3 = &pItem->getFraction();
912  CPPUNIT_ASSERT(pFraction3->checkDenominatorOne() == true);
913  const CNormalSum& numerator3 = pFraction3->getNumerator();
914  CPPUNIT_ASSERT(numerator3.getFractions().size() == 0);
915  const std::set<CNormalProduct*, compareProducts >& products3 = numerator3.getProducts();
916  CPPUNIT_ASSERT(products3.size() == 1);
917  pProduct = *(products3.begin());
918  CPPUNIT_ASSERT(pProduct != NULL);
919  CPPUNIT_ASSERT(pProduct->getFactor() == 3.5);
920  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
921 }
922 
923 void test_normalform::test_product_mixed_1()
924 {
925  std::string infix("7.0*SIN(1.5)");
926  CEvaluationTree* pTree = new CEvaluationTree();
927  pTree->setInfix(infix);
928  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
930  delete pTree;
931  CPPUNIT_ASSERT(pFraction != NULL);
932 
933  const CNormalSum& numerator = pFraction->getNumerator();
934  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
935  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
936  CPPUNIT_ASSERT(products.size() == 1);
937  const CNormalProduct* pProduct = *(products.begin());
938  CPPUNIT_ASSERT(pProduct != NULL);
939  CPPUNIT_ASSERT(pProduct->getFactor() == 7.0);
940  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
941  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
942  CPPUNIT_ASSERT(pItemPower != NULL);
943  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
944  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::FUNCTION);
945  const CNormalFunction* pFunction = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
946  CPPUNIT_ASSERT(pFunction != NULL);
947  CPPUNIT_ASSERT(pFunction->getType() == CNormalFunction::SIN);
948 
949  const CNormalFraction* pFraction2 = &pFunction->getFraction();
950  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
951  const CNormalSum& numerator2 = pFraction2->getNumerator();
952  CPPUNIT_ASSERT(numerator2.getFractions().size() == 0);
953  const std::set<CNormalProduct*, compareProducts >& products2 = numerator2.getProducts();
954  CPPUNIT_ASSERT(products2.size() == 1);
955  pProduct = *(products2.begin());
956  CPPUNIT_ASSERT(pProduct != NULL);
957  CPPUNIT_ASSERT(pProduct->getFactor() == 1.5);
958  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
959 }
960 
961 void test_normalform::test_product_mixed_1_reversed()
962 {
963  std::string infix("SIN(1.5)*7.0");
964  CEvaluationTree* pTree = new CEvaluationTree();
965  pTree->setInfix(infix);
966  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
968  delete pTree;
969  CPPUNIT_ASSERT(pFraction != NULL);
970 
971  const CNormalSum& numerator = pFraction->getNumerator();
972  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
973  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
974  CPPUNIT_ASSERT(products.size() == 1);
975  const CNormalProduct* pProduct = *(products.begin());
976  CPPUNIT_ASSERT(pProduct != NULL);
977  CPPUNIT_ASSERT(pProduct->getFactor() == 7.0);
978  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
979  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
980  CPPUNIT_ASSERT(pItemPower != NULL);
981  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
982  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::FUNCTION);
983  const CNormalFunction* pFunction = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
984  CPPUNIT_ASSERT(pFunction != NULL);
985  CPPUNIT_ASSERT(pFunction->getType() == CNormalFunction::SIN);
986 
987  const CNormalFraction* pFraction2 = &pFunction->getFraction();
988  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
989  const CNormalSum& numerator2 = pFraction2->getNumerator();
990  CPPUNIT_ASSERT(numerator2.getFractions().size() == 0);
991  const std::set<CNormalProduct*, compareProducts >& products2 = numerator2.getProducts();
992  CPPUNIT_ASSERT(products2.size() == 1);
993  pProduct = *(products2.begin());
994  CPPUNIT_ASSERT(pProduct != NULL);
995  CPPUNIT_ASSERT(pProduct->getFactor() == 1.5);
996  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
997 }
998 
999 void test_normalform::test_product_mixed_2()
1000 {
1001  std::string infix("A*COS(1.2)*7.0*PI");
1002  CEvaluationTree* pTree = new CEvaluationTree();
1003  pTree->setInfix(infix);
1004  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
1006  delete pTree;
1007  CPPUNIT_ASSERT(pFraction != NULL);
1008 
1009  const CNormalSum& numerator = pFraction->getNumerator();
1010  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
1011  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
1012  CPPUNIT_ASSERT(products.size() == 1);
1013  const CNormalProduct* pProduct = *(products.begin());
1014  CPPUNIT_ASSERT(pProduct != NULL);
1015  CPPUNIT_ASSERT(pProduct->getFactor() == 7.0);
1016  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 3);
1017  std::set<CNormalItemPower*, compareItemPowers>::const_iterator it = pProduct->getItemPowers().begin();
1018 
1019  const CNormalItemPower* pItemPower = *(it);
1020  CPPUNIT_ASSERT(pItemPower != NULL);
1021  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
1022  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
1023  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
1024  CPPUNIT_ASSERT(pItem != NULL);
1025  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::CONSTANT);
1026  CPPUNIT_ASSERT(pItem->getName() == "PI");
1027  ++it;
1028 
1029  pItemPower = *(it);
1030  CPPUNIT_ASSERT(pItemPower != NULL);
1031  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
1032  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
1033  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
1034  CPPUNIT_ASSERT(pItem != NULL);
1035  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
1036  CPPUNIT_ASSERT(pItem->getName() == "A");
1037  ++it;
1038 
1039  pItemPower = *(it);
1040  CPPUNIT_ASSERT(pItemPower != NULL);
1041  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
1042  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::FUNCTION);
1043  const CNormalFunction* pFunction = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
1044  CPPUNIT_ASSERT(pFunction != NULL);
1045  CPPUNIT_ASSERT(pFunction->getType() == CNormalFunction::COS);
1046 
1047  const CNormalFraction* pFraction2 = &pFunction->getFraction();
1048  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
1049  const CNormalSum& numerator2 = pFraction2->getNumerator();
1050  CPPUNIT_ASSERT(numerator2.getFractions().size() == 0);
1051  const std::set<CNormalProduct*, compareProducts >& products2 = numerator2.getProducts();
1052  CPPUNIT_ASSERT(products2.size() == 1);
1053  pProduct = *(products2.begin());
1054  CPPUNIT_ASSERT(pProduct != NULL);
1055  CPPUNIT_ASSERT(pProduct->getFactor() == 1.2);
1056  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
1057 }
1058 
1059 void test_normalform::test_product_mixed_2_reversed()
1060 {
1061  std::string infix("PI*7.0*COS(1.2)*A");
1062  CEvaluationTree* pTree = new CEvaluationTree();
1063  pTree->setInfix(infix);
1064  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
1066  delete pTree;
1067  CPPUNIT_ASSERT(pFraction != NULL);
1068 
1069  const CNormalSum& numerator = pFraction->getNumerator();
1070  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
1071  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
1072  CPPUNIT_ASSERT(products.size() == 1);
1073  const CNormalProduct* pProduct = *(products.begin());
1074  CPPUNIT_ASSERT(pProduct != NULL);
1075  CPPUNIT_ASSERT(pProduct->getFactor() == 7.0);
1076  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 3);
1077  std::set<CNormalItemPower*, compareItemPowers>::const_iterator it = pProduct->getItemPowers().begin();
1078 
1079  const CNormalItemPower* pItemPower = *(it);
1080  CPPUNIT_ASSERT(pItemPower != NULL);
1081  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
1082  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
1083  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
1084  CPPUNIT_ASSERT(pItem != NULL);
1085  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::CONSTANT);
1086  CPPUNIT_ASSERT(pItem->getName() == "PI");
1087  ++it;
1088 
1089  pItemPower = *(it);
1090  CPPUNIT_ASSERT(pItemPower != NULL);
1091  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
1092  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
1093  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
1094  CPPUNIT_ASSERT(pItem != NULL);
1095  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
1096  CPPUNIT_ASSERT(pItem->getName() == "A");
1097  ++it;
1098 
1099  pItemPower = *(it);
1100  CPPUNIT_ASSERT(pItemPower != NULL);
1101  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
1102  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::FUNCTION);
1103  const CNormalFunction* pFunction = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
1104  CPPUNIT_ASSERT(pFunction != NULL);
1105  CPPUNIT_ASSERT(pFunction->getType() == CNormalFunction::COS);
1106 
1107  const CNormalFraction* pFraction2 = &pFunction->getFraction();
1108  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
1109  const CNormalSum& numerator2 = pFraction2->getNumerator();
1110  CPPUNIT_ASSERT(numerator2.getFractions().size() == 0);
1111  const std::set<CNormalProduct*, compareProducts >& products2 = numerator2.getProducts();
1112  CPPUNIT_ASSERT(products2.size() == 1);
1113  pProduct = *(products2.begin());
1114  CPPUNIT_ASSERT(pProduct != NULL);
1115  CPPUNIT_ASSERT(pProduct->getFactor() == 1.2);
1116  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
1117 }
1118 
1119 void test_normalform::test_fraction_numbers()
1120 {
1121  std::string infix("7.0/3.0");
1122  CEvaluationTree* pTree = new CEvaluationTree();
1123  pTree->setInfix(infix);
1124  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
1126  delete pTree;
1127  CPPUNIT_ASSERT(pFraction != NULL);
1128  CPPUNIT_ASSERT(pFraction->checkDenominatorOne() == true);
1129 
1130  const CNormalSum& numerator = pFraction->getNumerator();
1131  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
1132  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
1133  CPPUNIT_ASSERT(products.size() == 1);
1134  const CNormalProduct* pProduct = *(products.begin());
1135  CPPUNIT_ASSERT(pProduct != NULL);
1136  double quotient = (double)7.0 / (double)3.0;
1137  CPPUNIT_ASSERT(fabs((pProduct->getFactor() - quotient) / quotient) < 1e-15);
1138  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
1139 }
1140 
1141 void test_normalform::test_fraction_variables()
1142 {
1143  std::string infix("A/B");
1144  CEvaluationTree* pTree = new CEvaluationTree();
1145  pTree->setInfix(infix);
1146  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
1148  delete pTree;
1149  CPPUNIT_ASSERT(pFraction != NULL);
1150 
1151  const CNormalSum& numerator = pFraction->getNumerator();
1152  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
1153  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
1154  CPPUNIT_ASSERT(products.size() == 1);
1155  const CNormalProduct* pProduct = *(products.begin());
1156  CPPUNIT_ASSERT(pProduct != NULL);
1157  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
1158  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
1159  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
1160  CPPUNIT_ASSERT(pItemPower != NULL);
1161  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
1162  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
1163  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
1164  CPPUNIT_ASSERT(pItem != NULL);
1165  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
1166  CPPUNIT_ASSERT(pItem->getName() == "A");
1167 
1168  const CNormalSum& denominator = pFraction->getDenominator();
1169  CPPUNIT_ASSERT(denominator.getFractions().size() == 0);
1170  const std::set<CNormalProduct*, compareProducts >& products2 = denominator.getProducts();
1171  CPPUNIT_ASSERT(products2.size() == 1);
1172  pProduct = *(products2.begin());
1173  CPPUNIT_ASSERT(pProduct != NULL);
1174  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
1175  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
1176  pItemPower = *(pProduct->getItemPowers().begin());
1177  CPPUNIT_ASSERT(pItemPower != NULL);
1178  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
1179  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
1180  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
1181  CPPUNIT_ASSERT(pItem != NULL);
1182  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
1183  CPPUNIT_ASSERT(pItem->getName() == "B");
1184 }
1185 
1186 void test_normalform::test_fraction_constants()
1187 {
1188  std::string infix("PI/EXPONENTIALE");
1189  CEvaluationTree* pTree = new CEvaluationTree();
1190  pTree->setInfix(infix);
1191  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
1193  delete pTree;
1194  CPPUNIT_ASSERT(pFraction != NULL);
1195 
1196  const CNormalSum& numerator = pFraction->getNumerator();
1197  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
1198  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
1199  CPPUNIT_ASSERT(products.size() == 1);
1200  const CNormalProduct* pProduct = *(products.begin());
1201  CPPUNIT_ASSERT(pProduct != NULL);
1202  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
1203  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
1204  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
1205  CPPUNIT_ASSERT(pItemPower != NULL);
1206  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
1207  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
1208  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
1209  CPPUNIT_ASSERT(pItem != NULL);
1210  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::CONSTANT);
1211  CPPUNIT_ASSERT(pItem->getName() == "PI");
1212 
1213  const CNormalSum& denominator = pFraction->getDenominator();
1214  CPPUNIT_ASSERT(denominator.getFractions().size() == 0);
1215  const std::set<CNormalProduct*, compareProducts >& products2 = denominator.getProducts();
1216  CPPUNIT_ASSERT(products2.size() == 1);
1217  pProduct = *(products2.begin());
1218  CPPUNIT_ASSERT(pProduct != NULL);
1219  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
1220  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
1221  pItemPower = *(pProduct->getItemPowers().begin());
1222  CPPUNIT_ASSERT(pItemPower != NULL);
1223  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
1224  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
1225  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
1226  CPPUNIT_ASSERT(pItem != NULL);
1227  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::CONSTANT);
1228  CPPUNIT_ASSERT(pItem->getName() == "EXPONENTIALE");
1229 }
1230 
1231 void test_normalform::test_fraction_functions()
1232 {
1233  std::string infix("SIN(1.4)/COS(1.3)");
1234  CEvaluationTree* pTree = new CEvaluationTree();
1235  pTree->setInfix(infix);
1236  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
1238  delete pTree;
1239  CPPUNIT_ASSERT(pFraction != NULL);
1240 
1241  const CNormalSum& numerator = pFraction->getNumerator();
1242  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
1243  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
1244  CPPUNIT_ASSERT(products.size() == 1);
1245  const CNormalProduct* pProduct = *(products.begin());
1246  CPPUNIT_ASSERT(pProduct != NULL);
1247  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
1248  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
1249  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
1250  CPPUNIT_ASSERT(pItemPower != NULL);
1251  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
1252  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::FUNCTION);
1253  const CNormalFunction* pFunction = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
1254  CPPUNIT_ASSERT(pFunction != NULL);
1255  CPPUNIT_ASSERT(pFunction->getType() == CNormalFunction::SIN);
1256 
1257  const CNormalFraction* pFraction2 = &pFunction->getFraction();
1258  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
1259  const CNormalSum& numerator2 = pFraction2->getNumerator();
1260  CPPUNIT_ASSERT(numerator2.getFractions().size() == 0);
1261  const std::set<CNormalProduct*, compareProducts >& products2 = numerator2.getProducts();
1262  CPPUNIT_ASSERT(products2.size() == 1);
1263  pProduct = *(products2.begin());
1264  CPPUNIT_ASSERT(pProduct != NULL);
1265  CPPUNIT_ASSERT(pProduct->getFactor() == 1.4);
1266  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
1267 
1268  const CNormalSum& denominator = pFraction->getDenominator();
1269  CPPUNIT_ASSERT(denominator.getFractions().size() == 0);
1270  const std::set<CNormalProduct*, compareProducts >& products3 = denominator.getProducts();
1271  CPPUNIT_ASSERT(products3.size() == 1);
1272  pProduct = *(products3.begin());
1273  CPPUNIT_ASSERT(pProduct != NULL);
1274  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
1275  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
1276  pItemPower = *(pProduct->getItemPowers().begin());
1277  CPPUNIT_ASSERT(pItemPower != NULL);
1278  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
1279  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::FUNCTION);
1280  pFunction = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
1281  CPPUNIT_ASSERT(pFunction != NULL);
1282  CPPUNIT_ASSERT(pFunction->getType() == CNormalFunction::COS);
1283 
1284  pFraction2 = &pFunction->getFraction();
1285  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
1286  const CNormalSum& numerator3 = pFraction2->getNumerator();
1287  CPPUNIT_ASSERT(numerator3.getFractions().size() == 0);
1288  const std::set<CNormalProduct*, compareProducts >& products4 = numerator3.getProducts();
1289  CPPUNIT_ASSERT(products4.size() == 1);
1290  pProduct = *(products4.begin());
1291  CPPUNIT_ASSERT(pProduct != NULL);
1292  CPPUNIT_ASSERT(pProduct->getFactor() == 1.3);
1293  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
1294 }
1295 
1296 void test_normalform::test_fraction_mixed_1()
1297 {
1298  std::string infix("7.0/A");
1299  CEvaluationTree* pTree = new CEvaluationTree();
1300  pTree->setInfix(infix);
1301  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
1303  delete pTree;
1304  CPPUNIT_ASSERT(pFraction != NULL);
1305 
1306  const CNormalSum& numerator = pFraction->getNumerator();
1307  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
1308  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
1309  CPPUNIT_ASSERT(products.size() == 1);
1310  const CNormalProduct* pProduct = *(products.begin());
1311  CPPUNIT_ASSERT(pProduct != NULL);
1312  CPPUNIT_ASSERT(pProduct->getFactor() == 7.0);
1313  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
1314 
1315  const CNormalSum& denominator = pFraction->getDenominator();
1316  CPPUNIT_ASSERT(denominator.getFractions().size() == 0);
1317  const std::set<CNormalProduct*, compareProducts >& products2 = denominator.getProducts();
1318  CPPUNIT_ASSERT(products2.size() == 1);
1319  pProduct = *(products2.begin());
1320  CPPUNIT_ASSERT(pProduct != NULL);
1321  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
1322  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
1323  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
1324  CPPUNIT_ASSERT(pItemPower != NULL);
1325  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
1326  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
1327  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
1328  CPPUNIT_ASSERT(pItem != NULL);
1329  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
1330  CPPUNIT_ASSERT(pItem->getName() == "A");
1331 }
1332 
1333 void test_normalform::test_fraction_mixed_2()
1334 {
1335  std::string infix("PI/TAN(A)");
1336  CEvaluationTree* pTree = new CEvaluationTree();
1337  pTree->setInfix(infix);
1338  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
1340  delete pTree;
1341  CPPUNIT_ASSERT(pFraction != NULL);
1342 
1343  const CNormalSum& numerator = pFraction->getNumerator();
1344  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
1345  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
1346  CPPUNIT_ASSERT(products.size() == 1);
1347  const CNormalProduct* pProduct = *(products.begin());
1348  CPPUNIT_ASSERT(pProduct != NULL);
1349  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
1350  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
1351  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
1352  CPPUNIT_ASSERT(pItemPower != NULL);
1353  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
1354  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
1355  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
1356  CPPUNIT_ASSERT(pItem != NULL);
1357  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::CONSTANT);
1358  CPPUNIT_ASSERT(pItem->getName() == "PI");
1359 
1360  const CNormalSum& denominator = pFraction->getDenominator();
1361  CPPUNIT_ASSERT(denominator.getFractions().size() == 0);
1362  const std::set<CNormalProduct*, compareProducts >& products3 = denominator.getProducts();
1363  CPPUNIT_ASSERT(products3.size() == 1);
1364  pProduct = *(products3.begin());
1365  CPPUNIT_ASSERT(pProduct != NULL);
1366  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
1367  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
1368  pItemPower = *(pProduct->getItemPowers().begin());
1369  CPPUNIT_ASSERT(pItemPower != NULL);
1370  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
1371  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::FUNCTION);
1372  const CNormalFunction* pFunction = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
1373  CPPUNIT_ASSERT(pFunction != NULL);
1374  CPPUNIT_ASSERT(pFunction->getType() == CNormalFunction::TAN);
1375 
1376  const CNormalFraction* pFraction2 = &pFunction->getFraction();
1377  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
1378  const CNormalSum& numerator3 = pFraction2->getNumerator();
1379  CPPUNIT_ASSERT(numerator3.getFractions().size() == 0);
1380  const std::set<CNormalProduct*, compareProducts >& products4 = numerator3.getProducts();
1381  CPPUNIT_ASSERT(products4.size() == 1);
1382  pProduct = *(products4.begin());
1383  CPPUNIT_ASSERT(pProduct != NULL);
1384  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
1385  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
1386  pItemPower = *(pProduct->getItemPowers().begin());
1387  CPPUNIT_ASSERT(pItemPower != NULL);
1388  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
1389  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
1390  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
1391  CPPUNIT_ASSERT(pItem != NULL);
1392  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
1393  CPPUNIT_ASSERT(pItem->getName() == "A");
1394 }
1395 
1396 void test_normalform::test_itempower_numbers()
1397 {
1398  std::string infix("4.0^3");
1399  CEvaluationTree* pTree = new CEvaluationTree();
1400  pTree->setInfix(infix);
1401  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
1403  delete pTree;
1404  CPPUNIT_ASSERT(pFraction != NULL);
1405 
1406  const CNormalSum& numerator = pFraction->getNumerator();
1407  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
1408  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
1409  CPPUNIT_ASSERT(products.size() == 1);
1410  const CNormalProduct* pProduct = *(products.begin());
1411  CPPUNIT_ASSERT(pProduct != NULL);
1412  CPPUNIT_ASSERT(pProduct->getFactor() == 64.0);
1413  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
1414 }
1415 
1416 void test_normalform::test_itempower_variables()
1417 {
1418  std::string infix("A^2");
1419  CEvaluationTree* pTree = new CEvaluationTree();
1420  pTree->setInfix(infix);
1421  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
1423  delete pTree;
1424  CPPUNIT_ASSERT(pFraction != NULL);
1425 
1426  const CNormalSum& numerator = pFraction->getNumerator();
1427  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
1428  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
1429  CPPUNIT_ASSERT(products.size() == 1);
1430  const CNormalProduct* pProduct = *(products.begin());
1431  CPPUNIT_ASSERT(pProduct != NULL);
1432  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
1433  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
1434  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
1435  CPPUNIT_ASSERT(pItemPower != NULL);
1436  CPPUNIT_ASSERT(pItemPower->getExp() == 2.0);
1437  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
1438  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
1439  CPPUNIT_ASSERT(pItem != NULL);
1440  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
1441  CPPUNIT_ASSERT(pItem->getName() == "A");
1442 }
1443 
1444 void test_normalform::test_itempower_constants()
1445 {
1446  std::string infix("PI^2");
1447  CEvaluationTree* pTree = new CEvaluationTree();
1448  pTree->setInfix(infix);
1449  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
1451  delete pTree;
1452  CPPUNIT_ASSERT(pFraction != NULL);
1453 
1454  const CNormalSum& numerator = pFraction->getNumerator();
1455  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
1456  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
1457  CPPUNIT_ASSERT(products.size() == 1);
1458  const CNormalProduct* pProduct = *(products.begin());
1459  CPPUNIT_ASSERT(pProduct != NULL);
1460  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
1461  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
1462  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
1463  CPPUNIT_ASSERT(pItemPower != NULL);
1464  CPPUNIT_ASSERT(pItemPower->getExp() == 2.0);
1465  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
1466  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
1467  CPPUNIT_ASSERT(pItem != NULL);
1468  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::CONSTANT);
1469  CPPUNIT_ASSERT(pItem->getName() == "PI");
1470 }
1471 
1472 void test_normalform::test_itempower_functions()
1473 {
1474  std::string infix("SIN(5.5)^5");
1475  CEvaluationTree* pTree = new CEvaluationTree();
1476  pTree->setInfix(infix);
1477  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
1479  delete pTree;
1480  CPPUNIT_ASSERT(pFraction != NULL);
1481 
1482  const CNormalSum& numerator = pFraction->getNumerator();
1483  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
1484  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
1485  CPPUNIT_ASSERT(products.size() == 1);
1486  const CNormalProduct* pProduct = *(products.begin());
1487  CPPUNIT_ASSERT(pProduct != NULL);
1488  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
1489  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
1490  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
1491  CPPUNIT_ASSERT(pItemPower != NULL);
1492  CPPUNIT_ASSERT(pItemPower->getExp() == 5.0);
1493  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::FUNCTION);
1494  const CNormalFunction* pFunction = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
1495  CPPUNIT_ASSERT(pFunction != NULL);
1496  CPPUNIT_ASSERT(pFunction->getType() == CNormalFunction::SIN);
1497 
1498  const CNormalFraction* pFraction2 = &pFunction->getFraction();
1499  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
1500  const CNormalSum& numerator2 = pFraction2->getNumerator();
1501  CPPUNIT_ASSERT(numerator2.getFractions().size() == 0);
1502  const std::set<CNormalProduct*, compareProducts >& products2 = numerator2.getProducts();
1503  CPPUNIT_ASSERT(products2.size() == 1);
1504  pProduct = *(products2.begin());
1505  CPPUNIT_ASSERT(pProduct != NULL);
1506  CPPUNIT_ASSERT(pProduct->getFactor() == 5.5);
1507  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
1508 }
1509 
1510 void test_normalform::test_generalpower_number_and_variable()
1511 {
1512  std::string infix("7.0^A");
1513  CEvaluationTree* pTree = new CEvaluationTree();
1514  pTree->setInfix(infix);
1515  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
1517  delete pTree;
1518  CPPUNIT_ASSERT(pFraction != NULL);
1519 
1520  const CNormalSum& numerator = pFraction->getNumerator();
1521  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
1522  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
1523  CPPUNIT_ASSERT(products.size() == 1);
1524  const CNormalProduct* pProduct = *(products.begin());
1525  CPPUNIT_ASSERT(pProduct != NULL);
1526  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
1527  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
1528  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
1529  CPPUNIT_ASSERT(pItemPower != NULL);
1530  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
1531  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::POWER);
1532  const CNormalGeneralPower* pPower = dynamic_cast<const CNormalGeneralPower*>(&pItemPower->getItem());
1533  CPPUNIT_ASSERT(pPower != NULL);
1534  CPPUNIT_ASSERT(pPower->getType() == CNormalGeneralPower::POWER);
1535 
1536  const CNormalFraction* pFraction2 = &pPower->getLeft();
1537  CPPUNIT_ASSERT(pFraction2 != NULL);
1538  const CNormalSum& numerator2 = pFraction2->getNumerator();
1539  CPPUNIT_ASSERT(numerator2.getFractions().size() == 0);
1540  const std::set<CNormalProduct*, compareProducts >& products2 = numerator2.getProducts();
1541  CPPUNIT_ASSERT(products2.size() == 1);
1542  pProduct = *(products2.begin());
1543  CPPUNIT_ASSERT(pProduct != NULL);
1544  CPPUNIT_ASSERT(pProduct->getFactor() == 7.0);
1545  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
1546 
1547  pFraction2 = &pPower->getRight();
1548  CPPUNIT_ASSERT(pFraction2 != NULL);
1549  const CNormalSum& numerator3 = pFraction2->getNumerator();
1550  CPPUNIT_ASSERT(numerator3.getFractions().size() == 0);
1551  const std::set<CNormalProduct*, compareProducts >& products3 = numerator3.getProducts();
1552  CPPUNIT_ASSERT(products3.size() == 1);
1553  pProduct = *(products3.begin());
1554  CPPUNIT_ASSERT(pProduct != NULL);
1555  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
1556  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
1557  pItemPower = *(pProduct->getItemPowers().begin());
1558  CPPUNIT_ASSERT(pItemPower != NULL);
1559  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
1560  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
1561  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
1562  CPPUNIT_ASSERT(pItem != NULL);
1563  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
1564  CPPUNIT_ASSERT(pItem->getName() == "A");
1565 }
1566 
1567 void test_normalform::test_generalpower_variable_and_variable()
1568 {
1569  std::string infix("B^A");
1570  CEvaluationTree* pTree = new CEvaluationTree();
1571  pTree->setInfix(infix);
1572  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
1574  delete pTree;
1575  CPPUNIT_ASSERT(pFraction != NULL);
1576 
1577  const CNormalSum& numerator = pFraction->getNumerator();
1578  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
1579  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
1580  CPPUNIT_ASSERT(products.size() == 1);
1581  const CNormalProduct* pProduct = *(products.begin());
1582  CPPUNIT_ASSERT(pProduct != NULL);
1583  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
1584  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
1585  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
1586  CPPUNIT_ASSERT(pItemPower != NULL);
1587  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
1588  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::POWER);
1589  const CNormalGeneralPower* pPower = dynamic_cast<const CNormalGeneralPower*>(&pItemPower->getItem());
1590  CPPUNIT_ASSERT(pPower != NULL);
1591  CPPUNIT_ASSERT(pPower->getType() == CNormalGeneralPower::POWER);
1592 
1593  const CNormalFraction* pFraction2 = &pPower->getLeft();
1594  CPPUNIT_ASSERT(pFraction2 != NULL);
1595  const CNormalSum& numerator2 = pFraction2->getNumerator();
1596  CPPUNIT_ASSERT(numerator2.getFractions().size() == 0);
1597  const std::set<CNormalProduct*, compareProducts >& products2 = numerator2.getProducts();
1598  CPPUNIT_ASSERT(products2.size() == 1);
1599  pProduct = *(products2.begin());
1600  CPPUNIT_ASSERT(pProduct != NULL);
1601  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
1602  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
1603  pItemPower = *(pProduct->getItemPowers().begin());
1604  CPPUNIT_ASSERT(pItemPower != NULL);
1605  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
1606  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
1607  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
1608  CPPUNIT_ASSERT(pItem != NULL);
1609  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
1610  CPPUNIT_ASSERT(pItem->getName() == "B");
1611 
1612  pFraction2 = &pPower->getRight();
1613  CPPUNIT_ASSERT(pFraction2 != NULL);
1614  const CNormalSum& numerator3 = pFraction2->getNumerator();
1615  CPPUNIT_ASSERT(numerator3.getFractions().size() == 0);
1616  const std::set<CNormalProduct*, compareProducts >& products3 = numerator3.getProducts();
1617  CPPUNIT_ASSERT(products3.size() == 1);
1618  pProduct = *(products3.begin());
1619  CPPUNIT_ASSERT(pProduct != NULL);
1620  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
1621  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
1622  pItemPower = *(pProduct->getItemPowers().begin());
1623  CPPUNIT_ASSERT(pItemPower != NULL);
1624  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
1625  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
1626  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
1627  CPPUNIT_ASSERT(pItem != NULL);
1628  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
1629  CPPUNIT_ASSERT(pItem->getName() == "A");
1630 }
1631 
1632 void test_normalform::test_generalpower_constant_and_constant()
1633 {
1634  std::string infix("PI^EXPONENTIALE");
1635  CEvaluationTree* pTree = new CEvaluationTree();
1636  pTree->setInfix(infix);
1637  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
1639  delete pTree;
1640  CPPUNIT_ASSERT(pFraction != NULL);
1641 
1642  const CNormalSum& numerator = pFraction->getNumerator();
1643  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
1644  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
1645  CPPUNIT_ASSERT(products.size() == 1);
1646  const CNormalProduct* pProduct = *(products.begin());
1647  CPPUNIT_ASSERT(pProduct != NULL);
1648  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
1649  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
1650  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
1651  CPPUNIT_ASSERT(pItemPower != NULL);
1652  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
1653  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::POWER);
1654  const CNormalGeneralPower* pPower = dynamic_cast<const CNormalGeneralPower*>(&pItemPower->getItem());
1655  CPPUNIT_ASSERT(pPower != NULL);
1656  CPPUNIT_ASSERT(pPower->getType() == CNormalGeneralPower::POWER);
1657 
1658  const CNormalFraction* pFraction2 = &pPower->getLeft();
1659  CPPUNIT_ASSERT(pFraction2 != NULL);
1660  const CNormalSum& numerator2 = pFraction2->getNumerator();
1661  CPPUNIT_ASSERT(numerator2.getFractions().size() == 0);
1662  const std::set<CNormalProduct*, compareProducts >& products2 = numerator2.getProducts();
1663  CPPUNIT_ASSERT(products2.size() == 1);
1664  pProduct = *(products2.begin());
1665  CPPUNIT_ASSERT(pProduct != NULL);
1666  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
1667  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
1668  pItemPower = *(pProduct->getItemPowers().begin());
1669  CPPUNIT_ASSERT(pItemPower != NULL);
1670  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
1671  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
1672  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
1673  CPPUNIT_ASSERT(pItem != NULL);
1674  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::CONSTANT);
1675  CPPUNIT_ASSERT(pItem->getName() == "PI");
1676 
1677  pFraction2 = &pPower->getRight();
1678  CPPUNIT_ASSERT(pFraction2 != NULL);
1679  const CNormalSum& numerator3 = pFraction2->getNumerator();
1680  CPPUNIT_ASSERT(numerator3.getFractions().size() == 0);
1681  const std::set<CNormalProduct*, compareProducts >& products3 = numerator3.getProducts();
1682  CPPUNIT_ASSERT(products3.size() == 1);
1683  pProduct = *(products3.begin());
1684  CPPUNIT_ASSERT(pProduct != NULL);
1685  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
1686  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
1687  pItemPower = *(pProduct->getItemPowers().begin());
1688  CPPUNIT_ASSERT(pItemPower != NULL);
1689  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
1690  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
1691  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
1692  CPPUNIT_ASSERT(pItem != NULL);
1693  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::CONSTANT);
1694  CPPUNIT_ASSERT(pItem->getName() == "EXPONENTIALE");
1695 }
1696 
1697 void test_normalform::test_generalpower_function_and_function()
1698 {
1699  std::string infix("COS(5.0)^SIN(2.0)");
1700  CEvaluationTree* pTree = new CEvaluationTree();
1701  pTree->setInfix(infix);
1702  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
1704  delete pTree;
1705  CPPUNIT_ASSERT(pFraction != NULL);
1706 
1707  const CNormalSum& numerator = pFraction->getNumerator();
1708  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
1709  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
1710  CPPUNIT_ASSERT(products.size() == 1);
1711  const CNormalProduct* pProduct = *(products.begin());
1712  CPPUNIT_ASSERT(pProduct != NULL);
1713  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
1714  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
1715  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
1716  CPPUNIT_ASSERT(pItemPower != NULL);
1717  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
1718  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::POWER);
1719  const CNormalGeneralPower* pPower = dynamic_cast<const CNormalGeneralPower*>(&pItemPower->getItem());
1720  CPPUNIT_ASSERT(pPower != NULL);
1721  CPPUNIT_ASSERT(pPower->getType() == CNormalGeneralPower::POWER);
1722 
1723  const CNormalFraction* pFraction2 = &pPower->getLeft();
1724  CPPUNIT_ASSERT(pFraction2 != NULL);
1725  const CNormalSum& numerator2 = pFraction2->getNumerator();
1726  CPPUNIT_ASSERT(numerator2.getFractions().size() == 0);
1727  const std::set<CNormalProduct*, compareProducts >& products2 = numerator2.getProducts();
1728  CPPUNIT_ASSERT(products2.size() == 1);
1729  pProduct = *(products2.begin());
1730  CPPUNIT_ASSERT(pProduct != NULL);
1731  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
1732  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
1733  pItemPower = *(pProduct->getItemPowers().begin());
1734  CPPUNIT_ASSERT(pItemPower != NULL);
1735  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
1736  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::FUNCTION);
1737  const CNormalFunction* pFunction = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
1738  CPPUNIT_ASSERT(pFunction != NULL);
1739  CPPUNIT_ASSERT(pFunction->getType() == CNormalFunction::COS);
1740 
1741  pFraction2 = &pFunction->getFraction();
1742  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
1743  const CNormalSum& numerator3 = pFraction2->getNumerator();
1744  CPPUNIT_ASSERT(numerator3.getFractions().size() == 0);
1745  const std::set<CNormalProduct*, compareProducts >& products3 = numerator3.getProducts();
1746  CPPUNIT_ASSERT(products3.size() == 1);
1747  pProduct = *(products3.begin());
1748  CPPUNIT_ASSERT(pProduct != NULL);
1749  CPPUNIT_ASSERT(pProduct->getFactor() == 5.0);
1750  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
1751 
1752  pFraction2 = &pPower->getRight();
1753  CPPUNIT_ASSERT(pFraction2 != NULL);
1754  const CNormalSum& numerator4 = pFraction2->getNumerator();
1755  CPPUNIT_ASSERT(numerator4.getFractions().size() == 0);
1756  const std::set<CNormalProduct*, compareProducts >& products4 = numerator4.getProducts();
1757  CPPUNIT_ASSERT(products4.size() == 1);
1758  pProduct = *(products4.begin());
1759  CPPUNIT_ASSERT(pProduct != NULL);
1760  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
1761  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
1762  pItemPower = *(pProduct->getItemPowers().begin());
1763  CPPUNIT_ASSERT(pItemPower != NULL);
1764  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
1765  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::FUNCTION);
1766  pFunction = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
1767  CPPUNIT_ASSERT(pFunction != NULL);
1768  CPPUNIT_ASSERT(pFunction->getType() == CNormalFunction::SIN);
1769 
1770  pFraction2 = &pFunction->getFraction();
1771  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
1772  const CNormalSum& numerator5 = pFraction2->getNumerator();
1773  CPPUNIT_ASSERT(numerator5.getFractions().size() == 0);
1774  const std::set<CNormalProduct*, compareProducts >& products5 = numerator5.getProducts();
1775  CPPUNIT_ASSERT(products5.size() == 1);
1776  pProduct = *(products5.begin());
1777  CPPUNIT_ASSERT(pProduct != NULL);
1778  CPPUNIT_ASSERT(pProduct->getFactor() == 2.0);
1779  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
1780 }
1781 
1782 void test_normalform::test_generalmodulus_number_and_variable()
1783 {
1784  std::string infix("7.0%A");
1785  CEvaluationTree* pTree = new CEvaluationTree();
1786  pTree->setInfix(infix);
1787  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
1789  delete pTree;
1790  CPPUNIT_ASSERT(pFraction != NULL);
1791 
1792  const CNormalSum& numerator = pFraction->getNumerator();
1793  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
1794  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
1795  CPPUNIT_ASSERT(products.size() == 1);
1796  const CNormalProduct* pProduct = *(products.begin());
1797  CPPUNIT_ASSERT(pProduct != NULL);
1798  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
1799  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
1800  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
1801  CPPUNIT_ASSERT(pItemPower != NULL);
1802  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
1803  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::POWER);
1804  const CNormalGeneralPower* pPower = dynamic_cast<const CNormalGeneralPower*>(&pItemPower->getItem());
1805  CPPUNIT_ASSERT(pPower != NULL);
1806  CPPUNIT_ASSERT(pPower->getType() == CNormalGeneralPower::MODULO);
1807 
1808  const CNormalFraction* pFraction2 = &pPower->getLeft();
1809  CPPUNIT_ASSERT(pFraction2 != NULL);
1810  const CNormalSum& numerator2 = pFraction2->getNumerator();
1811  CPPUNIT_ASSERT(numerator2.getFractions().size() == 0);
1812  const std::set<CNormalProduct*, compareProducts >& products2 = numerator2.getProducts();
1813  CPPUNIT_ASSERT(products2.size() == 1);
1814  pProduct = *(products2.begin());
1815  CPPUNIT_ASSERT(pProduct != NULL);
1816  CPPUNIT_ASSERT(pProduct->getFactor() == 7.0);
1817  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
1818 
1819  pFraction2 = &pPower->getRight();
1820  CPPUNIT_ASSERT(pFraction2 != NULL);
1821  const CNormalSum& numerator3 = pFraction2->getNumerator();
1822  CPPUNIT_ASSERT(numerator3.getFractions().size() == 0);
1823  const std::set<CNormalProduct*, compareProducts >& products3 = numerator3.getProducts();
1824  CPPUNIT_ASSERT(products3.size() == 1);
1825  pProduct = *(products3.begin());
1826  CPPUNIT_ASSERT(pProduct != NULL);
1827  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
1828  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
1829  pItemPower = *(pProduct->getItemPowers().begin());
1830  CPPUNIT_ASSERT(pItemPower != NULL);
1831  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
1832  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
1833  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
1834  CPPUNIT_ASSERT(pItem != NULL);
1835  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
1836  CPPUNIT_ASSERT(pItem->getName() == "A");
1837 }
1838 
1839 void test_normalform::test_generalmodulus_variable_and_variable()
1840 {
1841  std::string infix("B%A");
1842  CEvaluationTree* pTree = new CEvaluationTree();
1843  pTree->setInfix(infix);
1844  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
1846  delete pTree;
1847  CPPUNIT_ASSERT(pFraction != NULL);
1848 
1849  const CNormalSum& numerator = pFraction->getNumerator();
1850  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
1851  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
1852  CPPUNIT_ASSERT(products.size() == 1);
1853  const CNormalProduct* pProduct = *(products.begin());
1854  CPPUNIT_ASSERT(pProduct != NULL);
1855  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
1856  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
1857  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
1858  CPPUNIT_ASSERT(pItemPower != NULL);
1859  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
1860  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::POWER);
1861  const CNormalGeneralPower* pPower = dynamic_cast<const CNormalGeneralPower*>(&pItemPower->getItem());
1862  CPPUNIT_ASSERT(pPower != NULL);
1863  CPPUNIT_ASSERT(pPower->getType() == CNormalGeneralPower::MODULO);
1864 
1865  const CNormalFraction* pFraction2 = &pPower->getLeft();
1866  CPPUNIT_ASSERT(pFraction2 != NULL);
1867  const CNormalSum& numerator2 = pFraction2->getNumerator();
1868  CPPUNIT_ASSERT(numerator2.getFractions().size() == 0);
1869  const std::set<CNormalProduct*, compareProducts >& products2 = numerator2.getProducts();
1870  CPPUNIT_ASSERT(products2.size() == 1);
1871  pProduct = *(products2.begin());
1872  CPPUNIT_ASSERT(pProduct != NULL);
1873  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
1874  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
1875  pItemPower = *(pProduct->getItemPowers().begin());
1876  CPPUNIT_ASSERT(pItemPower != NULL);
1877  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
1878  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
1879  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
1880  CPPUNIT_ASSERT(pItem != NULL);
1881  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
1882  CPPUNIT_ASSERT(pItem->getName() == "B");
1883 
1884  pFraction2 = &pPower->getRight();
1885  CPPUNIT_ASSERT(pFraction2 != NULL);
1886  const CNormalSum& numerator3 = pFraction2->getNumerator();
1887  CPPUNIT_ASSERT(numerator3.getFractions().size() == 0);
1888  const std::set<CNormalProduct*, compareProducts >& products3 = numerator3.getProducts();
1889  CPPUNIT_ASSERT(products3.size() == 1);
1890  pProduct = *(products3.begin());
1891  CPPUNIT_ASSERT(pProduct != NULL);
1892  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
1893  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
1894  pItemPower = *(pProduct->getItemPowers().begin());
1895  CPPUNIT_ASSERT(pItemPower != NULL);
1896  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
1897  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
1898  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
1899  CPPUNIT_ASSERT(pItem != NULL);
1900  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
1901  CPPUNIT_ASSERT(pItem->getName() == "A");
1902 }
1903 
1904 void test_normalform::test_generalmodulus_constant_and_constant()
1905 {
1906  std::string infix("PI%EXPONENTIALE");
1907  CEvaluationTree* pTree = new CEvaluationTree();
1908  pTree->setInfix(infix);
1909  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
1911  delete pTree;
1912  CPPUNIT_ASSERT(pFraction != NULL);
1913 
1914  const CNormalSum& numerator = pFraction->getNumerator();
1915  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
1916  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
1917  CPPUNIT_ASSERT(products.size() == 1);
1918  const CNormalProduct* pProduct = *(products.begin());
1919  CPPUNIT_ASSERT(pProduct != NULL);
1920  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
1921  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
1922  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
1923  CPPUNIT_ASSERT(pItemPower != NULL);
1924  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
1925  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::POWER);
1926  const CNormalGeneralPower* pPower = dynamic_cast<const CNormalGeneralPower*>(&pItemPower->getItem());
1927  CPPUNIT_ASSERT(pPower != NULL);
1928  CPPUNIT_ASSERT(pPower->getType() == CNormalGeneralPower::MODULO);
1929 
1930  const CNormalFraction* pFraction2 = &pPower->getLeft();
1931  CPPUNIT_ASSERT(pFraction2 != NULL);
1932  const CNormalSum& numerator2 = pFraction2->getNumerator();
1933  CPPUNIT_ASSERT(numerator2.getFractions().size() == 0);
1934  const std::set<CNormalProduct*, compareProducts >& products2 = numerator2.getProducts();
1935  CPPUNIT_ASSERT(products2.size() == 1);
1936  pProduct = *(products2.begin());
1937  CPPUNIT_ASSERT(pProduct != NULL);
1938  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
1939  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
1940  pItemPower = *(pProduct->getItemPowers().begin());
1941  CPPUNIT_ASSERT(pItemPower != NULL);
1942  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
1943  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
1944  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
1945  CPPUNIT_ASSERT(pItem != NULL);
1946  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::CONSTANT);
1947  CPPUNIT_ASSERT(pItem->getName() == "PI");
1948 
1949  pFraction2 = &pPower->getRight();
1950  CPPUNIT_ASSERT(pFraction2 != NULL);
1951  const CNormalSum& numerator3 = pFraction2->getNumerator();
1952  CPPUNIT_ASSERT(numerator3.getFractions().size() == 0);
1953  const std::set<CNormalProduct*, compareProducts >& products3 = numerator3.getProducts();
1954  CPPUNIT_ASSERT(products3.size() == 1);
1955  pProduct = *(products3.begin());
1956  CPPUNIT_ASSERT(pProduct != NULL);
1957  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
1958  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
1959  pItemPower = *(pProduct->getItemPowers().begin());
1960  CPPUNIT_ASSERT(pItemPower != NULL);
1961  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
1962  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
1963  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
1964  CPPUNIT_ASSERT(pItem != NULL);
1965  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::CONSTANT);
1966  CPPUNIT_ASSERT(pItem->getName() == "EXPONENTIALE");
1967 }
1968 
1969 void test_normalform::test_generalmodulus_function_and_function()
1970 {
1971  std::string infix("COS(5.0)%SIN(2.0)");
1972  CEvaluationTree* pTree = new CEvaluationTree();
1973  pTree->setInfix(infix);
1974  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
1976  delete pTree;
1977  CPPUNIT_ASSERT(pFraction != NULL);
1978 
1979  const CNormalSum& numerator = pFraction->getNumerator();
1980  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
1981  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
1982  CPPUNIT_ASSERT(products.size() == 1);
1983  const CNormalProduct* pProduct = *(products.begin());
1984  CPPUNIT_ASSERT(pProduct != NULL);
1985  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
1986  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
1987  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
1988  CPPUNIT_ASSERT(pItemPower != NULL);
1989  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
1990  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::POWER);
1991  const CNormalGeneralPower* pPower = dynamic_cast<const CNormalGeneralPower*>(&pItemPower->getItem());
1992  CPPUNIT_ASSERT(pPower != NULL);
1993  CPPUNIT_ASSERT(pPower->getType() == CNormalGeneralPower::MODULO);
1994 
1995  const CNormalFraction* pFraction2 = &pPower->getLeft();
1996  CPPUNIT_ASSERT(pFraction2 != NULL);
1997  const CNormalSum& numerator2 = pFraction2->getNumerator();
1998  CPPUNIT_ASSERT(numerator2.getFractions().size() == 0);
1999  const std::set<CNormalProduct*, compareProducts >& products2 = numerator2.getProducts();
2000  CPPUNIT_ASSERT(products2.size() == 1);
2001  pProduct = *(products2.begin());
2002  CPPUNIT_ASSERT(pProduct != NULL);
2003  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2004  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2005  pItemPower = *(pProduct->getItemPowers().begin());
2006  CPPUNIT_ASSERT(pItemPower != NULL);
2007  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
2008  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::FUNCTION);
2009  const CNormalFunction* pFunction = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
2010  CPPUNIT_ASSERT(pFunction != NULL);
2011  CPPUNIT_ASSERT(pFunction->getType() == CNormalFunction::COS);
2012 
2013  pFraction2 = &pFunction->getFraction();
2014  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
2015  const CNormalSum& numerator3 = pFraction2->getNumerator();
2016  CPPUNIT_ASSERT(numerator3.getFractions().size() == 0);
2017  const std::set<CNormalProduct*, compareProducts >& products3 = numerator3.getProducts();
2018  CPPUNIT_ASSERT(products3.size() == 1);
2019  pProduct = *(products3.begin());
2020  CPPUNIT_ASSERT(pProduct != NULL);
2021  CPPUNIT_ASSERT(pProduct->getFactor() == 5.0);
2022  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
2023 
2024  pFraction2 = &pPower->getRight();
2025  CPPUNIT_ASSERT(pFraction2 != NULL);
2026  const CNormalSum& numerator4 = pFraction2->getNumerator();
2027  CPPUNIT_ASSERT(numerator4.getFractions().size() == 0);
2028  const std::set<CNormalProduct*, compareProducts >& products4 = numerator4.getProducts();
2029  CPPUNIT_ASSERT(products4.size() == 1);
2030  pProduct = *(products4.begin());
2031  CPPUNIT_ASSERT(pProduct != NULL);
2032  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2033  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2034  pItemPower = *(pProduct->getItemPowers().begin());
2035  CPPUNIT_ASSERT(pItemPower != NULL);
2036  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
2037  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::FUNCTION);
2038  pFunction = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
2039  CPPUNIT_ASSERT(pFunction != NULL);
2040  CPPUNIT_ASSERT(pFunction->getType() == CNormalFunction::SIN);
2041 
2042  pFraction2 = &pFunction->getFraction();
2043  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
2044  const CNormalSum& numerator5 = pFraction2->getNumerator();
2045  CPPUNIT_ASSERT(numerator5.getFractions().size() == 0);
2046  const std::set<CNormalProduct*, compareProducts >& products5 = numerator5.getProducts();
2047  CPPUNIT_ASSERT(products5.size() == 1);
2048  pProduct = *(products5.begin());
2049  CPPUNIT_ASSERT(pProduct != NULL);
2050  CPPUNIT_ASSERT(pProduct->getFactor() == 2.0);
2051  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
2052 }
2053 
2054 void test_normalform::test_generalpower_mixed_1()
2055 {
2056  std::string infix("(7.0+X)^FLOOR(PI/2)");
2057  CEvaluationTree* pTree = new CEvaluationTree();
2058  pTree->setInfix(infix);
2059  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
2061  delete pTree;
2062  CPPUNIT_ASSERT(pFraction != NULL);
2063 
2064  const CNormalSum& numerator = pFraction->getNumerator();
2065  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
2066  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
2067  CPPUNIT_ASSERT(products.size() == 1);
2068  const CNormalProduct* pProduct = *(products.begin());
2069  CPPUNIT_ASSERT(pProduct != NULL);
2070  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2071  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2072  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
2073  CPPUNIT_ASSERT(pItemPower != NULL);
2074  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
2075  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::POWER);
2076  const CNormalGeneralPower* pPower = dynamic_cast<const CNormalGeneralPower*>(&pItemPower->getItem());
2077  CPPUNIT_ASSERT(pPower != NULL);
2078  CPPUNIT_ASSERT(pPower->getType() == CNormalGeneralPower::POWER);
2079 
2080  const CNormalFraction* pFraction2 = &pPower->getLeft();
2081  CPPUNIT_ASSERT(pFraction2 != NULL);
2082  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
2083  const CNormalSum& numerator2 = pFraction2->getNumerator();
2084  CPPUNIT_ASSERT(numerator2.getFractions().size() == 0);
2085  const std::set<CNormalProduct*, compareProducts >& products2 = numerator2.getProducts();
2086  CPPUNIT_ASSERT(products2.size() == 2);
2087  ProductIterator it = products2.begin();
2088  pProduct = *(it);
2089  CPPUNIT_ASSERT(pProduct != NULL);
2090  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2091  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2092  pItemPower = *(pProduct->getItemPowers().begin());
2093  CPPUNIT_ASSERT(pItemPower != NULL);
2094  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
2095  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
2096  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
2097  CPPUNIT_ASSERT(pItem != NULL);
2098  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
2099  CPPUNIT_ASSERT(pItem->getName() == "X");
2100  ++it;
2101  pProduct = *(it);
2102  CPPUNIT_ASSERT(pProduct != NULL);
2103  CPPUNIT_ASSERT(pProduct->getFactor() == 7.0);
2104  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
2105 
2106  pFraction2 = &pPower->getRight();
2107  CPPUNIT_ASSERT(pFraction2 != NULL);
2108  const CNormalSum& numerator4 = pFraction2->getNumerator();
2109  CPPUNIT_ASSERT(numerator4.getFractions().size() == 0);
2110  const std::set<CNormalProduct*, compareProducts >& products4 = numerator4.getProducts();
2111  CPPUNIT_ASSERT(products4.size() == 1);
2112  pProduct = *(products4.begin());
2113  CPPUNIT_ASSERT(pProduct != NULL);
2114  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2115  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2116  pItemPower = *(pProduct->getItemPowers().begin());
2117  CPPUNIT_ASSERT(pItemPower != NULL);
2118  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
2119  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::FUNCTION);
2120  const CNormalFunction* pFunction = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
2121  CPPUNIT_ASSERT(pFunction != NULL);
2122  CPPUNIT_ASSERT(pFunction->getType() == CNormalFunction::FLOOR);
2123 
2124  pFraction2 = &pFunction->getFraction();
2125  CPPUNIT_ASSERT(pFraction2 != NULL);
2126  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
2127  const CNormalSum& numerator5 = pFraction2->getNumerator();
2128  CPPUNIT_ASSERT(numerator5.getFractions().size() == 0);
2129  const std::set<CNormalProduct*, compareProducts >& products5 = numerator5.getProducts();
2130  CPPUNIT_ASSERT(products5.size() == 1);
2131  pProduct = *(products5.begin());
2132  CPPUNIT_ASSERT(pProduct != NULL);
2133  CPPUNIT_ASSERT(pProduct->getFactor() == 0.5);
2134  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2135  pItemPower = *pProduct->getItemPowers().begin();
2136  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
2137  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
2138  CPPUNIT_ASSERT(pItem != NULL);
2139  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::CONSTANT);
2140  CPPUNIT_ASSERT(pItem->getName() == "PI");
2141 }
2142 
2143 void test_normalform::test_generalpower_mixed_2()
2144 {
2145  std::string infix("TAN(5.0)^A");
2146  CEvaluationTree* pTree = new CEvaluationTree();
2147  pTree->setInfix(infix);
2148  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
2150  delete pTree;
2151  CPPUNIT_ASSERT(pFraction != NULL);
2152 
2153  const CNormalSum& numerator = pFraction->getNumerator();
2154  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
2155  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
2156  CPPUNIT_ASSERT(products.size() == 1);
2157  const CNormalProduct* pProduct = *(products.begin());
2158  CPPUNIT_ASSERT(pProduct != NULL);
2159  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2160  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2161  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
2162  CPPUNIT_ASSERT(pItemPower != NULL);
2163  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
2164  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::POWER);
2165  const CNormalGeneralPower* pPower = dynamic_cast<const CNormalGeneralPower*>(&pItemPower->getItem());
2166  CPPUNIT_ASSERT(pPower != NULL);
2167  CPPUNIT_ASSERT(pPower->getType() == CNormalGeneralPower::POWER);
2168 
2169  const CNormalFraction* pFraction2 = &pPower->getLeft();
2170  CPPUNIT_ASSERT(pFraction2 != NULL);
2171  const CNormalSum& numerator2 = pFraction2->getNumerator();
2172  CPPUNIT_ASSERT(numerator2.getFractions().size() == 0);
2173  const std::set<CNormalProduct*, compareProducts >& products2 = numerator2.getProducts();
2174  CPPUNIT_ASSERT(products2.size() == 1);
2175  pProduct = *(products2.begin());
2176  CPPUNIT_ASSERT(pProduct != NULL);
2177  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2178  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2179  pItemPower = *(pProduct->getItemPowers().begin());
2180  CPPUNIT_ASSERT(pItemPower != NULL);
2181  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
2182  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::FUNCTION);
2183  const CNormalFunction* pFunction = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
2184  CPPUNIT_ASSERT(pFunction != NULL);
2185  CPPUNIT_ASSERT(pFunction->getType() == CNormalFunction::TAN);
2186 
2187  pFraction2 = &pFunction->getFraction();
2188  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
2189  const CNormalSum& numerator3 = pFraction2->getNumerator();
2190  CPPUNIT_ASSERT(numerator3.getFractions().size() == 0);
2191  const std::set<CNormalProduct*, compareProducts >& products3 = numerator3.getProducts();
2192  CPPUNIT_ASSERT(products3.size() == 1);
2193  pProduct = *(products3.begin());
2194  CPPUNIT_ASSERT(pProduct != NULL);
2195  CPPUNIT_ASSERT(pProduct->getFactor() == 5.0);
2196  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
2197 
2198  pFraction2 = &pPower->getRight();
2199  CPPUNIT_ASSERT(pFraction2 != NULL);
2200  const CNormalSum& numerator4 = pFraction2->getNumerator();
2201  CPPUNIT_ASSERT(numerator4.getFractions().size() == 0);
2202  const std::set<CNormalProduct*, compareProducts >& products4 = numerator4.getProducts();
2203  CPPUNIT_ASSERT(products4.size() == 1);
2204  pProduct = *(products4.begin());
2205  CPPUNIT_ASSERT(pProduct != NULL);
2206  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2207  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2208  pItemPower = *(pProduct->getItemPowers().begin());
2209  CPPUNIT_ASSERT(pItemPower != NULL);
2210  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
2211  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
2212  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
2213  CPPUNIT_ASSERT(pItem != NULL);
2214  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
2215  CPPUNIT_ASSERT(pItem->getName() == "A");
2216 }
2217 
2218 void test_normalform::test_generalpower_mixed_3()
2219 {
2220  std::string infix("A^CEIL(PI)");
2221  CEvaluationTree* pTree = new CEvaluationTree();
2222  pTree->setInfix(infix);
2223  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
2225  delete pTree;
2226  CPPUNIT_ASSERT(pFraction != NULL);
2227 
2228  const CNormalSum& numerator = pFraction->getNumerator();
2229  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
2230  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
2231  CPPUNIT_ASSERT(products.size() == 1);
2232  const CNormalProduct* pProduct = *(products.begin());
2233  CPPUNIT_ASSERT(pProduct != NULL);
2234  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2235  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2236  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
2237  CPPUNIT_ASSERT(pItemPower != NULL);
2238  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
2239  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::POWER);
2240  const CNormalGeneralPower* pPower = dynamic_cast<const CNormalGeneralPower*>(&pItemPower->getItem());
2241  CPPUNIT_ASSERT(pPower != NULL);
2242  CPPUNIT_ASSERT(pPower->getType() == CNormalGeneralPower::POWER);
2243 
2244  const CNormalFraction* pFraction2 = &pPower->getLeft();
2245  CPPUNIT_ASSERT(pFraction2 != NULL);
2246  const CNormalSum& numerator2 = pFraction2->getNumerator();
2247  CPPUNIT_ASSERT(numerator2.getFractions().size() == 0);
2248  const std::set<CNormalProduct*, compareProducts >& products2 = numerator2.getProducts();
2249  CPPUNIT_ASSERT(products2.size() == 1);
2250  pProduct = *(products2.begin());
2251  CPPUNIT_ASSERT(pProduct != NULL);
2252  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2253  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2254  pItemPower = *(pProduct->getItemPowers().begin());
2255  CPPUNIT_ASSERT(pItemPower != NULL);
2256  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
2257  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
2258  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
2259  CPPUNIT_ASSERT(pItem != NULL);
2260  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
2261  CPPUNIT_ASSERT(pItem->getName() == "A");
2262 
2263  pFraction2 = &pPower->getRight();
2264  CPPUNIT_ASSERT(pFraction2 != NULL);
2265  const CNormalSum& numerator4 = pFraction2->getNumerator();
2266  CPPUNIT_ASSERT(numerator4.getFractions().size() == 0);
2267  const std::set<CNormalProduct*, compareProducts >& products4 = numerator4.getProducts();
2268  CPPUNIT_ASSERT(products4.size() == 1);
2269  pProduct = *(products4.begin());
2270  CPPUNIT_ASSERT(pProduct != NULL);
2271  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2272  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2273  pItemPower = *(pProduct->getItemPowers().begin());
2274  CPPUNIT_ASSERT(pItemPower != NULL);
2275  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
2276  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::FUNCTION);
2277  const CNormalFunction* pFunction = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
2278  CPPUNIT_ASSERT(pFunction != NULL);
2279  CPPUNIT_ASSERT(pFunction->getType() == CNormalFunction::CEIL);
2280 
2281  pFraction2 = &pFunction->getFraction();
2282  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
2283  const CNormalSum& numerator5 = pFraction2->getNumerator();
2284  CPPUNIT_ASSERT(numerator5.getFractions().size() == 0);
2285  const std::set<CNormalProduct*, compareProducts >& products5 = numerator5.getProducts();
2286  CPPUNIT_ASSERT(products5.size() == 1);
2287  pProduct = *(products5.begin());
2288  CPPUNIT_ASSERT(pProduct != NULL);
2289  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2290  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2291  pItemPower = *pProduct->getItemPowers().begin();
2292  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
2293  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
2294  CPPUNIT_ASSERT(pItem != NULL);
2295  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::CONSTANT);
2296  CPPUNIT_ASSERT(pItem->getName() == "PI");
2297 }
2298 
2299 void test_normalform::test_generalpower_mixed_4()
2300 {
2301  std::string infix("EXPONENTIALE^A");
2302  CEvaluationTree* pTree = new CEvaluationTree();
2303  pTree->setInfix(infix);
2304  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
2306  delete pTree;
2307  CPPUNIT_ASSERT(pFraction != NULL);
2308 
2309  const CNormalSum& numerator = pFraction->getNumerator();
2310  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
2311  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
2312  CPPUNIT_ASSERT(products.size() == 1);
2313  const CNormalProduct* pProduct = *(products.begin());
2314  CPPUNIT_ASSERT(pProduct != NULL);
2315  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2316  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2317  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
2318  CPPUNIT_ASSERT(pItemPower != NULL);
2319  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
2320  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::POWER);
2321  const CNormalGeneralPower* pPower = dynamic_cast<const CNormalGeneralPower*>(&pItemPower->getItem());
2322  CPPUNIT_ASSERT(pPower != NULL);
2323  CPPUNIT_ASSERT(pPower->getType() == CNormalGeneralPower::POWER);
2324 
2325  const CNormalFraction* pFraction2 = &pPower->getLeft();
2326  CPPUNIT_ASSERT(pFraction2 != NULL);
2327  const CNormalSum& numerator2 = pFraction2->getNumerator();
2328  CPPUNIT_ASSERT(numerator2.getFractions().size() == 0);
2329  const std::set<CNormalProduct*, compareProducts >& products2 = numerator2.getProducts();
2330  CPPUNIT_ASSERT(products2.size() == 1);
2331  pProduct = *(products2.begin());
2332  CPPUNIT_ASSERT(pProduct != NULL);
2333  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2334  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2335  pItemPower = *(pProduct->getItemPowers().begin());
2336  CPPUNIT_ASSERT(pItemPower != NULL);
2337  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
2338  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
2339  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
2340  CPPUNIT_ASSERT(pItem != NULL);
2341  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::CONSTANT);
2342  CPPUNIT_ASSERT(pItem->getName() == "EXPONENTIALE");
2343 
2344  pFraction2 = &pPower->getRight();
2345  CPPUNIT_ASSERT(pFraction2 != NULL);
2346  const CNormalSum& numerator3 = pFraction2->getNumerator();
2347  CPPUNIT_ASSERT(numerator3.getFractions().size() == 0);
2348  const std::set<CNormalProduct*, compareProducts >& products3 = numerator3.getProducts();
2349  CPPUNIT_ASSERT(products3.size() == 1);
2350  pProduct = *(products3.begin());
2351  CPPUNIT_ASSERT(pProduct != NULL);
2352  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2353  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2354  pItemPower = *(pProduct->getItemPowers().begin());
2355  CPPUNIT_ASSERT(pItemPower != NULL);
2356  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
2357  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
2358  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
2359  CPPUNIT_ASSERT(pItem != NULL);
2360  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
2361  CPPUNIT_ASSERT(pItem->getName() == "A");
2362 }
2363 
2364 void test_normalform::test_generalmodulus_mixed_1()
2365 {
2366  std::string infix("(7.0+X)%FLOOR(PI/2)");
2367  CEvaluationTree* pTree = new CEvaluationTree();
2368  pTree->setInfix(infix);
2369  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
2371  delete pTree;
2372  CPPUNIT_ASSERT(pFraction != NULL);
2373 
2374  const CNormalSum& numerator = pFraction->getNumerator();
2375  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
2376  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
2377  CPPUNIT_ASSERT(products.size() == 1);
2378  const CNormalProduct* pProduct = *(products.begin());
2379  CPPUNIT_ASSERT(pProduct != NULL);
2380  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2381  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2382  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
2383  CPPUNIT_ASSERT(pItemPower != NULL);
2384  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
2385  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::POWER);
2386  const CNormalGeneralPower* pPower = dynamic_cast<const CNormalGeneralPower*>(&pItemPower->getItem());
2387  CPPUNIT_ASSERT(pPower != NULL);
2388  CPPUNIT_ASSERT(pPower->getType() == CNormalGeneralPower::MODULO);
2389 
2390  const CNormalFraction* pFraction2 = &pPower->getLeft();
2391  CPPUNIT_ASSERT(pFraction2 != NULL);
2392  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
2393  const CNormalSum& numerator2 = pFraction2->getNumerator();
2394  CPPUNIT_ASSERT(numerator2.getFractions().size() == 0);
2395  const std::set<CNormalProduct*, compareProducts >& products2 = numerator2.getProducts();
2396  CPPUNIT_ASSERT(products2.size() == 2);
2397  ProductIterator it = products2.begin();
2398  pProduct = *(it);
2399  CPPUNIT_ASSERT(pProduct != NULL);
2400  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2401  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2402  pItemPower = *(pProduct->getItemPowers().begin());
2403  CPPUNIT_ASSERT(pItemPower != NULL);
2404  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
2405  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
2406  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
2407  CPPUNIT_ASSERT(pItem != NULL);
2408  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
2409  CPPUNIT_ASSERT(pItem->getName() == "X");
2410  ++it;
2411  pProduct = *(it);
2412  CPPUNIT_ASSERT(pProduct != NULL);
2413  CPPUNIT_ASSERT(pProduct->getFactor() == 7.0);
2414  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
2415 
2416  pFraction2 = &pPower->getRight();
2417  CPPUNIT_ASSERT(pFraction2 != NULL);
2418  const CNormalSum& numerator4 = pFraction2->getNumerator();
2419  CPPUNIT_ASSERT(numerator4.getFractions().size() == 0);
2420  const std::set<CNormalProduct*, compareProducts >& products4 = numerator4.getProducts();
2421  CPPUNIT_ASSERT(products4.size() == 1);
2422  pProduct = *(products4.begin());
2423  CPPUNIT_ASSERT(pProduct != NULL);
2424  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2425  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2426  pItemPower = *(pProduct->getItemPowers().begin());
2427  CPPUNIT_ASSERT(pItemPower != NULL);
2428  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
2429  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::FUNCTION);
2430  const CNormalFunction* pFunction = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
2431  CPPUNIT_ASSERT(pFunction != NULL);
2432  CPPUNIT_ASSERT(pFunction->getType() == CNormalFunction::FLOOR);
2433 
2434  pFraction2 = &pFunction->getFraction();
2435  CPPUNIT_ASSERT(pFraction2 != NULL);
2436  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
2437  const CNormalSum& numerator5 = pFraction2->getNumerator();
2438  CPPUNIT_ASSERT(numerator5.getFractions().size() == 0);
2439  const std::set<CNormalProduct*, compareProducts >& products5 = numerator5.getProducts();
2440  CPPUNIT_ASSERT(products5.size() == 1);
2441  pProduct = *(products5.begin());
2442  CPPUNIT_ASSERT(pProduct != NULL);
2443  CPPUNIT_ASSERT(pProduct->getFactor() == 0.5);
2444  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2445  pItemPower = *pProduct->getItemPowers().begin();
2446  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
2447  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
2448  CPPUNIT_ASSERT(pItem != NULL);
2449  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::CONSTANT);
2450  CPPUNIT_ASSERT(pItem->getName() == "PI");
2451 }
2452 
2453 void test_normalform::test_generalmodulus_mixed_2()
2454 {
2455  std::string infix("TAN(5.0)%A");
2456  CEvaluationTree* pTree = new CEvaluationTree();
2457  pTree->setInfix(infix);
2458  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
2460  delete pTree;
2461  CPPUNIT_ASSERT(pFraction != NULL);
2462 
2463  const CNormalSum& numerator = pFraction->getNumerator();
2464  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
2465  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
2466  CPPUNIT_ASSERT(products.size() == 1);
2467  const CNormalProduct* pProduct = *(products.begin());
2468  CPPUNIT_ASSERT(pProduct != NULL);
2469  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2470  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2471  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
2472  CPPUNIT_ASSERT(pItemPower != NULL);
2473  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
2474  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::POWER);
2475  const CNormalGeneralPower* pPower = dynamic_cast<const CNormalGeneralPower*>(&pItemPower->getItem());
2476  CPPUNIT_ASSERT(pPower != NULL);
2477  CPPUNIT_ASSERT(pPower->getType() == CNormalGeneralPower::MODULO);
2478 
2479  const CNormalFraction* pFraction2 = &pPower->getLeft();
2480  CPPUNIT_ASSERT(pFraction2 != NULL);
2481  const CNormalSum& numerator2 = pFraction2->getNumerator();
2482  CPPUNIT_ASSERT(numerator2.getFractions().size() == 0);
2483  const std::set<CNormalProduct*, compareProducts >& products2 = numerator2.getProducts();
2484  CPPUNIT_ASSERT(products2.size() == 1);
2485  pProduct = *(products2.begin());
2486  CPPUNIT_ASSERT(pProduct != NULL);
2487  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2488  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2489  pItemPower = *(pProduct->getItemPowers().begin());
2490  CPPUNIT_ASSERT(pItemPower != NULL);
2491  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
2492  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::FUNCTION);
2493  const CNormalFunction* pFunction = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
2494  CPPUNIT_ASSERT(pFunction != NULL);
2495  CPPUNIT_ASSERT(pFunction->getType() == CNormalFunction::TAN);
2496 
2497  pFraction2 = &pFunction->getFraction();
2498  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
2499  const CNormalSum& numerator3 = pFraction2->getNumerator();
2500  CPPUNIT_ASSERT(numerator3.getFractions().size() == 0);
2501  const std::set<CNormalProduct*, compareProducts >& products3 = numerator3.getProducts();
2502  CPPUNIT_ASSERT(products3.size() == 1);
2503  pProduct = *(products3.begin());
2504  CPPUNIT_ASSERT(pProduct != NULL);
2505  CPPUNIT_ASSERT(pProduct->getFactor() == 5.0);
2506  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
2507 
2508  pFraction2 = &pPower->getRight();
2509  CPPUNIT_ASSERT(pFraction2 != NULL);
2510  const CNormalSum& numerator4 = pFraction2->getNumerator();
2511  CPPUNIT_ASSERT(numerator4.getFractions().size() == 0);
2512  const std::set<CNormalProduct*, compareProducts >& products4 = numerator4.getProducts();
2513  CPPUNIT_ASSERT(products4.size() == 1);
2514  pProduct = *(products4.begin());
2515  CPPUNIT_ASSERT(pProduct != NULL);
2516  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2517  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2518  pItemPower = *(pProduct->getItemPowers().begin());
2519  CPPUNIT_ASSERT(pItemPower != NULL);
2520  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
2521  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
2522  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
2523  CPPUNIT_ASSERT(pItem != NULL);
2524  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
2525  CPPUNIT_ASSERT(pItem->getName() == "A");
2526 }
2527 
2528 void test_normalform::test_generalmodulus_mixed_3()
2529 {
2530  std::string infix("A%CEIL(PI)");
2531  CEvaluationTree* pTree = new CEvaluationTree();
2532  pTree->setInfix(infix);
2533  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
2535  delete pTree;
2536  CPPUNIT_ASSERT(pFraction != NULL);
2537 
2538  const CNormalSum& numerator = pFraction->getNumerator();
2539  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
2540  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
2541  CPPUNIT_ASSERT(products.size() == 1);
2542  const CNormalProduct* pProduct = *(products.begin());
2543  CPPUNIT_ASSERT(pProduct != NULL);
2544  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2545  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2546  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
2547  CPPUNIT_ASSERT(pItemPower != NULL);
2548  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
2549  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::POWER);
2550  const CNormalGeneralPower* pPower = dynamic_cast<const CNormalGeneralPower*>(&pItemPower->getItem());
2551  CPPUNIT_ASSERT(pPower != NULL);
2552  CPPUNIT_ASSERT(pPower->getType() == CNormalGeneralPower::MODULO);
2553 
2554  const CNormalFraction* pFraction2 = &pPower->getLeft();
2555  CPPUNIT_ASSERT(pFraction2 != NULL);
2556  const CNormalSum& numerator2 = pFraction2->getNumerator();
2557  CPPUNIT_ASSERT(numerator2.getFractions().size() == 0);
2558  const std::set<CNormalProduct*, compareProducts >& products2 = numerator2.getProducts();
2559  CPPUNIT_ASSERT(products2.size() == 1);
2560  pProduct = *(products2.begin());
2561  CPPUNIT_ASSERT(pProduct != NULL);
2562  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2563  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2564  pItemPower = *(pProduct->getItemPowers().begin());
2565  CPPUNIT_ASSERT(pItemPower != NULL);
2566  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
2567  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
2568  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
2569  CPPUNIT_ASSERT(pItem != NULL);
2570  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
2571  CPPUNIT_ASSERT(pItem->getName() == "A");
2572 
2573  pFraction2 = &pPower->getRight();
2574  CPPUNIT_ASSERT(pFraction2 != NULL);
2575  const CNormalSum& numerator4 = pFraction2->getNumerator();
2576  CPPUNIT_ASSERT(numerator4.getFractions().size() == 0);
2577  const std::set<CNormalProduct*, compareProducts >& products4 = numerator4.getProducts();
2578  CPPUNIT_ASSERT(products4.size() == 1);
2579  pProduct = *(products4.begin());
2580  CPPUNIT_ASSERT(pProduct != NULL);
2581  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2582  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2583  pItemPower = *(pProduct->getItemPowers().begin());
2584  CPPUNIT_ASSERT(pItemPower != NULL);
2585  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
2586  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::FUNCTION);
2587  const CNormalFunction* pFunction = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
2588  CPPUNIT_ASSERT(pFunction != NULL);
2589  CPPUNIT_ASSERT(pFunction->getType() == CNormalFunction::CEIL);
2590 
2591  pFraction2 = &pFunction->getFraction();
2592  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
2593  const CNormalSum& numerator5 = pFraction2->getNumerator();
2594  CPPUNIT_ASSERT(numerator5.getFractions().size() == 0);
2595  const std::set<CNormalProduct*, compareProducts >& products5 = numerator5.getProducts();
2596  CPPUNIT_ASSERT(products5.size() == 1);
2597  pProduct = *(products5.begin());
2598  CPPUNIT_ASSERT(pProduct != NULL);
2599  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2600  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2601  pItemPower = *pProduct->getItemPowers().begin();
2602  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
2603  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
2604  CPPUNIT_ASSERT(pItem != NULL);
2605  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::CONSTANT);
2606  CPPUNIT_ASSERT(pItem->getName() == "PI");
2607 }
2608 
2609 void test_normalform::test_generalmodulus_mixed_4()
2610 {
2611  std::string infix("EXPONENTIALE%A");
2612  CEvaluationTree* pTree = new CEvaluationTree();
2613  pTree->setInfix(infix);
2614  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
2616  delete pTree;
2617  CPPUNIT_ASSERT(pFraction != NULL);
2618 
2619  const CNormalSum& numerator = pFraction->getNumerator();
2620  CPPUNIT_ASSERT(numerator.getFractions().size() == 0);
2621  const std::set<CNormalProduct*, compareProducts >& products = numerator.getProducts();
2622  CPPUNIT_ASSERT(products.size() == 1);
2623  const CNormalProduct* pProduct = *(products.begin());
2624  CPPUNIT_ASSERT(pProduct != NULL);
2625  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2626  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2627  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
2628  CPPUNIT_ASSERT(pItemPower != NULL);
2629  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
2630  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::POWER);
2631  const CNormalGeneralPower* pPower = dynamic_cast<const CNormalGeneralPower*>(&pItemPower->getItem());
2632  CPPUNIT_ASSERT(pPower != NULL);
2633  CPPUNIT_ASSERT(pPower->getType() == CNormalGeneralPower::MODULO);
2634 
2635  const CNormalFraction* pFraction2 = &pPower->getLeft();
2636  CPPUNIT_ASSERT(pFraction2 != NULL);
2637  const CNormalSum& numerator2 = pFraction2->getNumerator();
2638  CPPUNIT_ASSERT(numerator2.getFractions().size() == 0);
2639  const std::set<CNormalProduct*, compareProducts >& products2 = numerator2.getProducts();
2640  CPPUNIT_ASSERT(products2.size() == 1);
2641  pProduct = *(products2.begin());
2642  CPPUNIT_ASSERT(pProduct != NULL);
2643  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2644  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2645  pItemPower = *(pProduct->getItemPowers().begin());
2646  CPPUNIT_ASSERT(pItemPower != NULL);
2647  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
2648  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
2649  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
2650  CPPUNIT_ASSERT(pItem != NULL);
2651  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::CONSTANT);
2652  CPPUNIT_ASSERT(pItem->getName() == "EXPONENTIALE");
2653 
2654  pFraction2 = &pPower->getRight();
2655  CPPUNIT_ASSERT(pFraction2 != NULL);
2656  const CNormalSum& numerator3 = pFraction2->getNumerator();
2657  CPPUNIT_ASSERT(numerator3.getFractions().size() == 0);
2658  const std::set<CNormalProduct*, compareProducts >& products3 = numerator3.getProducts();
2659  CPPUNIT_ASSERT(products3.size() == 1);
2660  pProduct = *(products3.begin());
2661  CPPUNIT_ASSERT(pProduct != NULL);
2662  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2663  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2664  pItemPower = *(pProduct->getItemPowers().begin());
2665  CPPUNIT_ASSERT(pItemPower != NULL);
2666  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
2667  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
2668  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
2669  CPPUNIT_ASSERT(pItem != NULL);
2670  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
2671  CPPUNIT_ASSERT(pItem->getName() == "A");
2672 }
2673 
2674 void test_normalform::test_simple_stepwise_numbers()
2675 {
2676  std::string infix("IF(TRUE,2.3,4.5)");
2677  CEvaluationTree* pTree = new CEvaluationTree();
2678  pTree->setInfix(infix);
2679  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
2681  delete pTree;
2682  CPPUNIT_ASSERT(pFraction != NULL);
2683  CPPUNIT_ASSERT(pFraction->checkDenominatorOne() == true);
2684 
2685  const CNormalSum* numerator = &pFraction->getNumerator();
2686  CPPUNIT_ASSERT(numerator->getFractions().size() == 0);
2687  const std::set<CNormalProduct*, compareProducts >* products = &numerator->getProducts();
2688  CPPUNIT_ASSERT(products->size() == 1);
2689  const CNormalProduct* pProduct = *(products->begin());
2690  CPPUNIT_ASSERT(pProduct != NULL);
2691  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2692  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2693  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
2694  CPPUNIT_ASSERT(pItemPower != NULL);
2695  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
2696  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::CHOICE);
2697  const CNormalChoice* pChoice = dynamic_cast<const CNormalChoice*>(&pItemPower->getItem());
2698  CPPUNIT_ASSERT(pChoice != NULL);
2699 
2700  // check the condition
2701  const CNormalLogical* pLogical = &pChoice->getCondition();
2702  CPPUNIT_ASSERT(pLogical != NULL);
2703  CPPUNIT_ASSERT(pLogical->isNegated() == false);
2704  CPPUNIT_ASSERT(pLogical->getChoices().size() == 0);
2705  CPPUNIT_ASSERT(pLogical->getAndSets().size() == 1);
2706  std::pair<CNormalLogical::ItemSet, bool> outerpair = *(pLogical->getAndSets().begin());
2707  CPPUNIT_ASSERT(outerpair.second == false);
2708  CPPUNIT_ASSERT(outerpair.first.size() == 1);
2709  std::pair<CNormalLogicalItem*, bool> innerpair = *(outerpair.first.begin());
2710  CPPUNIT_ASSERT(innerpair.second == false);
2711  const CNormalLogicalItem* pLogicalItem = innerpair.first;
2712  CPPUNIT_ASSERT(pLogicalItem != NULL);
2713  CPPUNIT_ASSERT(pLogicalItem->getType() == CNormalLogicalItem::TRUE);
2714  pItemPower = *(pProduct->getItemPowers().begin());
2715  CPPUNIT_ASSERT(pItemPower != NULL);
2716  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
2717  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::CHOICE);
2718 
2719  // check the true branch
2720  const CNormalFraction* pFraction2 = &pChoice->getTrueExpression();
2721  CPPUNIT_ASSERT(pFraction2 != NULL);
2722  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
2723  numerator = &pFraction2->getNumerator();
2724  CPPUNIT_ASSERT(numerator->getFractions().size() == 0);
2725  products = &numerator->getProducts();
2726  CPPUNIT_ASSERT(products->size() == 1);
2727  pProduct = *(products->begin());
2728  CPPUNIT_ASSERT(pProduct != NULL);
2729  CPPUNIT_ASSERT(pProduct->getFactor() == 2.3);
2730  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
2731 
2732  // check the false branch
2733  pFraction2 = &pChoice->getFalseExpression();
2734  CPPUNIT_ASSERT(pFraction2 != NULL);
2735  numerator = &pFraction2->getNumerator();
2736  CPPUNIT_ASSERT(numerator->getFractions().size() == 0);
2737  products = &numerator->getProducts();
2738  CPPUNIT_ASSERT(products->size() == 1);
2739  pProduct = *(products->begin());
2740  CPPUNIT_ASSERT(pProduct != NULL);
2741  CPPUNIT_ASSERT(pProduct->getFactor() == 4.5);
2742  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
2743 }
2744 
2745 void test_normalform::test_simple_stepwise_fractions()
2746 {
2747  std::string infix("IF(TRUE,A/TAN(X)^R,SIN(PI)/A^6)");
2748  CEvaluationTree* pTree = new CEvaluationTree();
2749  pTree->setInfix(infix);
2750  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
2752  delete pTree;
2753  CPPUNIT_ASSERT(pFraction != NULL);
2754  CPPUNIT_ASSERT(pFraction->checkDenominatorOne() == true);
2755 
2756  const CNormalSum* numerator = &pFraction->getNumerator();
2757  CPPUNIT_ASSERT(numerator->getFractions().size() == 0);
2758  const std::set<CNormalProduct*, compareProducts >* products = &numerator->getProducts();
2759  CPPUNIT_ASSERT(products->size() == 1);
2760  const CNormalProduct* pProduct = *(products->begin());
2761  CPPUNIT_ASSERT(pProduct != NULL);
2762  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2763  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2764  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
2765  CPPUNIT_ASSERT(pItemPower != NULL);
2766  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
2767  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::CHOICE);
2768  const CNormalChoice* pChoice = dynamic_cast<const CNormalChoice*>(&pItemPower->getItem());
2769  CPPUNIT_ASSERT(pChoice != NULL);
2770 
2771  // check the condition
2772  const CNormalLogical* pLogical = &pChoice->getCondition();
2773  CPPUNIT_ASSERT(pLogical != NULL);
2774  CPPUNIT_ASSERT(pLogical->isNegated() == false);
2775  CPPUNIT_ASSERT(pLogical->getChoices().size() == 0);
2776  CPPUNIT_ASSERT(pLogical->getAndSets().size() == 1);
2777  std::pair<CNormalLogical::ItemSet, bool> outerpair = *(pLogical->getAndSets().begin());
2778  CPPUNIT_ASSERT(outerpair.second == false);
2779  CPPUNIT_ASSERT(outerpair.first.size() == 1);
2780  std::pair<CNormalLogicalItem*, bool> innerpair = *(outerpair.first.begin());
2781  CPPUNIT_ASSERT(innerpair.second == false);
2782  const CNormalLogicalItem* pLogicalItem = innerpair.first;
2783  CPPUNIT_ASSERT(pLogicalItem != NULL);
2784  CPPUNIT_ASSERT(pLogicalItem->getType() == CNormalLogicalItem::TRUE);
2785 
2786  // check the true branch
2787  const CNormalFraction* pFraction2 = &pChoice->getTrueExpression();
2788  CPPUNIT_ASSERT(pFraction2 != NULL);
2789  numerator = &pFraction2->getNumerator();
2790  CPPUNIT_ASSERT(numerator->getFractions().size() == 0);
2791  products = &numerator->getProducts();
2792  CPPUNIT_ASSERT(products->size() == 1);
2793  pProduct = *(products->begin());
2794  CPPUNIT_ASSERT(pProduct != NULL);
2795  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2796  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2797  pItemPower = *(pProduct->getItemPowers().begin());
2798  CPPUNIT_ASSERT(pItemPower != NULL);
2799  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
2800  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
2801  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
2802  CPPUNIT_ASSERT(pItem != NULL);
2803  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
2804  CPPUNIT_ASSERT(pItem->getName() == "A");
2805  const CNormalSum* denominator = &pFraction2->getDenominator();
2806  CPPUNIT_ASSERT(denominator->getFractions().size() == 0);
2807  products = &denominator->getProducts();
2808  CPPUNIT_ASSERT(products->size() == 1);
2809  pProduct = *(products->begin());
2810  CPPUNIT_ASSERT(pProduct != NULL);
2811  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2812  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2813  pItemPower = *(pProduct->getItemPowers().begin());
2814  CPPUNIT_ASSERT(pItemPower != NULL);
2815  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
2816  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::POWER);
2817  const CNormalGeneralPower* pGeneralPower = dynamic_cast<const CNormalGeneralPower*>(&pItemPower->getItem());
2818  CPPUNIT_ASSERT(pGeneralPower != NULL);
2819  CPPUNIT_ASSERT(pGeneralPower->getType() == CNormalGeneralPower::POWER);
2820  pFraction2 = &pGeneralPower->getLeft();
2821  CPPUNIT_ASSERT(pFraction2 != NULL);
2822  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
2823  numerator = &pFraction2->getNumerator();
2824  CPPUNIT_ASSERT(numerator->getFractions().size() == 0);
2825  products = &numerator->getProducts();
2826  CPPUNIT_ASSERT(products->size() == 1);
2827  pProduct = *(products->begin());
2828  CPPUNIT_ASSERT(pProduct != NULL);
2829  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2830  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2831  pItemPower = *(pProduct->getItemPowers().begin());
2832  CPPUNIT_ASSERT(pItemPower != NULL);
2833  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
2834  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::FUNCTION);
2835  const CNormalFunction* pFunction = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
2836  CPPUNIT_ASSERT(pFunction != NULL);
2837  CPPUNIT_ASSERT(pFunction->getType() == CNormalFunction::TAN);
2838  pFraction2 = &pFunction->getFraction();
2839  CPPUNIT_ASSERT(pFraction2 != NULL);
2840  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
2841  numerator = &pFraction2->getNumerator();
2842  CPPUNIT_ASSERT(numerator->getFractions().size() == 0);
2843  products = &numerator->getProducts();
2844  CPPUNIT_ASSERT(products->size() == 1);
2845  pProduct = *(products->begin());
2846  CPPUNIT_ASSERT(pProduct != NULL);
2847  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2848  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2849  pItemPower = *(pProduct->getItemPowers().begin());
2850  CPPUNIT_ASSERT(pItemPower != NULL);
2851  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
2852  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
2853  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
2854  CPPUNIT_ASSERT(pItem != NULL);
2855  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
2856  CPPUNIT_ASSERT(pItem->getName() == "X");
2857  pFraction2 = &pGeneralPower->getRight();
2858  CPPUNIT_ASSERT(pFraction2 != NULL);
2859  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
2860  numerator = &pFraction2->getNumerator();
2861  CPPUNIT_ASSERT(numerator->getFractions().size() == 0);
2862  products = &numerator->getProducts();
2863  CPPUNIT_ASSERT(products->size() == 1);
2864  pProduct = *(products->begin());
2865  CPPUNIT_ASSERT(pProduct != NULL);
2866  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2867  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2868  pItemPower = *(pProduct->getItemPowers().begin());
2869  CPPUNIT_ASSERT(pItemPower != NULL);
2870  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
2871  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
2872  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
2873  CPPUNIT_ASSERT(pItem != NULL);
2874  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
2875  CPPUNIT_ASSERT(pItem->getName() == "R");
2876 
2877  // check false branch
2878  pFraction2 = &pChoice->getFalseExpression();
2879  CPPUNIT_ASSERT(pFraction2 != NULL);
2880  numerator = &pFraction2->getNumerator();
2881  CPPUNIT_ASSERT(numerator->getFractions().size() == 0);
2882  products = &numerator->getProducts();
2883  CPPUNIT_ASSERT(products->size() == 1);
2884  pProduct = *(products->begin());
2885  CPPUNIT_ASSERT(pProduct != NULL);
2886  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2887  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2888  pItemPower = *(pProduct->getItemPowers().begin());
2889  CPPUNIT_ASSERT(pItemPower != NULL);
2890  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
2891  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::FUNCTION);
2892  pFunction = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
2893  CPPUNIT_ASSERT(pFunction != NULL);
2894  CPPUNIT_ASSERT(pFunction->getType() == CNormalFunction::SIN);
2895  pFraction2 = &pFunction->getFraction();
2896  CPPUNIT_ASSERT(pFraction2 != NULL);
2897  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
2898  numerator = &pFraction2->getNumerator();
2899  CPPUNIT_ASSERT(numerator->getFractions().size() == 0);
2900  products = &numerator->getProducts();
2901  CPPUNIT_ASSERT(products->size() == 1);
2902  pProduct = *(products->begin());
2903  CPPUNIT_ASSERT(pProduct != NULL);
2904  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2905  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2906  pItemPower = *(pProduct->getItemPowers().begin());
2907  CPPUNIT_ASSERT(pItemPower != NULL);
2908  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
2909  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
2910  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
2911  CPPUNIT_ASSERT(pItem != NULL);
2912  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::CONSTANT);
2913  CPPUNIT_ASSERT(pItem->getName() == "PI");
2914 
2915  // set pFraction2 again since it has been set to the fraction of the function
2916  // above
2917  pFraction2 = &pChoice->getFalseExpression();
2918  denominator = &pFraction2->getDenominator();
2919  CPPUNIT_ASSERT(denominator->getFractions().size() == 0);
2920  products = &denominator->getProducts();
2921  CPPUNIT_ASSERT(products->size() == 1);
2922  pProduct = *(products->begin());
2923  CPPUNIT_ASSERT(pProduct != NULL);
2924  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2925  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2926  pItemPower = *(pProduct->getItemPowers().begin());
2927  CPPUNIT_ASSERT(pItemPower != NULL);
2928  CPPUNIT_ASSERT(pItemPower->getExp() == 6.0);
2929  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
2930  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
2931  CPPUNIT_ASSERT(pItem != NULL);
2932  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
2933  CPPUNIT_ASSERT(pItem->getName() == "A");
2934 }
2935 
2936 void test_normalform::test_simple_nested_stepwise_numbers()
2937 {
2938  std::string infix("IF(IF(IF(TRUE,FALSE,TRUE),IF(FALSE,TRUE,FALSE),IF(FALSE,FALSE,FALSE)),2.3,4.5)");
2939  CEvaluationTree* pTree = new CEvaluationTree();
2940  pTree->setInfix(infix);
2941  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
2943  delete pTree;
2944  CPPUNIT_ASSERT(pFraction != NULL);
2945  CPPUNIT_ASSERT(pFraction->checkDenominatorOne() == true);
2946 
2947  const CNormalSum* numerator = &pFraction->getNumerator();
2948  CPPUNIT_ASSERT(numerator->getFractions().size() == 0);
2949  const std::set<CNormalProduct*, compareProducts >* products = &numerator->getProducts();
2950  CPPUNIT_ASSERT(products->size() == 1);
2951  const CNormalProduct* pProduct = *(products->begin());
2952  CPPUNIT_ASSERT(pProduct != NULL);
2953  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
2954  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
2955  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
2956  CPPUNIT_ASSERT(pItemPower != NULL);
2957  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
2958  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::CHOICE);
2959  const CNormalChoice* pChoice = dynamic_cast<const CNormalChoice*>(&pItemPower->getItem());
2960  CPPUNIT_ASSERT(pChoice != NULL);
2961 
2962  // check the condition
2963  const CNormalLogical* pLogical = &pChoice->getCondition();
2964  CPPUNIT_ASSERT(pLogical != NULL);
2965  CPPUNIT_ASSERT(pLogical->isNegated() == false);
2966  CPPUNIT_ASSERT(pLogical->getChoices().size() == 0);
2967  CPPUNIT_ASSERT(pLogical->getAndSets().size() == 1);
2968  std::pair<CNormalLogical::ItemSet, bool> outerpair = *(pLogical->getAndSets().begin());
2969  CPPUNIT_ASSERT(outerpair.second == false);
2970  CPPUNIT_ASSERT(outerpair.first.size() == 1);
2971  std::pair<CNormalLogicalItem*, bool> innerpair = *(outerpair.first.begin());
2972  CPPUNIT_ASSERT(innerpair.second == false);
2973  const CNormalLogicalItem* pLogicalItem = innerpair.first;
2974  CPPUNIT_ASSERT(pLogicalItem != NULL);
2975  CPPUNIT_ASSERT(pLogicalItem->getType() == CNormalLogicalItem::FALSE);
2976 
2977  // check the true branch
2978  const CNormalFraction* pFraction2 = &pChoice->getTrueExpression();
2979  CPPUNIT_ASSERT(pFraction2 != NULL);
2980  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
2981  numerator = &pFraction2->getNumerator();
2982  CPPUNIT_ASSERT(numerator->getFractions().size() == 0);
2983  products = &numerator->getProducts();
2984  CPPUNIT_ASSERT(products->size() == 1);
2985  pProduct = *(products->begin());
2986  CPPUNIT_ASSERT(pProduct != NULL);
2987  CPPUNIT_ASSERT(pProduct->getFactor() == 2.3);
2988  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
2989 
2990  // check the false branch
2991  pFraction2 = &pChoice->getFalseExpression();
2992  CPPUNIT_ASSERT(pFraction2 != NULL);
2993  numerator = &pFraction2->getNumerator();
2994  CPPUNIT_ASSERT(numerator->getFractions().size() == 0);
2995  products = &numerator->getProducts();
2996  CPPUNIT_ASSERT(products->size() == 1);
2997  pProduct = *(products->begin());
2998  CPPUNIT_ASSERT(pProduct != NULL);
2999  CPPUNIT_ASSERT(pProduct->getFactor() == 4.5);
3000  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
3001 }
3002 
3003 void test_normalform::test_simple_nested_stepwise_fractions()
3004 {
3005  std::string infix("IF(IF(IF(TRUE,FALSE,TRUE),IF(FALSE,TRUE,FALSE),IF(FALSE,FALSE,FALSE)),A/TAN(X)^R,SIN(PI)/A^6)");
3006  CEvaluationTree* pTree = new CEvaluationTree();
3007  pTree->setInfix(infix);
3008  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
3010  delete pTree;
3011  CPPUNIT_ASSERT(pFraction != NULL);
3012  CPPUNIT_ASSERT(pFraction->checkDenominatorOne() == true);
3013 
3014  const CNormalSum* numerator = &pFraction->getNumerator();
3015  CPPUNIT_ASSERT(numerator->getFractions().size() == 0);
3016  const std::set<CNormalProduct*, compareProducts >* products = &numerator->getProducts();
3017  CPPUNIT_ASSERT(products->size() == 1);
3018  const CNormalProduct* pProduct = *(products->begin());
3019  CPPUNIT_ASSERT(pProduct != NULL);
3020  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
3021  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
3022  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
3023  CPPUNIT_ASSERT(pItemPower != NULL);
3024  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
3025  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::CHOICE);
3026  const CNormalChoice* pChoice = dynamic_cast<const CNormalChoice*>(&pItemPower->getItem());
3027  CPPUNIT_ASSERT(pChoice != NULL);
3028 
3029  // check the condition
3030  const CNormalLogical* pLogical = &pChoice->getCondition();
3031  CPPUNIT_ASSERT(pLogical != NULL);
3032  CPPUNIT_ASSERT(pLogical->isNegated() == false);
3033  CPPUNIT_ASSERT(pLogical->getChoices().size() == 0);
3034  CPPUNIT_ASSERT(pLogical->getAndSets().size() == 1);
3035  std::pair<CNormalLogical::ItemSet, bool> outerpair = *(pLogical->getAndSets().begin());
3036  CPPUNIT_ASSERT(outerpair.second == false);
3037  CPPUNIT_ASSERT(outerpair.first.size() == 1);
3038  std::pair<CNormalLogicalItem*, bool> innerpair = *(outerpair.first.begin());
3039  CPPUNIT_ASSERT(innerpair.second == false);
3040  const CNormalLogicalItem* pLogicalItem = innerpair.first;
3041  CPPUNIT_ASSERT(pLogicalItem != NULL);
3042  CPPUNIT_ASSERT(pLogicalItem->getType() == CNormalLogicalItem::FALSE);
3043 
3044  // check the true branch
3045  const CNormalFraction* pFraction2 = &pChoice->getTrueExpression();
3046  CPPUNIT_ASSERT(pFraction2 != NULL);
3047  numerator = &pFraction2->getNumerator();
3048  CPPUNIT_ASSERT(numerator->getFractions().size() == 0);
3049  products = &numerator->getProducts();
3050  CPPUNIT_ASSERT(products->size() == 1);
3051  pProduct = *(products->begin());
3052  CPPUNIT_ASSERT(pProduct != NULL);
3053  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
3054  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
3055  pItemPower = *(pProduct->getItemPowers().begin());
3056  CPPUNIT_ASSERT(pItemPower != NULL);
3057  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
3058  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
3059  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
3060  CPPUNIT_ASSERT(pItem != NULL);
3061  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
3062  CPPUNIT_ASSERT(pItem->getName() == "A");
3063  const CNormalSum* denominator = &pFraction2->getDenominator();
3064  CPPUNIT_ASSERT(denominator->getFractions().size() == 0);
3065  products = &denominator->getProducts();
3066  CPPUNIT_ASSERT(products->size() == 1);
3067  pProduct = *(products->begin());
3068  CPPUNIT_ASSERT(pProduct != NULL);
3069  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
3070  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
3071  pItemPower = *(pProduct->getItemPowers().begin());
3072  CPPUNIT_ASSERT(pItemPower != NULL);
3073  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
3074  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::POWER);
3075  const CNormalGeneralPower* pGeneralPower = dynamic_cast<const CNormalGeneralPower*>(&pItemPower->getItem());
3076  CPPUNIT_ASSERT(pGeneralPower != NULL);
3077  CPPUNIT_ASSERT(pGeneralPower->getType() == CNormalGeneralPower::POWER);
3078  pFraction2 = &pGeneralPower->getLeft();
3079  CPPUNIT_ASSERT(pFraction2 != NULL);
3080  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
3081  numerator = &pFraction2->getNumerator();
3082  CPPUNIT_ASSERT(numerator->getFractions().size() == 0);
3083  products = &numerator->getProducts();
3084  CPPUNIT_ASSERT(products->size() == 1);
3085  pProduct = *(products->begin());
3086  CPPUNIT_ASSERT(pProduct != NULL);
3087  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
3088  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
3089  pItemPower = *(pProduct->getItemPowers().begin());
3090  CPPUNIT_ASSERT(pItemPower != NULL);
3091  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
3092  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::FUNCTION);
3093  const CNormalFunction* pFunction = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
3094  CPPUNIT_ASSERT(pFunction != NULL);
3095  CPPUNIT_ASSERT(pFunction->getType() == CNormalFunction::TAN);
3096  pFraction2 = &pFunction->getFraction();
3097  CPPUNIT_ASSERT(pFraction2 != NULL);
3098  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
3099  numerator = &pFraction2->getNumerator();
3100  CPPUNIT_ASSERT(numerator->getFractions().size() == 0);
3101  products = &numerator->getProducts();
3102  CPPUNIT_ASSERT(products->size() == 1);
3103  pProduct = *(products->begin());
3104  CPPUNIT_ASSERT(pProduct != NULL);
3105  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
3106  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
3107  pItemPower = *(pProduct->getItemPowers().begin());
3108  CPPUNIT_ASSERT(pItemPower != NULL);
3109  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
3110  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
3111  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
3112  CPPUNIT_ASSERT(pItem != NULL);
3113  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
3114  CPPUNIT_ASSERT(pItem->getName() == "X");
3115  pFraction2 = &pGeneralPower->getRight();
3116  CPPUNIT_ASSERT(pFraction2 != NULL);
3117  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
3118  numerator = &pFraction2->getNumerator();
3119  CPPUNIT_ASSERT(numerator->getFractions().size() == 0);
3120  products = &numerator->getProducts();
3121  CPPUNIT_ASSERT(products->size() == 1);
3122  pProduct = *(products->begin());
3123  CPPUNIT_ASSERT(pProduct != NULL);
3124  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
3125  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
3126  pItemPower = *(pProduct->getItemPowers().begin());
3127  CPPUNIT_ASSERT(pItemPower != NULL);
3128  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
3129  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
3130  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
3131  CPPUNIT_ASSERT(pItem != NULL);
3132  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
3133  CPPUNIT_ASSERT(pItem->getName() == "R");
3134 
3135  // check false branch
3136  pFraction2 = &pChoice->getFalseExpression();
3137  CPPUNIT_ASSERT(pFraction2 != NULL);
3138  numerator = &pFraction2->getNumerator();
3139  CPPUNIT_ASSERT(numerator->getFractions().size() == 0);
3140  products = &numerator->getProducts();
3141  CPPUNIT_ASSERT(products->size() == 1);
3142  pProduct = *(products->begin());
3143  CPPUNIT_ASSERT(pProduct != NULL);
3144  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
3145  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
3146  pItemPower = *(pProduct->getItemPowers().begin());
3147  CPPUNIT_ASSERT(pItemPower != NULL);
3148  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
3149  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::FUNCTION);
3150  pFunction = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
3151  CPPUNIT_ASSERT(pFunction != NULL);
3152  CPPUNIT_ASSERT(pFunction->getType() == CNormalFunction::SIN);
3153  pFraction2 = &pFunction->getFraction();
3154  CPPUNIT_ASSERT(pFraction2 != NULL);
3155  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
3156  numerator = &pFraction2->getNumerator();
3157  CPPUNIT_ASSERT(numerator->getFractions().size() == 0);
3158  products = &numerator->getProducts();
3159  CPPUNIT_ASSERT(products->size() == 1);
3160  pProduct = *(products->begin());
3161  CPPUNIT_ASSERT(pProduct != NULL);
3162  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
3163  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
3164  pItemPower = *(pProduct->getItemPowers().begin());
3165  CPPUNIT_ASSERT(pItemPower != NULL);
3166  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
3167  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
3168  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
3169  CPPUNIT_ASSERT(pItem != NULL);
3170  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::CONSTANT);
3171  CPPUNIT_ASSERT(pItem->getName() == "PI");
3172 
3173  // set pFraction2 again since it has been set to the fraction of the function
3174  // above
3175  pFraction2 = &pChoice->getFalseExpression();
3176  denominator = &pFraction2->getDenominator();
3177  CPPUNIT_ASSERT(denominator->getFractions().size() == 0);
3178  products = &denominator->getProducts();
3179  CPPUNIT_ASSERT(products->size() == 1);
3180  pProduct = *(products->begin());
3181  CPPUNIT_ASSERT(pProduct != NULL);
3182  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
3183  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
3184  pItemPower = *(pProduct->getItemPowers().begin());
3185  CPPUNIT_ASSERT(pItemPower != NULL);
3186  CPPUNIT_ASSERT(pItemPower->getExp() == 6.0);
3187  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
3188  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
3189  CPPUNIT_ASSERT(pItem != NULL);
3190  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
3191  CPPUNIT_ASSERT(pItem->getName() == "A");
3192 }
3193 
3194 void test_normalform::test_nested_stepwise_numbers_2levels_1()
3195 {
3196  std::string infix("IF(IF(A gt PI,FALSE,4.0 ne A),2.3,4.5)");
3197  CEvaluationTree* pTree = new CEvaluationTree();
3198  pTree->setInfix(infix);
3199  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
3201  delete pTree;
3202  CPPUNIT_ASSERT(pFraction != NULL);
3203  CPPUNIT_ASSERT(pFraction->checkDenominatorOne() == true);
3204 
3205  const CNormalSum* numerator = &pFraction->getNumerator();
3206  CPPUNIT_ASSERT(numerator->getFractions().size() == 0);
3207  const std::set<CNormalProduct*, compareProducts >* products = &numerator->getProducts();
3208  CPPUNIT_ASSERT(products->size() == 1);
3209  const CNormalProduct* pProduct = *(products->begin());
3210  CPPUNIT_ASSERT(pProduct != NULL);
3211  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
3212  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
3213  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
3214  CPPUNIT_ASSERT(pItemPower != NULL);
3215  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
3216  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::CHOICE);
3217  const CNormalChoice* pChoice = dynamic_cast<const CNormalChoice*>(&pItemPower->getItem());
3218  CPPUNIT_ASSERT(pChoice != NULL);
3219 
3220  // check the condition
3221  const CNormalLogical* pLogical = &pChoice->getCondition();
3222  CPPUNIT_ASSERT(pLogical != NULL);
3223  CPPUNIT_ASSERT(pLogical->isNegated() == false);
3224  CPPUNIT_ASSERT(pLogical->getChoices().size() == 0);
3225  CPPUNIT_ASSERT(pLogical->getAndSets().size() == 1);
3226 
3227  CNormalLogical::ItemSetOfSets::const_iterator outerIt = pLogical->getAndSets().begin();
3228  CPPUNIT_ASSERT(outerIt->second == false);
3229  CPPUNIT_ASSERT(outerIt->first.size() == 2);
3230  CNormalLogical::ItemSet::const_iterator innerIt = outerIt->first.begin();
3231  CPPUNIT_ASSERT(innerIt->second == false);
3232  const CNormalLogicalItem* pLogicalItem = innerIt->first;
3233  CPPUNIT_ASSERT(check_LogicalItemB(pLogicalItem) == true);
3234 
3235  ++innerIt;
3236  CPPUNIT_ASSERT(innerIt->second == false);
3237  pLogicalItem = innerIt->first;
3238  CPPUNIT_ASSERT(check_LogicalItemNotA(pLogicalItem) == true);
3239 
3240  // check the true branch
3241  const CNormalFraction* pFraction2 = &pChoice->getTrueExpression();
3242  CPPUNIT_ASSERT(pFraction2 != NULL);
3243  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
3244  numerator = &pFraction2->getNumerator();
3245  CPPUNIT_ASSERT(numerator->getFractions().size() == 0);
3246  products = &numerator->getProducts();
3247  CPPUNIT_ASSERT(products->size() == 1);
3248  pProduct = *(products->begin());
3249  CPPUNIT_ASSERT(pProduct != NULL);
3250  CPPUNIT_ASSERT(pProduct->getFactor() == 2.3);
3251  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
3252 
3253  // check the false branch
3254  pFraction2 = &pChoice->getFalseExpression();
3255  CPPUNIT_ASSERT(pFraction2 != NULL);
3256  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
3257  numerator = &pFraction2->getNumerator();
3258  CPPUNIT_ASSERT(numerator->getFractions().size() == 0);
3259  products = &numerator->getProducts();
3260  CPPUNIT_ASSERT(products->size() == 1);
3261  pProduct = *(products->begin());
3262  CPPUNIT_ASSERT(pProduct != NULL);
3263  CPPUNIT_ASSERT(pProduct->getFactor() == 4.5);
3264  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
3265 }
3266 
3267 void test_normalform::test_nested_stepwise_numbers_2levels_2()
3268 {
3269  std::string infix("IF(IF(2 eq T,FALSE,NOT (D eq F)),2.3,4.5)");
3270  CEvaluationTree* pTree = new CEvaluationTree();
3271  pTree->setInfix(infix);
3272  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
3274  delete pTree;
3275  CPPUNIT_ASSERT(pFraction != NULL);
3276  CPPUNIT_ASSERT(pFraction->checkDenominatorOne() == true);
3277 
3278  const CNormalSum* numerator = &pFraction->getNumerator();
3279  CPPUNIT_ASSERT(numerator->getFractions().size() == 0);
3280  const std::set<CNormalProduct*, compareProducts >* products = &numerator->getProducts();
3281  CPPUNIT_ASSERT(products->size() == 1);
3282  const CNormalProduct* pProduct = *(products->begin());
3283  CPPUNIT_ASSERT(pProduct != NULL);
3284  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
3285  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
3286  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
3287  CPPUNIT_ASSERT(pItemPower != NULL);
3288  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
3289  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::CHOICE);
3290  const CNormalChoice* pChoice = dynamic_cast<const CNormalChoice*>(&pItemPower->getItem());
3291  CPPUNIT_ASSERT(pChoice != NULL);
3292 
3293  // check condition
3294  const CNormalLogical* pLogical = &pChoice->getCondition();
3295  CPPUNIT_ASSERT(pLogical != NULL);
3296  CPPUNIT_ASSERT(pLogical->isNegated() == false);
3297  CPPUNIT_ASSERT(pLogical->getChoices().size() == 0);
3298  CPPUNIT_ASSERT(pLogical->getAndSets().size() == 1);
3299  CNormalLogical::ItemSetOfSets::const_iterator outerIt = pLogical->getAndSets().begin();
3300  CPPUNIT_ASSERT(outerIt->second == false);
3301  CPPUNIT_ASSERT(outerIt->first.size() == 2);
3302  CNormalLogical::ItemSet::const_iterator innerIt = outerIt->first.begin();
3303  CPPUNIT_ASSERT(innerIt->second == false);
3304 
3305  const CNormalLogicalItem* pLogicalItem = innerIt->first;
3306  // check type, left side and right side
3307  CPPUNIT_ASSERT(check_LogicalItemD(pLogicalItem) == true);
3308 
3309  ++innerIt;
3310  CPPUNIT_ASSERT(innerIt->second == false);
3311  pLogicalItem = innerIt->first;
3312  // check type, left side and right side
3313  CPPUNIT_ASSERT(check_LogicalItemNotC(pLogicalItem) == true);
3314 
3315  // check the true branch
3316  const CNormalFraction* pFraction2 = &pChoice->getTrueExpression();
3317  CPPUNIT_ASSERT(pFraction2 != NULL);
3318  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
3319  numerator = &pFraction2->getNumerator();
3320  CPPUNIT_ASSERT(numerator->getFractions().size() == 0);
3321  products = &numerator->getProducts();
3322  CPPUNIT_ASSERT(products->size() == 1);
3323  pProduct = *(products->begin());
3324  CPPUNIT_ASSERT(pProduct != NULL);
3325  CPPUNIT_ASSERT(pProduct->getFactor() == 2.3);
3326  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
3327 
3328  // check the false branch
3329  pFraction2 = &pChoice->getFalseExpression();
3330  CPPUNIT_ASSERT(pFraction2 != NULL);
3331  numerator = &pFraction2->getNumerator();
3332  CPPUNIT_ASSERT(numerator->getFractions().size() == 0);
3333  products = &numerator->getProducts();
3334  CPPUNIT_ASSERT(products->size() == 1);
3335  pProduct = *(products->begin());
3336  CPPUNIT_ASSERT(pProduct != NULL);
3337  CPPUNIT_ASSERT(pProduct->getFactor() == 4.5);
3338  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
3339 }
3340 
3341 void test_normalform::test_nested_stepwise_numbers_2levels_3()
3342 {
3343  std::string infix("IF(IF(SIN(D*PI) lt X,TRUE,2*T^(3*J) ne 6.2),2.3,4.5)");
3344  CEvaluationTree* pTree = new CEvaluationTree();
3345  pTree->setInfix(infix);
3346  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
3348  delete pTree;
3349  CPPUNIT_ASSERT(pFraction != NULL);
3350  CPPUNIT_ASSERT(pFraction->checkDenominatorOne() == true);
3351 
3352  const CNormalSum* numerator = &pFraction->getNumerator();
3353  CPPUNIT_ASSERT(numerator->getFractions().size() == 0);
3354  const std::set<CNormalProduct*, compareProducts >* products = &numerator->getProducts();
3355  CPPUNIT_ASSERT(products->size() == 1);
3356  const CNormalProduct* pProduct = *(products->begin());
3357  CPPUNIT_ASSERT(pProduct != NULL);
3358  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
3359  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
3360  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
3361  CPPUNIT_ASSERT(pItemPower != NULL);
3362  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
3363  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::CHOICE);
3364  const CNormalChoice* pChoice = dynamic_cast<const CNormalChoice*>(&pItemPower->getItem());
3365  CPPUNIT_ASSERT(pChoice != NULL);
3366 
3367  // check condition
3368  const CNormalLogical* pLogical = &pChoice->getCondition();
3369  CPPUNIT_ASSERT(pLogical != NULL);
3370  CPPUNIT_ASSERT(pLogical->isNegated() == false);
3371  CPPUNIT_ASSERT(pLogical->getChoices().size() == 0);
3372  CPPUNIT_ASSERT(pLogical->getAndSets().size() == 3);
3373  CNormalLogical::ItemSetOfSets::const_iterator outerIt = pLogical->getAndSets().begin();
3374  // (2*T^(3J)==6.2 && SIN(PI*D)<X)
3375  CPPUNIT_ASSERT(outerIt->second == false);
3376  CPPUNIT_ASSERT(outerIt->first.size() == 2);
3377  CNormalLogical::ItemSet::const_iterator innerIt = outerIt->first.begin();
3378  CPPUNIT_ASSERT(innerIt->second == false);
3379  const CNormalLogicalItem* pLogicalItem = innerIt->first;
3380  // check type, left side and right side
3381  CPPUNIT_ASSERT(check_LogicalItemNotF(pLogicalItem) == true);
3382 
3383  ++innerIt;
3384  CPPUNIT_ASSERT(innerIt->second == false);
3385  pLogicalItem = innerIt->first;
3386  // check type, left side and right side
3387  CPPUNIT_ASSERT(check_LogicalItemE(pLogicalItem) == true);
3388 
3389  ++outerIt;
3390  // check the second and set
3391  // (2*T^(3J)!=6.2 && SIN(PI*D)<X)
3392  CPPUNIT_ASSERT(outerIt->second == false);
3393  CPPUNIT_ASSERT(outerIt->first.size() == 2);
3394  innerIt = outerIt->first.begin();
3395  CPPUNIT_ASSERT(innerIt->second == false);
3396  pLogicalItem = innerIt->first;
3397  // check type, left side and right side
3398  CPPUNIT_ASSERT(check_LogicalItemF(pLogicalItem) == true);
3399 
3400  ++innerIt;
3401  CPPUNIT_ASSERT(innerIt->second == false);
3402  pLogicalItem = innerIt->first;
3403  // check type, left side and right side
3404  CPPUNIT_ASSERT(check_LogicalItemE(pLogicalItem) == true);
3405 
3406  ++outerIt;
3407  // check the second and set
3408  // (2*T^(3J)!=6.2 && x<=SIN(PI*D))
3409  CPPUNIT_ASSERT(outerIt->second == false);
3410  CPPUNIT_ASSERT(outerIt->first.size() == 2);
3411  innerIt = outerIt->first.begin();
3412  CPPUNIT_ASSERT(innerIt->second == false);
3413  pLogicalItem = innerIt->first;
3414  // check type, left side and right side
3415  CPPUNIT_ASSERT(check_LogicalItemF(pLogicalItem) == true);
3416 
3417  ++innerIt;
3418  CPPUNIT_ASSERT(innerIt->second == false);
3419  pLogicalItem = innerIt->first;
3420  // check type, left side and right side
3421  CPPUNIT_ASSERT(check_LogicalItemNotE(pLogicalItem) == true);
3422  // check the true branch
3423  const CNormalFraction* pFraction2 = &pChoice->getTrueExpression();
3424  CPPUNIT_ASSERT(pFraction2 != NULL);
3425  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
3426  numerator = &pFraction2->getNumerator();
3427  CPPUNIT_ASSERT(numerator->getFractions().size() == 0);
3428  products = &numerator->getProducts();
3429  CPPUNIT_ASSERT(products->size() == 1);
3430  pProduct = *(products->begin());
3431  CPPUNIT_ASSERT(pProduct != NULL);
3432  CPPUNIT_ASSERT(pProduct->getFactor() == 2.3);
3433  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
3434 
3435  // check the false branch
3436  pFraction2 = &pChoice->getFalseExpression();
3437  CPPUNIT_ASSERT(pFraction2 != NULL);
3438  numerator = &pFraction2->getNumerator();
3439  CPPUNIT_ASSERT(numerator->getFractions().size() == 0);
3440  products = &numerator->getProducts();
3441  CPPUNIT_ASSERT(products->size() == 1);
3442  pProduct = *(products->begin());
3443  CPPUNIT_ASSERT(pProduct != NULL);
3444  CPPUNIT_ASSERT(pProduct->getFactor() == 4.5);
3445  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 0);
3446 }
3447 
3448 void test_normalform::test_nested_stepwise_fractions_3levels()
3449 {
3450  // the condition expression in this test should lead to a truth table with 64 entries and 6 items in each
3451  // entry, 24 of those items evaluate to false,so 40 entries remain after
3452  // normalization
3453  // to simplify the display, the individual logical items are substituted by
3454  // one letter variables
3455  // A: A > PI
3456  // B: 4 != A
3457  // C: 2 == T
3458  // D: NOT (D == F)
3459  // E: SIND(D*PI) < X
3460  // F: "*T^(3J) != 6.2
3461  //
3462  // So the simplified condition is:
3463  // IF(IF(A,FALSE,B),IF(C,FALSE,D),IF(E,TRUE,F))
3464  //
3465  // And the resulting truth table is:
3466  // A B C D E F RESULT
3467  // 01: 0 0 0 0 0 0 0
3468  // 02: 0 0 0 0 0 1 1
3469  // 03: 0 0 0 0 1 0 1
3470  // 04: 0 0 0 0 1 1 1
3471  // 05: 0 0 0 1 0 0 0
3472  // 06: 0 0 0 1 0 1 1
3473  // 07: 0 0 0 1 1 0 1
3474  // 08: 0 0 0 1 1 1 1
3475  // 09: 0 0 1 0 0 0 0
3476  // 10: 0 0 1 0 0 1 1
3477  // 11: 0 0 1 0 1 0 1
3478  // 12: 0 0 1 0 1 1 1
3479  // 13: 0 0 1 1 0 0 0
3480  // 14: 0 0 1 1 0 1 1
3481  // 15: 0 0 1 1 1 0 1
3482  // 16: 0 0 1 1 1 1 1
3483  // 17: 0 1 0 0 0 0 0
3484  // 18: 0 1 0 0 0 1 0
3485  // 19: 0 1 0 0 1 0 0
3486  // 20: 0 1 0 0 1 1 0
3487  // 21: 0 1 0 1 0 0 1
3488  // 22: 0 1 0 1 0 1 1
3489  // 23: 0 1 0 1 1 0 1
3490  // 24: 0 1 0 1 1 1 1
3491  // 25: 0 1 1 0 0 0 0
3492  // 26: 0 1 1 0 0 1 0
3493  // 27: 0 1 1 0 1 0 0
3494  // 28: 0 1 1 0 1 1 0
3495  // 29: 0 1 1 1 0 0 0
3496  // 30: 0 1 1 1 0 1 0
3497  // 31: 0 1 1 1 1 0 0
3498  // 32: 0 1 1 1 1 1 0
3499  // 33: 1 0 0 0 0 0 0
3500  // 34: 1 0 0 0 0 1 1
3501  // 35: 1 0 0 0 1 0 1
3502  // 36: 1 0 0 0 1 1 1
3503  // 37: 1 0 0 1 0 0 0
3504  // 38: 1 0 0 1 0 1 1
3505  // 39: 1 0 0 1 1 0 1
3506  // 40: 1 0 0 1 1 1 1
3507  // 41: 1 0 1 0 0 0 0
3508  // 42: 1 0 1 0 0 1 1
3509  // 43: 1 0 1 0 1 0 1
3510  // 44: 1 0 1 0 1 1 1
3511  // 45: 1 0 1 1 0 0 0
3512  // 46: 1 0 1 1 0 1 1
3513  // 47: 1 0 1 1 1 0 1
3514  // 48: 1 0 1 1 1 1 1
3515  // 49: 1 1 0 0 0 0 0
3516  // 50: 1 1 0 0 0 1 1
3517  // 51: 1 1 0 0 1 0 1
3518  // 52: 1 1 0 0 1 1 1
3519  // 53: 1 1 0 1 0 0 0
3520  // 54: 1 1 0 1 0 1 1
3521  // 55: 1 1 0 1 1 0 1
3522  // 56: 1 1 0 1 1 1 1
3523  // 57: 1 1 1 0 0 0 0
3524  // 58: 1 1 1 0 0 1 1
3525  // 59: 1 1 1 0 1 0 1
3526  // 60: 1 1 1 0 1 1 1
3527  // 61: 1 1 1 1 0 0 0
3528  // 62: 1 1 1 1 0 1 1
3529  // 63: 1 1 1 1 1 0 1
3530  // 64: 1 1 1 1 1 1 1
3531  //
3532  // normalized and simplified forms of logical elements:
3533  // A: (PI < A) !A: (A <= PI)
3534  // B: (4 != A) !B: (4 == A)
3535  // C: (2 == T) !C: (2 != T)
3536  // D: (D != F) !D: (D == F)
3537  // E: (SIN (PI*D) < X) !E: (X <= SIN(PI*D))
3538  // F: (6.2 != 2*T^(3J)) !F: (6.2 == 2*T^(3J))
3539  //
3540  // after removing the false entries, we are left with the following 40
3541  // entries.
3542  // the expanded form is ordered according to the comparison operators
3543  // A B C D E F expanded and ordered
3544  // 01: 1 0 1 0 1 0 (D == F) & (2 == T) & (2*T^(3J) == 6.2) & (4 == A) & (PI < A) & (SIN (PI*D) < X)
3545  // 02: 0 0 1 0 1 0 (D == F) & (2 == T) & (2*T^(3J) == 6.2) & (4 == A) & (SIN (PI*D) < X) & (A <= PI)
3546  // 03: 1 1 1 0 1 0 (D == F) & (2 == T) & (2*T^(3J) == 6.2) & (4 != A) & (PI < A) & (SIN (PI*D) < X)
3547  // 04: 1 0 1 0 1 1 (D == F) & (2 == T) & (4 == A) & (2*T^(3J) != 6.2) & (PI < A) & (SIN (PI*D) < X)
3548  // 05: 1 0 1 0 0 1 (D == F) & (2 == T) & (4 == A) & (2*T^(3J) != 6.2) & (PI < A) & (X <= SIN(PI*D))
3549  // 06: 0 0 1 0 1 1 (D == F) & (2 == T) & (4 == A) & (2*T^(3J) != 6.2) & (SIN (PI*D) < X) & (A <= PI)
3550  // 07: 0 0 1 0 0 1 (D == F) & (2 == T) & (4 == A) & (2*T^(3J) != 6.2) & (A <= PI) & (X <= SIN(PI*D))
3551  // 08: 1 1 1 0 1 1 (D == F) & (2 == T) & (2*T^(3J) != 6.2) & (4 != A) & (PI < A) & (SIN (PI*D) < X)
3552  // 09: 1 1 1 0 0 1 (D == F) & (2 == T) & (2*T^(3J) != 6.2) & (4 != A) & (PI < A) & (X <= SIN(PI*D))
3553  // 10: 1 0 0 0 1 0 (D == F) & (2*T^(3J) == 6.2) & (4 == A) & (2 != T) & (PI < A) & (SIN (PI*D) < X)
3554  // 11: 0 0 0 0 1 0 (D == F) & (2*T^(3J) == 6.2) & (4 == A) & (2 != T) & (SIN (PI*D) < X) & (A <= PI)
3555  // 12: 1 1 0 0 1 0 (D == F) & (2*T^(3J) == 6.2) & (2 != T) & (4 != A) & (PI < A) & (SIN (PI*D) < X)
3556  // 13: 1 0 0 0 1 1 (D == F) & (4 == A) & (2 != T) & (2*T^(3J) != 6.2) & (PI < A) & (SIN (PI*D) < X)
3557  // 14: 1 0 0 0 0 1 (D == F) & (4 == A) & (2 != T) & (2*T^(3J) != 6.2) & (PI < A) & (X <= SIN(PI*D))
3558  // 15: 0 0 0 0 1 1 (D == F) & (4 == A) & (2 != T) & (2*T^(3J) != 6.2) & (SIN (PI*D) < X) & (A <= PI)
3559  // 16: 0 0 0 0 0 1 (D == F) & (4 == A) & (2 != T) & (2*T^(3J) != 6.2) & (A <= PI) & (X <= SIN(PI*D))
3560  // 17: 1 1 0 0 1 1 (D == F) & (2 != T) & (2*T^(3J) != 6.2) & (4 != A) & (PI < A) & (SIN (PI*D) < X)
3561  // 18: 1 1 0 0 0 1 (D == F) & (2 != T) & (2*T^(3J) != 6.2) & (4 != A) & (PI < A) & (X <= SIN(PI*D))
3562  // 19: 1 0 1 1 1 0 (2 == T) & (2*T^(3J) == 6.2) & (4 == A) & (D != F) & (PI < A) & (SIN (PI*D) < X)
3563  // 20: 0 0 1 1 1 0 (2 == T) & (2*T^(3J) == 6.2) & (4 == A) & (D != F) & (SIN (PI*D) < X) & (A <= PI)
3564  // 21: 1 1 1 1 1 0 (2 == T) & (2*T^(3J) == 6.2) & (D != F) & (4 != A) & (PI < A) & (SIN (PI*D) < X)
3565  // 22: 1 0 1 1 1 1 (2 == T) & (4 == A) & (D != F) & (2*T^(3J) != 6.2) & (PI < A) & (SIN (PI*D) < X)
3566  // 23: 1 0 1 1 0 1 (2 == T) & (4 == A) & (D != F) & (2*T^(3J) != 6.2) & (PI < A) & (X <= SIN(PI*D))
3567  // 24: 0 0 1 1 1 1 (2 == T) & (4 == A) & (D != F) & (2*T^(3J) != 6.2) & (SIN (PI*D) < X) & (A <= PI)
3568  // 25: 0 0 1 1 0 1 (2 == T) & (4 == A) & (D != F) & (2*T^(3J) != 6.2) & (A <= PI) & (X <= SIN(PI*D))
3569  // 26: 1 1 1 1 1 1 (2 == T) & (D != F) & (2*T^(3J) != 6.2) & (4 != A) & (PI < A) & (SIN (PI*D) < X)
3570  // 27: 1 1 1 1 0 1 (2 == T) & (D != F) & (2*T^(3J) != 6.2) & (4 != A) & (PI < A) & (X <= SIN(PI*D))
3571  // 28: 1 0 0 1 1 0 (2*T^(3J) == 6.2) & (4 == A) & (D != F) & (2 != T) & (PI < A) & (SIN (PI*D) < X)
3572  // 29: 0 0 0 1 1 0 (2*T^(3J) == 6.2) & (4 == A) & (D != F) & (2 != T) & (SIN (PI*D) < X) & (A <= PI)
3573  // 30: 1 1 0 1 1 0 (2*T^(3J) == 6.2) & (D != F) & (2 != T) & (4 != A) & (PI < A) & (SIN (PI*D) < X)
3574  // 31: 0 1 0 1 1 0 (2*T^(3J) == 6.2) & (D != F) & (2 != T) & (4 != A) & (SIN (PI*D) < X) & (A <= PI)
3575  // 32: 0 1 0 1 0 0 (2*T^(3J) == 6.2) & (D != F) & (2 != T) & (4 != A) & (A <= PI) & (X <= SIN(PI*D))
3576  // 33: 1 0 0 1 1 1 (4 == A) & (D != F) & (2 != T) & (2*T^(3J) != 6.2) & (PI < A) & (SIN (PI*D) < X)
3577  // 34: 1 0 0 1 0 1 (4 == A) & (D != F) & (2 != T) & (2*T^(3J) != 6.2) & (PI < A) & (X <= SIN(PI*D))
3578  // 35: 0 0 0 1 1 1 (4 == A) & (D != F) & (2 != T) & (2*T^(3J) != 6.2) & (SIN (PI*D) < X) & (A <= PI)
3579  // 36: 0 0 0 1 0 1 (4 == A) & (D != F) & (2 != T) & (2*T^(3J) != 6.2) & (A <= PI) & (X <= SIN(PI*D))
3580  // 37: 1 1 0 1 1 1 (D != F) & (2 != T) & (2*T^(3J) != 6.2) & (4 != A) & (PI < A) & (SIN (PI*D) < X)
3581  // 38: 1 1 0 1 0 1 (D != F) & (2 != T) & (2*T^(3J) != 6.2) & (4 != A) & (PI < A) & (X <= SIN(PI*D))
3582  // 39: 0 1 0 1 1 1 (D != F) & (2 != T) & (2*T^(3J) != 6.2) & (4 != A) & (SIN (PI*D) < X) & (A <= PI)
3583  // 40: 0 1 0 1 0 1 (D != F) & (2 != T) & (2*T^(3J) != 6.2) & (4 != A) & (A <= PI) & (X <= SIN(PI*D))
3584  //
3585  //
3586  std::string infix("IF(IF(IF(A gt PI,FALSE,4.0 ne A),IF(2 eq T,FALSE,NOT (D eq F)),IF(SIN(D*PI) lt X,TRUE,2*T^(3*J) ne 6.2)),A/TAN(X)^R,SIN(PI)/A^6)");
3587  CEvaluationTree* pTree = new CEvaluationTree();
3588  pTree->setInfix(infix);
3589  CPPUNIT_ASSERT(pTree->getRoot() != NULL);
3591  delete pTree;
3592  //std::cout << pFraction->toString() << std::endl;
3593  CPPUNIT_ASSERT(pFraction != NULL);
3594  CPPUNIT_ASSERT(pFraction->checkDenominatorOne() == true);
3595 
3596  const CNormalSum* numerator = &pFraction->getNumerator();
3597  CPPUNIT_ASSERT(numerator->getFractions().size() == 0);
3598  const std::set<CNormalProduct*, compareProducts >* products = &numerator->getProducts();
3599  CPPUNIT_ASSERT(products->size() == 1);
3600  const CNormalProduct* pProduct = *(products->begin());
3601  CPPUNIT_ASSERT(pProduct != NULL);
3602  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
3603  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
3604  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
3605  CPPUNIT_ASSERT(pItemPower != NULL);
3606  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
3607  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::CHOICE);
3608  const CNormalChoice* pChoice = dynamic_cast<const CNormalChoice*>(&pItemPower->getItem());
3609  CPPUNIT_ASSERT(pChoice != NULL);
3610 
3611  // check condition
3612  const CNormalLogical* pLogical = &pChoice->getCondition();
3613  CPPUNIT_ASSERT(pLogical != NULL);
3614  CPPUNIT_ASSERT(pLogical->isNegated() == false);
3615  CPPUNIT_ASSERT(pLogical->getChoices().size() == 0);
3616  CPPUNIT_ASSERT(pLogical->getAndSets().size() == 40);
3617 
3618  // 40 sets
3619  CNormalLogical::ItemSetOfSets::const_iterator outerIt = pLogical->getAndSets().begin();
3620  CPPUNIT_ASSERT(outerIt->second == false);
3621  CPPUNIT_ASSERT(outerIt->first.size() == 6);
3622  // 1
3623  // 6 items in each set
3624  CNormalLogical::ItemSet::const_iterator innerIt = outerIt->first.begin();
3625  CPPUNIT_ASSERT(innerIt->second == false);
3626  CPPUNIT_ASSERT(check_LogicalItemNotD(innerIt->first) == true);
3627  ++innerIt;
3628  CPPUNIT_ASSERT(innerIt->second == false);
3629  CPPUNIT_ASSERT(check_LogicalItemC(innerIt->first) == true);
3630  ++innerIt;
3631  CPPUNIT_ASSERT(innerIt->second == false);
3632  CPPUNIT_ASSERT(check_LogicalItemNotF(innerIt->first) == true);
3633  ++innerIt;
3634  CPPUNIT_ASSERT(innerIt->second == false);
3635  CPPUNIT_ASSERT(check_LogicalItemNotB(innerIt->first) == true);
3636  ++innerIt;
3637  CPPUNIT_ASSERT(innerIt->second == false);
3638  CPPUNIT_ASSERT(check_LogicalItemA(innerIt->first) == true);
3639  ++innerIt;
3640  CPPUNIT_ASSERT(innerIt->second == false);
3641  CPPUNIT_ASSERT(check_LogicalItemE(innerIt->first) == true);
3642 
3643  ++outerIt;
3644  CPPUNIT_ASSERT(outerIt->second == false);
3645  CPPUNIT_ASSERT(outerIt->first.size() == 6);
3646  // 2
3647  innerIt = outerIt->first.begin();
3648  CPPUNIT_ASSERT(innerIt->second == false);
3649  CPPUNIT_ASSERT(check_LogicalItemNotD(innerIt->first) == true);
3650  ++innerIt;
3651  CPPUNIT_ASSERT(innerIt->second == false);
3652  CPPUNIT_ASSERT(check_LogicalItemC(innerIt->first) == true);
3653  ++innerIt;
3654  CPPUNIT_ASSERT(innerIt->second == false);
3655  CPPUNIT_ASSERT(check_LogicalItemNotF(innerIt->first) == true);
3656  ++innerIt;
3657  CPPUNIT_ASSERT(innerIt->second == false);
3658  CPPUNIT_ASSERT(check_LogicalItemNotB(innerIt->first) == true);
3659  ++innerIt;
3660  CPPUNIT_ASSERT(innerIt->second == false);
3661  CPPUNIT_ASSERT(check_LogicalItemE(innerIt->first) == true);
3662  ++innerIt;
3663  CPPUNIT_ASSERT(innerIt->second == false);
3664  CPPUNIT_ASSERT(check_LogicalItemNotA(innerIt->first) == true);
3665 
3666  ++outerIt;
3667  CPPUNIT_ASSERT(outerIt->second == false);
3668  CPPUNIT_ASSERT(outerIt->first.size() == 6);
3669  // 3
3670  innerIt = outerIt->first.begin();
3671  CPPUNIT_ASSERT(innerIt->second == false);
3672  CPPUNIT_ASSERT(check_LogicalItemNotD(innerIt->first) == true);
3673  ++innerIt;
3674  CPPUNIT_ASSERT(innerIt->second == false);
3675  CPPUNIT_ASSERT(check_LogicalItemC(innerIt->first) == true);
3676  ++innerIt;
3677  CPPUNIT_ASSERT(innerIt->second == false);
3678  CPPUNIT_ASSERT(check_LogicalItemNotF(innerIt->first) == true);
3679  ++innerIt;
3680  CPPUNIT_ASSERT(innerIt->second == false);
3681  CPPUNIT_ASSERT(check_LogicalItemB(innerIt->first) == true);
3682  ++innerIt;
3683  CPPUNIT_ASSERT(innerIt->second == false);
3684  CPPUNIT_ASSERT(check_LogicalItemA(innerIt->first) == true);
3685  ++innerIt;
3686  CPPUNIT_ASSERT(innerIt->second == false);
3687  CPPUNIT_ASSERT(check_LogicalItemE(innerIt->first) == true);
3688 
3689  ++outerIt;
3690  CPPUNIT_ASSERT(outerIt->second == false);
3691  CPPUNIT_ASSERT(outerIt->first.size() == 6);
3692  // 4
3693  innerIt = outerIt->first.begin();
3694  CPPUNIT_ASSERT(innerIt->second == false);
3695  CPPUNIT_ASSERT(check_LogicalItemNotD(innerIt->first) == true);
3696  ++innerIt;
3697  CPPUNIT_ASSERT(innerIt->second == false);
3698  CPPUNIT_ASSERT(check_LogicalItemC(innerIt->first) == true);
3699  ++innerIt;
3700  CPPUNIT_ASSERT(innerIt->second == false);
3701  CPPUNIT_ASSERT(check_LogicalItemNotB(innerIt->first) == true);
3702  ++innerIt;
3703  CPPUNIT_ASSERT(innerIt->second == false);
3704  CPPUNIT_ASSERT(check_LogicalItemF(innerIt->first) == true);
3705  ++innerIt;
3706  CPPUNIT_ASSERT(innerIt->second == false);
3707  CPPUNIT_ASSERT(check_LogicalItemA(innerIt->first) == true);
3708  ++innerIt;
3709  CPPUNIT_ASSERT(innerIt->second == false);
3710  CPPUNIT_ASSERT(check_LogicalItemE(innerIt->first) == true);
3711 
3712  ++outerIt;
3713  CPPUNIT_ASSERT(outerIt->second == false);
3714  CPPUNIT_ASSERT(outerIt->first.size() == 6);
3715  // 5
3716  innerIt = outerIt->first.begin();
3717  CPPUNIT_ASSERT(innerIt->second == false);
3718  CPPUNIT_ASSERT(check_LogicalItemNotD(innerIt->first) == true);
3719  ++innerIt;
3720  CPPUNIT_ASSERT(innerIt->second == false);
3721  CPPUNIT_ASSERT(check_LogicalItemC(innerIt->first) == true);
3722  ++innerIt;
3723  CPPUNIT_ASSERT(innerIt->second == false);
3724  CPPUNIT_ASSERT(check_LogicalItemNotB(innerIt->first) == true);
3725  ++innerIt;
3726  CPPUNIT_ASSERT(innerIt->second == false);
3727  CPPUNIT_ASSERT(check_LogicalItemF(innerIt->first) == true);
3728  ++innerIt;
3729  CPPUNIT_ASSERT(innerIt->second == false);
3730  CPPUNIT_ASSERT(check_LogicalItemA(innerIt->first) == true);
3731  ++innerIt;
3732  CPPUNIT_ASSERT(innerIt->second == false);
3733  CPPUNIT_ASSERT(check_LogicalItemNotE(innerIt->first) == true);
3734 
3735  ++outerIt;
3736  CPPUNIT_ASSERT(outerIt->second == false);
3737  CPPUNIT_ASSERT(outerIt->first.size() == 6);
3738  // 6
3739  innerIt = outerIt->first.begin();
3740  CPPUNIT_ASSERT(innerIt->second == false);
3741  CPPUNIT_ASSERT(check_LogicalItemNotD(innerIt->first) == true);
3742  ++innerIt;
3743  CPPUNIT_ASSERT(innerIt->second == false);
3744  CPPUNIT_ASSERT(check_LogicalItemC(innerIt->first) == true);
3745  ++innerIt;
3746  CPPUNIT_ASSERT(innerIt->second == false);
3747  CPPUNIT_ASSERT(check_LogicalItemNotB(innerIt->first) == true);
3748  ++innerIt;
3749  CPPUNIT_ASSERT(innerIt->second == false);
3750  CPPUNIT_ASSERT(check_LogicalItemF(innerIt->first) == true);
3751  ++innerIt;
3752  CPPUNIT_ASSERT(innerIt->second == false);
3753  CPPUNIT_ASSERT(check_LogicalItemE(innerIt->first) == true);
3754  ++innerIt;
3755  CPPUNIT_ASSERT(innerIt->second == false);
3756  CPPUNIT_ASSERT(check_LogicalItemNotA(innerIt->first) == true);
3757 
3758  ++outerIt;
3759  CPPUNIT_ASSERT(outerIt->second == false);
3760  CPPUNIT_ASSERT(outerIt->first.size() == 6);
3761  // 7
3762  innerIt = outerIt->first.begin();
3763  CPPUNIT_ASSERT(innerIt->second == false);
3764  CPPUNIT_ASSERT(check_LogicalItemNotD(innerIt->first) == true);
3765  ++innerIt;
3766  CPPUNIT_ASSERT(innerIt->second == false);
3767  CPPUNIT_ASSERT(check_LogicalItemC(innerIt->first) == true);
3768  ++innerIt;
3769  CPPUNIT_ASSERT(innerIt->second == false);
3770  CPPUNIT_ASSERT(check_LogicalItemNotB(innerIt->first) == true);
3771  ++innerIt;
3772  CPPUNIT_ASSERT(innerIt->second == false);
3773  CPPUNIT_ASSERT(check_LogicalItemF(innerIt->first) == true);
3774  ++innerIt;
3775  CPPUNIT_ASSERT(innerIt->second == false);
3776  CPPUNIT_ASSERT(check_LogicalItemNotA(innerIt->first) == true);
3777  ++innerIt;
3778  CPPUNIT_ASSERT(innerIt->second == false);
3779  CPPUNIT_ASSERT(check_LogicalItemNotE(innerIt->first) == true);
3780 
3781  ++outerIt;
3782  CPPUNIT_ASSERT(outerIt->second == false);
3783  CPPUNIT_ASSERT(outerIt->first.size() == 6);
3784  // 8
3785  innerIt = outerIt->first.begin();
3786  CPPUNIT_ASSERT(innerIt->second == false);
3787  CPPUNIT_ASSERT(check_LogicalItemNotD(innerIt->first) == true);
3788  ++innerIt;
3789  CPPUNIT_ASSERT(innerIt->second == false);
3790  CPPUNIT_ASSERT(check_LogicalItemC(innerIt->first) == true);
3791  ++innerIt;
3792  CPPUNIT_ASSERT(innerIt->second == false);
3793  CPPUNIT_ASSERT(check_LogicalItemF(innerIt->first) == true);
3794  ++innerIt;
3795  CPPUNIT_ASSERT(innerIt->second == false);
3796  CPPUNIT_ASSERT(check_LogicalItemB(innerIt->first) == true);
3797  ++innerIt;
3798  CPPUNIT_ASSERT(innerIt->second == false);
3799  CPPUNIT_ASSERT(check_LogicalItemA(innerIt->first) == true);
3800  ++innerIt;
3801  CPPUNIT_ASSERT(innerIt->second == false);
3802  CPPUNIT_ASSERT(check_LogicalItemE(innerIt->first) == true);
3803 
3804  ++outerIt;
3805  CPPUNIT_ASSERT(outerIt->second == false);
3806  CPPUNIT_ASSERT(outerIt->first.size() == 6);
3807  // 9
3808  innerIt = outerIt->first.begin();
3809  CPPUNIT_ASSERT(innerIt->second == false);
3810  CPPUNIT_ASSERT(check_LogicalItemNotD(innerIt->first) == true);
3811  ++innerIt;
3812  CPPUNIT_ASSERT(innerIt->second == false);
3813  CPPUNIT_ASSERT(check_LogicalItemC(innerIt->first) == true);
3814  ++innerIt;
3815  CPPUNIT_ASSERT(innerIt->second == false);
3816  CPPUNIT_ASSERT(check_LogicalItemF(innerIt->first) == true);
3817  ++innerIt;
3818  CPPUNIT_ASSERT(innerIt->second == false);
3819  CPPUNIT_ASSERT(check_LogicalItemB(innerIt->first) == true);
3820  ++innerIt;
3821  CPPUNIT_ASSERT(innerIt->second == false);
3822  CPPUNIT_ASSERT(check_LogicalItemA(innerIt->first) == true);
3823  ++innerIt;
3824  CPPUNIT_ASSERT(innerIt->second == false);
3825  CPPUNIT_ASSERT(check_LogicalItemNotE(innerIt->first) == true);
3826 
3827  ++outerIt;
3828  CPPUNIT_ASSERT(outerIt->second == false);
3829  CPPUNIT_ASSERT(outerIt->first.size() == 6);
3830  // 10
3831  innerIt = outerIt->first.begin();
3832  CPPUNIT_ASSERT(innerIt->second == false);
3833  CPPUNIT_ASSERT(check_LogicalItemNotD(innerIt->first) == true);
3834  ++innerIt;
3835  CPPUNIT_ASSERT(innerIt->second == false);
3836  CPPUNIT_ASSERT(check_LogicalItemNotF(innerIt->first) == true);
3837  ++innerIt;
3838  CPPUNIT_ASSERT(innerIt->second == false);
3839  CPPUNIT_ASSERT(check_LogicalItemNotB(innerIt->first) == true);
3840  ++innerIt;
3841  CPPUNIT_ASSERT(innerIt->second == false);
3842  CPPUNIT_ASSERT(check_LogicalItemNotC(innerIt->first) == true);
3843  ++innerIt;
3844  CPPUNIT_ASSERT(innerIt->second == false);
3845  CPPUNIT_ASSERT(check_LogicalItemA(innerIt->first) == true);
3846  ++innerIt;
3847  CPPUNIT_ASSERT(innerIt->second == false);
3848  CPPUNIT_ASSERT(check_LogicalItemE(innerIt->first) == true);
3849 
3850  ++outerIt;
3851  CPPUNIT_ASSERT(outerIt->second == false);
3852  CPPUNIT_ASSERT(outerIt->first.size() == 6);
3853  // 11
3854  innerIt = outerIt->first.begin();
3855  CPPUNIT_ASSERT(innerIt->second == false);
3856  CPPUNIT_ASSERT(check_LogicalItemNotD(innerIt->first) == true);
3857  ++innerIt;
3858  CPPUNIT_ASSERT(innerIt->second == false);
3859  CPPUNIT_ASSERT(check_LogicalItemNotF(innerIt->first) == true);
3860  ++innerIt;
3861  CPPUNIT_ASSERT(innerIt->second == false);
3862  CPPUNIT_ASSERT(check_LogicalItemNotB(innerIt->first) == true);
3863  ++innerIt;
3864  CPPUNIT_ASSERT(innerIt->second == false);
3865  CPPUNIT_ASSERT(check_LogicalItemNotC(innerIt->first) == true);
3866  ++innerIt;
3867  CPPUNIT_ASSERT(innerIt->second == false);
3868  CPPUNIT_ASSERT(check_LogicalItemE(innerIt->first) == true);
3869  ++innerIt;
3870  CPPUNIT_ASSERT(innerIt->second == false);
3871  CPPUNIT_ASSERT(check_LogicalItemNotA(innerIt->first) == true);
3872 
3873  ++outerIt;
3874  CPPUNIT_ASSERT(outerIt->second == false);
3875  CPPUNIT_ASSERT(outerIt->first.size() == 6);
3876  // 12
3877  innerIt = outerIt->first.begin();
3878  CPPUNIT_ASSERT(innerIt->second == false);
3879  CPPUNIT_ASSERT(check_LogicalItemNotD(innerIt->first) == true);
3880  ++innerIt;
3881  CPPUNIT_ASSERT(innerIt->second == false);
3882  CPPUNIT_ASSERT(check_LogicalItemNotF(innerIt->first) == true);
3883  ++innerIt;
3884  CPPUNIT_ASSERT(innerIt->second == false);
3885  CPPUNIT_ASSERT(check_LogicalItemNotC(innerIt->first) == true);
3886  ++innerIt;
3887  CPPUNIT_ASSERT(innerIt->second == false);
3888  CPPUNIT_ASSERT(check_LogicalItemB(innerIt->first) == true);
3889  ++innerIt;
3890  CPPUNIT_ASSERT(innerIt->second == false);
3891  CPPUNIT_ASSERT(check_LogicalItemA(innerIt->first) == true);
3892  ++innerIt;
3893  CPPUNIT_ASSERT(innerIt->second == false);
3894  CPPUNIT_ASSERT(check_LogicalItemE(innerIt->first) == true);
3895 
3896  ++outerIt;
3897  CPPUNIT_ASSERT(outerIt->second == false);
3898  CPPUNIT_ASSERT(outerIt->first.size() == 6);
3899  // 13
3900  innerIt = outerIt->first.begin();
3901  CPPUNIT_ASSERT(innerIt->second == false);
3902  CPPUNIT_ASSERT(check_LogicalItemNotD(innerIt->first) == true);
3903  ++innerIt;
3904  CPPUNIT_ASSERT(innerIt->second == false);
3905  CPPUNIT_ASSERT(check_LogicalItemNotB(innerIt->first) == true);
3906  ++innerIt;
3907  CPPUNIT_ASSERT(innerIt->second == false);
3908  CPPUNIT_ASSERT(check_LogicalItemNotC(innerIt->first) == true);
3909  ++innerIt;
3910  CPPUNIT_ASSERT(innerIt->second == false);
3911  CPPUNIT_ASSERT(check_LogicalItemF(innerIt->first) == true);
3912  ++innerIt;
3913  CPPUNIT_ASSERT(innerIt->second == false);
3914  CPPUNIT_ASSERT(check_LogicalItemA(innerIt->first) == true);
3915  ++innerIt;
3916  CPPUNIT_ASSERT(innerIt->second == false);
3917  CPPUNIT_ASSERT(check_LogicalItemE(innerIt->first) == true);
3918 
3919  ++outerIt;
3920  CPPUNIT_ASSERT(outerIt->second == false);
3921  CPPUNIT_ASSERT(outerIt->first.size() == 6);
3922  // 14
3923  innerIt = outerIt->first.begin();
3924  CPPUNIT_ASSERT(innerIt->second == false);
3925  CPPUNIT_ASSERT(check_LogicalItemNotD(innerIt->first) == true);
3926  ++innerIt;
3927  CPPUNIT_ASSERT(innerIt->second == false);
3928  CPPUNIT_ASSERT(check_LogicalItemNotB(innerIt->first) == true);
3929  ++innerIt;
3930  CPPUNIT_ASSERT(innerIt->second == false);
3931  CPPUNIT_ASSERT(check_LogicalItemNotC(innerIt->first) == true);
3932  ++innerIt;
3933  CPPUNIT_ASSERT(innerIt->second == false);
3934  CPPUNIT_ASSERT(check_LogicalItemF(innerIt->first) == true);
3935  ++innerIt;
3936  CPPUNIT_ASSERT(innerIt->second == false);
3937  CPPUNIT_ASSERT(check_LogicalItemA(innerIt->first) == true);
3938  ++innerIt;
3939  CPPUNIT_ASSERT(innerIt->second == false);
3940  CPPUNIT_ASSERT(check_LogicalItemNotE(innerIt->first) == true);
3941 
3942  ++outerIt;
3943  CPPUNIT_ASSERT(outerIt->second == false);
3944  CPPUNIT_ASSERT(outerIt->first.size() == 6);
3945  // 15
3946  innerIt = outerIt->first.begin();
3947  CPPUNIT_ASSERT(innerIt->second == false);
3948  CPPUNIT_ASSERT(check_LogicalItemNotD(innerIt->first) == true);
3949  ++innerIt;
3950  CPPUNIT_ASSERT(innerIt->second == false);
3951  CPPUNIT_ASSERT(check_LogicalItemNotB(innerIt->first) == true);
3952  ++innerIt;
3953  CPPUNIT_ASSERT(innerIt->second == false);
3954  CPPUNIT_ASSERT(check_LogicalItemNotC(innerIt->first) == true);
3955  ++innerIt;
3956  CPPUNIT_ASSERT(innerIt->second == false);
3957  CPPUNIT_ASSERT(check_LogicalItemF(innerIt->first) == true);
3958  ++innerIt;
3959  CPPUNIT_ASSERT(innerIt->second == false);
3960  CPPUNIT_ASSERT(check_LogicalItemE(innerIt->first) == true);
3961  ++innerIt;
3962  CPPUNIT_ASSERT(innerIt->second == false);
3963  CPPUNIT_ASSERT(check_LogicalItemNotA(innerIt->first) == true);
3964 
3965  ++outerIt;
3966  CPPUNIT_ASSERT(outerIt->second == false);
3967  CPPUNIT_ASSERT(outerIt->first.size() == 6);
3968  // 16
3969  innerIt = outerIt->first.begin();
3970  CPPUNIT_ASSERT(innerIt->second == false);
3971  CPPUNIT_ASSERT(check_LogicalItemNotD(innerIt->first) == true);
3972  ++innerIt;
3973  CPPUNIT_ASSERT(innerIt->second == false);
3974  CPPUNIT_ASSERT(check_LogicalItemNotB(innerIt->first) == true);
3975  ++innerIt;
3976  CPPUNIT_ASSERT(innerIt->second == false);
3977  CPPUNIT_ASSERT(check_LogicalItemNotC(innerIt->first) == true);
3978  ++innerIt;
3979  CPPUNIT_ASSERT(innerIt->second == false);
3980  CPPUNIT_ASSERT(check_LogicalItemF(innerIt->first) == true);
3981  ++innerIt;
3982  CPPUNIT_ASSERT(innerIt->second == false);
3983  CPPUNIT_ASSERT(check_LogicalItemNotA(innerIt->first) == true);
3984  ++innerIt;
3985  CPPUNIT_ASSERT(innerIt->second == false);
3986  CPPUNIT_ASSERT(check_LogicalItemNotE(innerIt->first) == true);
3987 
3988  ++outerIt;
3989  CPPUNIT_ASSERT(outerIt->second == false);
3990  CPPUNIT_ASSERT(outerIt->first.size() == 6);
3991  // 17
3992  innerIt = outerIt->first.begin();
3993  CPPUNIT_ASSERT(innerIt->second == false);
3994  CPPUNIT_ASSERT(check_LogicalItemNotD(innerIt->first) == true);
3995  ++innerIt;
3996  CPPUNIT_ASSERT(innerIt->second == false);
3997  CPPUNIT_ASSERT(check_LogicalItemNotC(innerIt->first) == true);
3998  ++innerIt;
3999  CPPUNIT_ASSERT(innerIt->second == false);
4000  CPPUNIT_ASSERT(check_LogicalItemF(innerIt->first) == true);
4001  ++innerIt;
4002  CPPUNIT_ASSERT(innerIt->second == false);
4003  CPPUNIT_ASSERT(check_LogicalItemB(innerIt->first) == true);
4004  ++innerIt;
4005  CPPUNIT_ASSERT(innerIt->second == false);
4006  CPPUNIT_ASSERT(check_LogicalItemA(innerIt->first) == true);
4007  ++innerIt;
4008  CPPUNIT_ASSERT(innerIt->second == false);
4009  CPPUNIT_ASSERT(check_LogicalItemE(innerIt->first) == true);
4010 
4011  ++outerIt;
4012  CPPUNIT_ASSERT(outerIt->second == false);
4013  CPPUNIT_ASSERT(outerIt->first.size() == 6);
4014  // 18
4015  innerIt = outerIt->first.begin();
4016  CPPUNIT_ASSERT(innerIt->second == false);
4017  CPPUNIT_ASSERT(check_LogicalItemNotD(innerIt->first) == true);
4018  ++innerIt;
4019  CPPUNIT_ASSERT(innerIt->second == false);
4020  CPPUNIT_ASSERT(check_LogicalItemNotC(innerIt->first) == true);
4021  ++innerIt;
4022  CPPUNIT_ASSERT(innerIt->second == false);
4023  CPPUNIT_ASSERT(check_LogicalItemF(innerIt->first) == true);
4024  ++innerIt;
4025  CPPUNIT_ASSERT(innerIt->second == false);
4026  CPPUNIT_ASSERT(check_LogicalItemB(innerIt->first) == true);
4027  ++innerIt;
4028  CPPUNIT_ASSERT(innerIt->second == false);
4029  CPPUNIT_ASSERT(check_LogicalItemA(innerIt->first) == true);
4030  ++innerIt;
4031  CPPUNIT_ASSERT(innerIt->second == false);
4032  CPPUNIT_ASSERT(check_LogicalItemNotE(innerIt->first) == true);
4033 
4034  ++outerIt;
4035  CPPUNIT_ASSERT(outerIt->second == false);
4036  CPPUNIT_ASSERT(outerIt->first.size() == 6);
4037  // 19
4038  innerIt = outerIt->first.begin();
4039  CPPUNIT_ASSERT(innerIt->second == false);
4040  CPPUNIT_ASSERT(check_LogicalItemC(innerIt->first) == true);
4041  ++innerIt;
4042  CPPUNIT_ASSERT(innerIt->second == false);
4043  CPPUNIT_ASSERT(check_LogicalItemNotF(innerIt->first) == true);
4044  ++innerIt;
4045  CPPUNIT_ASSERT(innerIt->second == false);
4046  CPPUNIT_ASSERT(check_LogicalItemNotB(innerIt->first) == true);
4047  ++innerIt;
4048  CPPUNIT_ASSERT(innerIt->second == false);
4049  CPPUNIT_ASSERT(check_LogicalItemD(innerIt->first) == true);
4050  ++innerIt;
4051  CPPUNIT_ASSERT(innerIt->second == false);
4052  CPPUNIT_ASSERT(check_LogicalItemA(innerIt->first) == true);
4053  ++innerIt;
4054  CPPUNIT_ASSERT(innerIt->second == false);
4055  CPPUNIT_ASSERT(check_LogicalItemE(innerIt->first) == true);
4056 
4057  ++outerIt;
4058  CPPUNIT_ASSERT(outerIt->second == false);
4059  CPPUNIT_ASSERT(outerIt->first.size() == 6);
4060  // 20
4061  innerIt = outerIt->first.begin();
4062  CPPUNIT_ASSERT(innerIt->second == false);
4063  CPPUNIT_ASSERT(check_LogicalItemC(innerIt->first) == true);
4064  ++innerIt;
4065  CPPUNIT_ASSERT(innerIt->second == false);
4066  CPPUNIT_ASSERT(check_LogicalItemNotF(innerIt->first) == true);
4067  ++innerIt;
4068  CPPUNIT_ASSERT(innerIt->second == false);
4069  CPPUNIT_ASSERT(check_LogicalItemNotB(innerIt->first) == true);
4070  ++innerIt;
4071  CPPUNIT_ASSERT(innerIt->second == false);
4072  CPPUNIT_ASSERT(check_LogicalItemD(innerIt->first) == true);
4073  ++innerIt;
4074  CPPUNIT_ASSERT(innerIt->second == false);
4075  CPPUNIT_ASSERT(check_LogicalItemE(innerIt->first) == true);
4076  ++innerIt;
4077  CPPUNIT_ASSERT(innerIt->second == false);
4078  CPPUNIT_ASSERT(check_LogicalItemNotA(innerIt->first) == true);
4079 
4080  ++outerIt;
4081  CPPUNIT_ASSERT(outerIt->second == false);
4082  CPPUNIT_ASSERT(outerIt->first.size() == 6);
4083  // 21
4084  innerIt = outerIt->first.begin();
4085  CPPUNIT_ASSERT(innerIt->second == false);
4086  CPPUNIT_ASSERT(check_LogicalItemC(innerIt->first) == true);
4087  ++innerIt;
4088  CPPUNIT_ASSERT(innerIt->second == false);
4089  CPPUNIT_ASSERT(check_LogicalItemNotF(innerIt->first) == true);
4090  ++innerIt;
4091  CPPUNIT_ASSERT(innerIt->second == false);
4092  CPPUNIT_ASSERT(check_LogicalItemD(innerIt->first) == true);
4093  ++innerIt;
4094  CPPUNIT_ASSERT(innerIt->second == false);
4095  CPPUNIT_ASSERT(check_LogicalItemB(innerIt->first) == true);
4096  ++innerIt;
4097  CPPUNIT_ASSERT(innerIt->second == false);
4098  CPPUNIT_ASSERT(check_LogicalItemA(innerIt->first) == true);
4099  ++innerIt;
4100  CPPUNIT_ASSERT(innerIt->second == false);
4101  CPPUNIT_ASSERT(check_LogicalItemE(innerIt->first) == true);
4102 
4103  ++outerIt;
4104  CPPUNIT_ASSERT(outerIt->second == false);
4105  CPPUNIT_ASSERT(outerIt->first.size() == 6);
4106  // 22
4107  innerIt = outerIt->first.begin();
4108  CPPUNIT_ASSERT(innerIt->second == false);
4109  CPPUNIT_ASSERT(check_LogicalItemC(innerIt->first) == true);
4110  ++innerIt;
4111  CPPUNIT_ASSERT(innerIt->second == false);
4112  CPPUNIT_ASSERT(check_LogicalItemNotB(innerIt->first) == true);
4113  ++innerIt;
4114  CPPUNIT_ASSERT(innerIt->second == false);
4115  CPPUNIT_ASSERT(check_LogicalItemD(innerIt->first) == true);
4116  ++innerIt;
4117  CPPUNIT_ASSERT(innerIt->second == false);
4118  CPPUNIT_ASSERT(check_LogicalItemF(innerIt->first) == true);
4119  ++innerIt;
4120  CPPUNIT_ASSERT(innerIt->second == false);
4121  CPPUNIT_ASSERT(check_LogicalItemA(innerIt->first) == true);
4122  ++innerIt;
4123  CPPUNIT_ASSERT(innerIt->second == false);
4124  CPPUNIT_ASSERT(check_LogicalItemE(innerIt->first) == true);
4125 
4126  ++outerIt;
4127  CPPUNIT_ASSERT(outerIt->second == false);
4128  CPPUNIT_ASSERT(outerIt->first.size() == 6);
4129  // 23
4130  innerIt = outerIt->first.begin();
4131  CPPUNIT_ASSERT(innerIt->second == false);
4132  CPPUNIT_ASSERT(check_LogicalItemC(innerIt->first) == true);
4133  ++innerIt;
4134  CPPUNIT_ASSERT(innerIt->second == false);
4135  CPPUNIT_ASSERT(check_LogicalItemNotB(innerIt->first) == true);
4136  ++innerIt;
4137  CPPUNIT_ASSERT(innerIt->second == false);
4138  CPPUNIT_ASSERT(check_LogicalItemD(innerIt->first) == true);
4139  ++innerIt;
4140  CPPUNIT_ASSERT(innerIt->second == false);
4141  CPPUNIT_ASSERT(check_LogicalItemF(innerIt->first) == true);
4142  ++innerIt;
4143  CPPUNIT_ASSERT(innerIt->second == false);
4144  CPPUNIT_ASSERT(check_LogicalItemA(innerIt->first) == true);
4145  ++innerIt;
4146  CPPUNIT_ASSERT(innerIt->second == false);
4147  CPPUNIT_ASSERT(check_LogicalItemNotE(innerIt->first) == true);
4148 
4149  ++outerIt;
4150  CPPUNIT_ASSERT(outerIt->second == false);
4151  CPPUNIT_ASSERT(outerIt->first.size() == 6);
4152  // 24
4153  innerIt = outerIt->first.begin();
4154  CPPUNIT_ASSERT(innerIt->second == false);
4155  CPPUNIT_ASSERT(check_LogicalItemC(innerIt->first) == true);
4156  ++innerIt;
4157  CPPUNIT_ASSERT(innerIt->second == false);
4158  CPPUNIT_ASSERT(check_LogicalItemNotB(innerIt->first) == true);
4159  ++innerIt;
4160  CPPUNIT_ASSERT(innerIt->second == false);
4161  CPPUNIT_ASSERT(check_LogicalItemD(innerIt->first) == true);
4162  ++innerIt;
4163  CPPUNIT_ASSERT(innerIt->second == false);
4164  CPPUNIT_ASSERT(check_LogicalItemF(innerIt->first) == true);
4165  ++innerIt;
4166  CPPUNIT_ASSERT(innerIt->second == false);
4167  CPPUNIT_ASSERT(check_LogicalItemE(innerIt->first) == true);
4168  ++innerIt;
4169  CPPUNIT_ASSERT(innerIt->second == false);
4170  CPPUNIT_ASSERT(check_LogicalItemNotA(innerIt->first) == true);
4171 
4172  ++outerIt;
4173  CPPUNIT_ASSERT(outerIt->second == false);
4174  CPPUNIT_ASSERT(outerIt->first.size() == 6);
4175  // 25
4176  innerIt = outerIt->first.begin();
4177  CPPUNIT_ASSERT(innerIt->second == false);
4178  CPPUNIT_ASSERT(check_LogicalItemC(innerIt->first) == true);
4179  ++innerIt;
4180  CPPUNIT_ASSERT(innerIt->second == false);
4181  CPPUNIT_ASSERT(check_LogicalItemNotB(innerIt->first) == true);
4182  ++innerIt;
4183  CPPUNIT_ASSERT(innerIt->second == false);
4184  CPPUNIT_ASSERT(check_LogicalItemD(innerIt->first) == true);
4185  ++innerIt;
4186  CPPUNIT_ASSERT(innerIt->second == false);
4187  CPPUNIT_ASSERT(check_LogicalItemF(innerIt->first) == true);
4188  ++innerIt;
4189  CPPUNIT_ASSERT(innerIt->second == false);
4190  CPPUNIT_ASSERT(check_LogicalItemNotA(innerIt->first) == true);
4191  ++innerIt;
4192  CPPUNIT_ASSERT(innerIt->second == false);
4193  CPPUNIT_ASSERT(check_LogicalItemNotE(innerIt->first) == true);
4194 
4195  ++outerIt;
4196  CPPUNIT_ASSERT(outerIt->second == false);
4197  CPPUNIT_ASSERT(outerIt->first.size() == 6);
4198  // 26
4199  innerIt = outerIt->first.begin();
4200  CPPUNIT_ASSERT(innerIt->second == false);
4201  CPPUNIT_ASSERT(check_LogicalItemC(innerIt->first) == true);
4202  ++innerIt;
4203  CPPUNIT_ASSERT(innerIt->second == false);
4204  CPPUNIT_ASSERT(check_LogicalItemD(innerIt->first) == true);
4205  ++innerIt;
4206  CPPUNIT_ASSERT(innerIt->second == false);
4207  CPPUNIT_ASSERT(check_LogicalItemF(innerIt->first) == true);
4208  ++innerIt;
4209  CPPUNIT_ASSERT(innerIt->second == false);
4210  CPPUNIT_ASSERT(check_LogicalItemB(innerIt->first) == true);
4211  ++innerIt;
4212  CPPUNIT_ASSERT(innerIt->second == false);
4213  CPPUNIT_ASSERT(check_LogicalItemA(innerIt->first) == true);
4214  ++innerIt;
4215  CPPUNIT_ASSERT(innerIt->second == false);
4216  CPPUNIT_ASSERT(check_LogicalItemE(innerIt->first) == true);
4217 
4218  ++outerIt;
4219  CPPUNIT_ASSERT(outerIt->second == false);
4220  CPPUNIT_ASSERT(outerIt->first.size() == 6);
4221  // 27
4222  innerIt = outerIt->first.begin();
4223  CPPUNIT_ASSERT(innerIt->second == false);
4224  CPPUNIT_ASSERT(check_LogicalItemC(innerIt->first) == true);
4225  ++innerIt;
4226  CPPUNIT_ASSERT(innerIt->second == false);
4227  CPPUNIT_ASSERT(check_LogicalItemD(innerIt->first) == true);
4228  ++innerIt;
4229  CPPUNIT_ASSERT(innerIt->second == false);
4230  CPPUNIT_ASSERT(check_LogicalItemF(innerIt->first) == true);
4231  ++innerIt;
4232  CPPUNIT_ASSERT(innerIt->second == false);
4233  CPPUNIT_ASSERT(check_LogicalItemB(innerIt->first) == true);
4234  ++innerIt;
4235  CPPUNIT_ASSERT(innerIt->second == false);
4236  CPPUNIT_ASSERT(check_LogicalItemA(innerIt->first) == true);
4237  ++innerIt;
4238  CPPUNIT_ASSERT(innerIt->second == false);
4239  CPPUNIT_ASSERT(check_LogicalItemNotE(innerIt->first) == true);
4240 
4241  ++outerIt;
4242  CPPUNIT_ASSERT(outerIt->second == false);
4243  CPPUNIT_ASSERT(outerIt->first.size() == 6);
4244  // 28
4245  innerIt = outerIt->first.begin();
4246  CPPUNIT_ASSERT(innerIt->second == false);
4247  CPPUNIT_ASSERT(check_LogicalItemNotF(innerIt->first) == true);
4248  ++innerIt;
4249  CPPUNIT_ASSERT(innerIt->second == false);
4250  CPPUNIT_ASSERT(check_LogicalItemNotB(innerIt->first) == true);
4251  ++innerIt;
4252  CPPUNIT_ASSERT(innerIt->second == false);
4253  CPPUNIT_ASSERT(check_LogicalItemD(innerIt->first) == true);
4254  ++innerIt;
4255  CPPUNIT_ASSERT(innerIt->second == false);
4256  CPPUNIT_ASSERT(check_LogicalItemNotC(innerIt->first) == true);
4257  ++innerIt;
4258  CPPUNIT_ASSERT(innerIt->second == false);
4259  CPPUNIT_ASSERT(check_LogicalItemA(innerIt->first) == true);
4260  ++innerIt;
4261  CPPUNIT_ASSERT(innerIt->second == false);
4262  CPPUNIT_ASSERT(check_LogicalItemE(innerIt->first) == true);
4263 
4264  ++outerIt;
4265  CPPUNIT_ASSERT(outerIt->second == false);
4266  CPPUNIT_ASSERT(outerIt->first.size() == 6);
4267  // 29
4268  innerIt = outerIt->first.begin();
4269  CPPUNIT_ASSERT(innerIt->second == false);
4270  CPPUNIT_ASSERT(check_LogicalItemNotF(innerIt->first) == true);
4271  ++innerIt;
4272  CPPUNIT_ASSERT(innerIt->second == false);
4273  CPPUNIT_ASSERT(check_LogicalItemNotB(innerIt->first) == true);
4274  ++innerIt;
4275  CPPUNIT_ASSERT(innerIt->second == false);
4276  CPPUNIT_ASSERT(check_LogicalItemD(innerIt->first) == true);
4277  ++innerIt;
4278  CPPUNIT_ASSERT(innerIt->second == false);
4279  CPPUNIT_ASSERT(check_LogicalItemNotC(innerIt->first) == true);
4280  ++innerIt;
4281  CPPUNIT_ASSERT(innerIt->second == false);
4282  CPPUNIT_ASSERT(check_LogicalItemE(innerIt->first) == true);
4283  ++innerIt;
4284  CPPUNIT_ASSERT(innerIt->second == false);
4285  CPPUNIT_ASSERT(check_LogicalItemNotA(innerIt->first) == true);
4286 
4287  ++outerIt;
4288  CPPUNIT_ASSERT(outerIt->second == false);
4289  CPPUNIT_ASSERT(outerIt->first.size() == 6);
4290  // 30
4291  innerIt = outerIt->first.begin();
4292  CPPUNIT_ASSERT(innerIt->second == false);
4293  CPPUNIT_ASSERT(check_LogicalItemNotF(innerIt->first) == true);
4294  ++innerIt;
4295  CPPUNIT_ASSERT(innerIt->second == false);
4296  CPPUNIT_ASSERT(check_LogicalItemD(innerIt->first) == true);
4297  ++innerIt;
4298  CPPUNIT_ASSERT(innerIt->second == false);
4299  CPPUNIT_ASSERT(check_LogicalItemNotC(innerIt->first) == true);
4300  ++innerIt;
4301  CPPUNIT_ASSERT(innerIt->second == false);
4302  CPPUNIT_ASSERT(check_LogicalItemB(innerIt->first) == true);
4303  ++innerIt;
4304  CPPUNIT_ASSERT(innerIt->second == false);
4305  CPPUNIT_ASSERT(check_LogicalItemA(innerIt->first) == true);
4306  ++innerIt;
4307  CPPUNIT_ASSERT(innerIt->second == false);
4308  CPPUNIT_ASSERT(check_LogicalItemE(innerIt->first) == true);
4309 
4310  ++outerIt;
4311  CPPUNIT_ASSERT(outerIt->second == false);
4312  CPPUNIT_ASSERT(outerIt->first.size() == 6);
4313  // 31
4314  innerIt = outerIt->first.begin();
4315  CPPUNIT_ASSERT(innerIt->second == false);
4316  CPPUNIT_ASSERT(check_LogicalItemNotF(innerIt->first) == true);
4317  ++innerIt;
4318  CPPUNIT_ASSERT(innerIt->second == false);
4319  CPPUNIT_ASSERT(check_LogicalItemD(innerIt->first) == true);
4320  ++innerIt;
4321  CPPUNIT_ASSERT(innerIt->second == false);
4322  CPPUNIT_ASSERT(check_LogicalItemNotC(innerIt->first) == true);
4323  ++innerIt;
4324  CPPUNIT_ASSERT(innerIt->second == false);
4325  CPPUNIT_ASSERT(check_LogicalItemB(innerIt->first) == true);
4326  ++innerIt;
4327  CPPUNIT_ASSERT(innerIt->second == false);
4328  CPPUNIT_ASSERT(check_LogicalItemE(innerIt->first) == true);
4329  ++innerIt;
4330  CPPUNIT_ASSERT(innerIt->second == false);
4331  CPPUNIT_ASSERT(check_LogicalItemNotA(innerIt->first) == true);
4332 
4333  ++outerIt;
4334  CPPUNIT_ASSERT(outerIt->second == false);
4335  CPPUNIT_ASSERT(outerIt->first.size() == 6);
4336  // 32
4337  innerIt = outerIt->first.begin();
4338  CPPUNIT_ASSERT(innerIt->second == false);
4339  CPPUNIT_ASSERT(check_LogicalItemNotF(innerIt->first) == true);
4340  ++innerIt;
4341  CPPUNIT_ASSERT(innerIt->second == false);
4342  CPPUNIT_ASSERT(check_LogicalItemD(innerIt->first) == true);
4343  ++innerIt;
4344  CPPUNIT_ASSERT(innerIt->second == false);
4345  CPPUNIT_ASSERT(check_LogicalItemNotC(innerIt->first) == true);
4346  ++innerIt;
4347  CPPUNIT_ASSERT(innerIt->second == false);
4348  CPPUNIT_ASSERT(check_LogicalItemB(innerIt->first) == true);
4349  ++innerIt;
4350  CPPUNIT_ASSERT(innerIt->second == false);
4351  CPPUNIT_ASSERT(check_LogicalItemNotA(innerIt->first) == true);
4352  ++innerIt;
4353  CPPUNIT_ASSERT(innerIt->second == false);
4354  CPPUNIT_ASSERT(check_LogicalItemNotE(innerIt->first) == true);
4355 
4356  ++outerIt;
4357  CPPUNIT_ASSERT(outerIt->second == false);
4358  CPPUNIT_ASSERT(outerIt->first.size() == 6);
4359  // 33
4360  innerIt = outerIt->first.begin();
4361  CPPUNIT_ASSERT(innerIt->second == false);
4362  CPPUNIT_ASSERT(check_LogicalItemNotB(innerIt->first) == true);
4363  ++innerIt;
4364  CPPUNIT_ASSERT(innerIt->second == false);
4365  CPPUNIT_ASSERT(check_LogicalItemD(innerIt->first) == true);
4366  ++innerIt;
4367  CPPUNIT_ASSERT(innerIt->second == false);
4368  CPPUNIT_ASSERT(check_LogicalItemNotC(innerIt->first) == true);
4369  ++innerIt;
4370  CPPUNIT_ASSERT(innerIt->second == false);
4371  CPPUNIT_ASSERT(check_LogicalItemF(innerIt->first) == true);
4372  ++innerIt;
4373  CPPUNIT_ASSERT(innerIt->second == false);
4374  CPPUNIT_ASSERT(check_LogicalItemA(innerIt->first) == true);
4375  ++innerIt;
4376  CPPUNIT_ASSERT(innerIt->second == false);
4377  CPPUNIT_ASSERT(check_LogicalItemE(innerIt->first) == true);
4378 
4379  ++outerIt;
4380  CPPUNIT_ASSERT(outerIt->second == false);
4381  CPPUNIT_ASSERT(outerIt->first.size() == 6);
4382  // 34
4383  innerIt = outerIt->first.begin();
4384  CPPUNIT_ASSERT(innerIt->second == false);
4385  CPPUNIT_ASSERT(check_LogicalItemNotB(innerIt->first) == true);
4386  ++innerIt;
4387  CPPUNIT_ASSERT(innerIt->second == false);
4388  CPPUNIT_ASSERT(check_LogicalItemD(innerIt->first) == true);
4389  ++innerIt;
4390  CPPUNIT_ASSERT(innerIt->second == false);
4391  CPPUNIT_ASSERT(check_LogicalItemNotC(innerIt->first) == true);
4392  ++innerIt;
4393  CPPUNIT_ASSERT(innerIt->second == false);
4394  CPPUNIT_ASSERT(check_LogicalItemF(innerIt->first) == true);
4395  ++innerIt;
4396  CPPUNIT_ASSERT(innerIt->second == false);
4397  CPPUNIT_ASSERT(check_LogicalItemA(innerIt->first) == true);
4398  ++innerIt;
4399  CPPUNIT_ASSERT(innerIt->second == false);
4400  CPPUNIT_ASSERT(check_LogicalItemNotE(innerIt->first) == true);
4401 
4402  ++outerIt;
4403  CPPUNIT_ASSERT(outerIt->second == false);
4404  CPPUNIT_ASSERT(outerIt->first.size() == 6);
4405  // 35
4406  innerIt = outerIt->first.begin();
4407  CPPUNIT_ASSERT(innerIt->second == false);
4408  CPPUNIT_ASSERT(check_LogicalItemNotB(innerIt->first) == true);
4409  ++innerIt;
4410  CPPUNIT_ASSERT(innerIt->second == false);
4411  CPPUNIT_ASSERT(check_LogicalItemD(innerIt->first) == true);
4412  ++innerIt;
4413  CPPUNIT_ASSERT(innerIt->second == false);
4414  CPPUNIT_ASSERT(check_LogicalItemNotC(innerIt->first) == true);
4415  ++innerIt;
4416  CPPUNIT_ASSERT(innerIt->second == false);
4417  CPPUNIT_ASSERT(check_LogicalItemF(innerIt->first) == true);
4418  ++innerIt;
4419  CPPUNIT_ASSERT(innerIt->second == false);
4420  CPPUNIT_ASSERT(check_LogicalItemE(innerIt->first) == true);
4421  ++innerIt;
4422  CPPUNIT_ASSERT(innerIt->second == false);
4423  CPPUNIT_ASSERT(check_LogicalItemNotA(innerIt->first) == true);
4424 
4425  ++outerIt;
4426  CPPUNIT_ASSERT(outerIt->second == false);
4427  CPPUNIT_ASSERT(outerIt->first.size() == 6);
4428  // 36
4429  innerIt = outerIt->first.begin();
4430  CPPUNIT_ASSERT(innerIt->second == false);
4431  CPPUNIT_ASSERT(check_LogicalItemNotB(innerIt->first) == true);
4432  ++innerIt;
4433  CPPUNIT_ASSERT(innerIt->second == false);
4434  CPPUNIT_ASSERT(check_LogicalItemD(innerIt->first) == true);
4435  ++innerIt;
4436  CPPUNIT_ASSERT(innerIt->second == false);
4437  CPPUNIT_ASSERT(check_LogicalItemNotC(innerIt->first) == true);
4438  ++innerIt;
4439  CPPUNIT_ASSERT(innerIt->second == false);
4440  CPPUNIT_ASSERT(check_LogicalItemF(innerIt->first) == true);
4441  ++innerIt;
4442  CPPUNIT_ASSERT(innerIt->second == false);
4443  CPPUNIT_ASSERT(check_LogicalItemNotA(innerIt->first) == true);
4444  ++innerIt;
4445  CPPUNIT_ASSERT(innerIt->second == false);
4446  CPPUNIT_ASSERT(check_LogicalItemNotE(innerIt->first) == true);
4447 
4448  ++outerIt;
4449  CPPUNIT_ASSERT(outerIt->second == false);
4450  CPPUNIT_ASSERT(outerIt->first.size() == 6);
4451  // 37
4452  innerIt = outerIt->first.begin();
4453  CPPUNIT_ASSERT(innerIt->second == false);
4454  CPPUNIT_ASSERT(check_LogicalItemD(innerIt->first) == true);
4455  ++innerIt;
4456  CPPUNIT_ASSERT(innerIt->second == false);
4457  CPPUNIT_ASSERT(check_LogicalItemNotC(innerIt->first) == true);
4458  ++innerIt;
4459  CPPUNIT_ASSERT(innerIt->second == false);
4460  CPPUNIT_ASSERT(check_LogicalItemF(innerIt->first) == true);
4461  ++innerIt;
4462  CPPUNIT_ASSERT(innerIt->second == false);
4463  CPPUNIT_ASSERT(check_LogicalItemB(innerIt->first) == true);
4464  ++innerIt;
4465  CPPUNIT_ASSERT(innerIt->second == false);
4466  CPPUNIT_ASSERT(check_LogicalItemA(innerIt->first) == true);
4467  ++innerIt;
4468  CPPUNIT_ASSERT(innerIt->second == false);
4469  CPPUNIT_ASSERT(check_LogicalItemE(innerIt->first) == true);
4470 
4471  ++outerIt;
4472  CPPUNIT_ASSERT(outerIt->second == false);
4473  CPPUNIT_ASSERT(outerIt->first.size() == 6);
4474  // 38
4475  innerIt = outerIt->first.begin();
4476  CPPUNIT_ASSERT(innerIt->second == false);
4477  CPPUNIT_ASSERT(check_LogicalItemD(innerIt->first) == true);
4478  ++innerIt;
4479  CPPUNIT_ASSERT(innerIt->second == false);
4480  CPPUNIT_ASSERT(check_LogicalItemNotC(innerIt->first) == true);
4481  ++innerIt;
4482  CPPUNIT_ASSERT(innerIt->second == false);
4483  CPPUNIT_ASSERT(check_LogicalItemF(innerIt->first) == true);
4484  ++innerIt;
4485  CPPUNIT_ASSERT(innerIt->second == false);
4486  CPPUNIT_ASSERT(check_LogicalItemB(innerIt->first) == true);
4487  ++innerIt;
4488  CPPUNIT_ASSERT(innerIt->second == false);
4489  CPPUNIT_ASSERT(check_LogicalItemA(innerIt->first) == true);
4490  ++innerIt;
4491  CPPUNIT_ASSERT(innerIt->second == false);
4492  CPPUNIT_ASSERT(check_LogicalItemNotE(innerIt->first) == true);
4493 
4494  ++outerIt;
4495  CPPUNIT_ASSERT(outerIt->second == false);
4496  CPPUNIT_ASSERT(outerIt->first.size() == 6);
4497  // 39
4498  innerIt = outerIt->first.begin();
4499  CPPUNIT_ASSERT(innerIt->second == false);
4500  CPPUNIT_ASSERT(check_LogicalItemD(innerIt->first) == true);
4501  ++innerIt;
4502  CPPUNIT_ASSERT(innerIt->second == false);
4503  CPPUNIT_ASSERT(check_LogicalItemNotC(innerIt->first) == true);
4504  ++innerIt;
4505  CPPUNIT_ASSERT(innerIt->second == false);
4506  CPPUNIT_ASSERT(check_LogicalItemF(innerIt->first) == true);
4507  ++innerIt;
4508  CPPUNIT_ASSERT(innerIt->second == false);
4509  CPPUNIT_ASSERT(check_LogicalItemB(innerIt->first) == true);
4510  ++innerIt;
4511  CPPUNIT_ASSERT(innerIt->second == false);
4512  CPPUNIT_ASSERT(check_LogicalItemE(innerIt->first) == true);
4513  ++innerIt;
4514  CPPUNIT_ASSERT(innerIt->second == false);
4515  CPPUNIT_ASSERT(check_LogicalItemNotA(innerIt->first) == true);
4516 
4517  ++outerIt;
4518  CPPUNIT_ASSERT(outerIt->second == false);
4519  CPPUNIT_ASSERT(outerIt->first.size() == 6);
4520  // 40
4521  innerIt = outerIt->first.begin();
4522  CPPUNIT_ASSERT(innerIt->second == false);
4523  CPPUNIT_ASSERT(check_LogicalItemD(innerIt->first) == true);
4524  ++innerIt;
4525  CPPUNIT_ASSERT(innerIt->second == false);
4526  CPPUNIT_ASSERT(check_LogicalItemNotC(innerIt->first) == true);
4527  ++innerIt;
4528  CPPUNIT_ASSERT(innerIt->second == false);
4529  CPPUNIT_ASSERT(check_LogicalItemF(innerIt->first) == true);
4530  ++innerIt;
4531  CPPUNIT_ASSERT(innerIt->second == false);
4532  CPPUNIT_ASSERT(check_LogicalItemB(innerIt->first) == true);
4533  ++innerIt;
4534  CPPUNIT_ASSERT(innerIt->second == false);
4535  CPPUNIT_ASSERT(check_LogicalItemNotA(innerIt->first) == true);
4536  ++innerIt;
4537  CPPUNIT_ASSERT(innerIt->second == false);
4538  CPPUNIT_ASSERT(check_LogicalItemNotE(innerIt->first) == true);
4539 
4540  // check the true branch
4541  const CNormalFraction* pFraction2 = &pChoice->getTrueExpression();
4542  CPPUNIT_ASSERT(pFraction2 != NULL);
4543  numerator = &pFraction2->getNumerator();
4544  CPPUNIT_ASSERT(numerator->getFractions().size() == 0);
4545  products = &numerator->getProducts();
4546  CPPUNIT_ASSERT(products->size() == 1);
4547  pProduct = *(products->begin());
4548  CPPUNIT_ASSERT(pProduct != NULL);
4549  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
4550  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
4551  pItemPower = *(pProduct->getItemPowers().begin());
4552  CPPUNIT_ASSERT(pItemPower != NULL);
4553  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
4554  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
4555  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
4556  CPPUNIT_ASSERT(pItem != NULL);
4557  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
4558  CPPUNIT_ASSERT(pItem->getName() == "A");
4559  const CNormalSum* denominator = &pFraction2->getDenominator();
4560  CPPUNIT_ASSERT(denominator->getFractions().size() == 0);
4561  products = &denominator->getProducts();
4562  CPPUNIT_ASSERT(products->size() == 1);
4563  pProduct = *(products->begin());
4564  CPPUNIT_ASSERT(pProduct != NULL);
4565  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
4566  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
4567  pItemPower = *(pProduct->getItemPowers().begin());
4568  CPPUNIT_ASSERT(pItemPower != NULL);
4569  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
4570  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::POWER);
4571  const CNormalGeneralPower* pGeneralPower = dynamic_cast<const CNormalGeneralPower*>(&pItemPower->getItem());
4572  CPPUNIT_ASSERT(pGeneralPower != NULL);
4573  CPPUNIT_ASSERT(pGeneralPower->getType() == CNormalGeneralPower::POWER);
4574  pFraction2 = &pGeneralPower->getLeft();
4575  CPPUNIT_ASSERT(pFraction2 != NULL);
4576  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
4577  numerator = &pFraction2->getNumerator();
4578  CPPUNIT_ASSERT(numerator->getFractions().size() == 0);
4579  products = &numerator->getProducts();
4580  CPPUNIT_ASSERT(products->size() == 1);
4581  pProduct = *(products->begin());
4582  CPPUNIT_ASSERT(pProduct != NULL);
4583  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
4584  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
4585  pItemPower = *(pProduct->getItemPowers().begin());
4586  CPPUNIT_ASSERT(pItemPower != NULL);
4587  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
4588  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::FUNCTION);
4589  const CNormalFunction* pFunction = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
4590  CPPUNIT_ASSERT(pFunction != NULL);
4591  CPPUNIT_ASSERT(pFunction->getType() == CNormalFunction::TAN);
4592  pFraction2 = &pFunction->getFraction();
4593  CPPUNIT_ASSERT(pFraction2 != NULL);
4594  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
4595  numerator = &pFraction2->getNumerator();
4596  CPPUNIT_ASSERT(numerator->getFractions().size() == 0);
4597  products = &numerator->getProducts();
4598  CPPUNIT_ASSERT(products->size() == 1);
4599  pProduct = *(products->begin());
4600  CPPUNIT_ASSERT(pProduct != NULL);
4601  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
4602  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
4603  pItemPower = *(pProduct->getItemPowers().begin());
4604  CPPUNIT_ASSERT(pItemPower != NULL);
4605  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
4606  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
4607  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
4608  CPPUNIT_ASSERT(pItem != NULL);
4609  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
4610  CPPUNIT_ASSERT(pItem->getName() == "X");
4611  pFraction2 = &pGeneralPower->getRight();
4612  CPPUNIT_ASSERT(pFraction2 != NULL);
4613  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
4614  numerator = &pFraction2->getNumerator();
4615  CPPUNIT_ASSERT(numerator->getFractions().size() == 0);
4616  products = &numerator->getProducts();
4617  CPPUNIT_ASSERT(products->size() == 1);
4618  pProduct = *(products->begin());
4619  CPPUNIT_ASSERT(pProduct != NULL);
4620  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
4621  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
4622  pItemPower = *(pProduct->getItemPowers().begin());
4623  CPPUNIT_ASSERT(pItemPower != NULL);
4624  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
4625  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
4626  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
4627  CPPUNIT_ASSERT(pItem != NULL);
4628  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
4629  CPPUNIT_ASSERT(pItem->getName() == "R");
4630 
4631  // check false branch
4632  pFraction2 = &pChoice->getFalseExpression();
4633  CPPUNIT_ASSERT(pFraction2 != NULL);
4634  numerator = &pFraction2->getNumerator();
4635  CPPUNIT_ASSERT(numerator->getFractions().size() == 0);
4636  products = &numerator->getProducts();
4637  CPPUNIT_ASSERT(products->size() == 1);
4638  pProduct = *(products->begin());
4639  CPPUNIT_ASSERT(pProduct != NULL);
4640  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
4641  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
4642  pItemPower = *(pProduct->getItemPowers().begin());
4643  CPPUNIT_ASSERT(pItemPower != NULL);
4644  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
4645  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::FUNCTION);
4646  pFunction = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
4647  CPPUNIT_ASSERT(pFunction != NULL);
4648  CPPUNIT_ASSERT(pFunction->getType() == CNormalFunction::SIN);
4649  pFraction2 = &pFunction->getFraction();
4650  CPPUNIT_ASSERT(pFraction2 != NULL);
4651  CPPUNIT_ASSERT(pFraction2->checkDenominatorOne() == true);
4652  numerator = &pFraction2->getNumerator();
4653  CPPUNIT_ASSERT(numerator->getFractions().size() == 0);
4654  products = &numerator->getProducts();
4655  CPPUNIT_ASSERT(products->size() == 1);
4656  pProduct = *(products->begin());
4657  CPPUNIT_ASSERT(pProduct != NULL);
4658  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
4659  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
4660  pItemPower = *(pProduct->getItemPowers().begin());
4661  CPPUNIT_ASSERT(pItemPower != NULL);
4662  CPPUNIT_ASSERT(pItemPower->getExp() == 1.0);
4663  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
4664  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
4665  CPPUNIT_ASSERT(pItem != NULL);
4666  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::CONSTANT);
4667  CPPUNIT_ASSERT(pItem->getName() == "PI");
4668 
4669  // set pFraction2 again since it has been set to the fraction of the function
4670  // above
4671  pFraction2 = &pChoice->getFalseExpression();
4672  denominator = &pFraction2->getDenominator();
4673  CPPUNIT_ASSERT(denominator->getFractions().size() == 0);
4674  products = &denominator->getProducts();
4675  CPPUNIT_ASSERT(products->size() == 1);
4676  pProduct = *(products->begin());
4677  CPPUNIT_ASSERT(pProduct != NULL);
4678  CPPUNIT_ASSERT(pProduct->getFactor() == 1.0);
4679  CPPUNIT_ASSERT(pProduct->getItemPowers().size() == 1);
4680  pItemPower = *(pProduct->getItemPowers().begin());
4681  CPPUNIT_ASSERT(pItemPower != NULL);
4682  CPPUNIT_ASSERT(pItemPower->getExp() == 6.0);
4683  CPPUNIT_ASSERT(pItemPower->getItemType() == CNormalItemPower::ITEM);
4684  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
4685  CPPUNIT_ASSERT(pItem != NULL);
4686  CPPUNIT_ASSERT(pItem->getType() == CNormalItem::VARIABLE);
4687  CPPUNIT_ASSERT(pItem->getName() == "A");
4688 }
4689 
4690 // PI < A
4691 bool test_normalform::check_LogicalItemA(const CNormalLogicalItem* pLogicalItem)
4692 {
4693  bool result = true;
4694 
4695  if (pLogicalItem == NULL) return false;
4696 
4697  if (pLogicalItem->getType() != CNormalLogicalItem::LT) return false;
4698 
4699  const CNormalFraction* pTmpFraction = &pLogicalItem->getLeft();
4700 
4701  if (pTmpFraction == NULL) return false;
4702 
4703  if (pTmpFraction->checkDenominatorOne() != true) return false;
4704 
4705  const CNormalSum* pNumerator = &pTmpFraction->getNumerator();
4706 
4707  if (pNumerator->getFractions().size() != 0) return false;
4708 
4709  const std::set<CNormalProduct*, compareProducts >* pProducts = &pNumerator->getProducts();
4710 
4711  if (pProducts->size() != 1) return false;
4712 
4713  const CNormalProduct* pProduct = *(pProducts->begin());
4714 
4715  if (pProduct == NULL) return false;
4716 
4717  if (pProduct->getFactor() != 1.0) return false;
4718 
4719  if (pProduct->getItemPowers().size() != 1) return false;
4720 
4721  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
4722 
4723  if (pItemPower == NULL) return false;
4724 
4725  if (pItemPower->getExp() != 1.0) return false;
4726 
4727  if (pItemPower->getItemType() != CNormalItemPower::ITEM) return false;
4728 
4729  const CNormalItem* pNormalItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
4730 
4731  if (pNormalItem == NULL) return false;
4732 
4733  if (pNormalItem->getType() != CNormalItem::CONSTANT) return false;
4734 
4735  if (pNormalItem->getName() != "PI") return false;
4736 
4737  pTmpFraction = &pLogicalItem->getRight();
4738 
4739  if (pTmpFraction == NULL) return false;
4740 
4741  if (pTmpFraction->checkDenominatorOne() != true) return false;
4742 
4743  pNumerator = &pTmpFraction->getNumerator();
4744 
4745  if (pNumerator->getFractions().size() != 0) return false;
4746 
4747  pProducts = &pNumerator->getProducts();
4748 
4749  if (pProducts->size() != 1) return false;
4750 
4751  pProduct = *(pProducts->begin());
4752 
4753  if (pProduct == NULL) return false;
4754 
4755  if (pProduct->getFactor() != 1.0) return false;
4756 
4757  if (pProduct->getItemPowers().size() != 1) return false;
4758 
4759  pItemPower = *(pProduct->getItemPowers().begin());
4760 
4761  if (pItemPower == NULL) return false;
4762 
4763  if (pItemPower->getExp() != 1.0) return false;
4764 
4765  if (pItemPower->getItemType() != CNormalItemPower::ITEM) return false;
4766 
4767  pNormalItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
4768 
4769  if (pNormalItem == NULL) return false;
4770 
4771  if (pNormalItem->getType() != CNormalItem::VARIABLE) return false;
4772 
4773  if (pNormalItem->getName() != "A") return false;
4774 
4775  return result;
4776 }
4777 
4778 // 4 != A
4779 bool test_normalform::check_LogicalItemB(const CNormalLogicalItem* pLogicalItem)
4780 {
4781  bool result = true;
4782 
4783  if (pLogicalItem == NULL) return false;
4784 
4785  if (pLogicalItem->getType() != CNormalLogicalItem::NE) return false;
4786 
4787  const CNormalFraction* pTmpFraction = &pLogicalItem->getLeft();
4788 
4789  if (pTmpFraction == NULL) return false;
4790 
4791  if (pTmpFraction->checkDenominatorOne() != true) return false;
4792 
4793  const CNormalSum* pNumerator = &pTmpFraction->getNumerator();
4794 
4795  if (pNumerator->getFractions().size() != 0) return false;
4796 
4797  const std::set<CNormalProduct*, compareProducts >* pProducts = &pNumerator->getProducts();
4798 
4799  if (pProducts->size() != 1) return false;
4800 
4801  const CNormalProduct* pProduct = *(pProducts->begin());
4802 
4803  if (pProduct == NULL) return false;
4804 
4805  if (pProduct->getFactor() != 4.0) return false;
4806 
4807  if (pProduct->getItemPowers().size() != 0) return false;
4808 
4809  pTmpFraction = &pLogicalItem->getRight();
4810 
4811  if (pTmpFraction == NULL) return false;
4812 
4813  if (pTmpFraction->checkDenominatorOne() != true) return false;
4814 
4815  pNumerator = &pTmpFraction->getNumerator();
4816 
4817  if (pNumerator->getFractions().size() != 0) return false;
4818 
4819  pProducts = &pNumerator->getProducts();
4820 
4821  if (pProducts->size() != 1) return false;
4822 
4823  pProduct = *(pProducts->begin());
4824 
4825  if (pProduct == NULL) return false;
4826 
4827  if (pProduct->getFactor() != 1.0) return false;
4828 
4829  if (pProduct->getItemPowers().size() != 1) return false;
4830 
4831  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
4832 
4833  if (pItemPower == NULL) return false;
4834 
4835  if (pItemPower->getExp() != 1.0) return false;
4836 
4837  if (pItemPower->getItemType() != CNormalItemPower::ITEM) return false;
4838 
4839  const CNormalItem* pNormalItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
4840 
4841  if (pNormalItem == NULL) return false;
4842 
4843  if (pNormalItem->getType() != CNormalItem::VARIABLE) return false;
4844 
4845  if (pNormalItem->getName() != "A") return false;
4846 
4847  return result;
4848 }
4849 
4850 //2==T
4851 bool test_normalform::check_LogicalItemC(const CNormalLogicalItem* pLogicalItem)
4852 {
4853  bool result = true;
4854 
4855  if (pLogicalItem == NULL) return false;
4856 
4857  if (pLogicalItem->getType() != CNormalLogicalItem::EQ) return false;
4858 
4859  const CNormalFraction* pTmpFraction = &pLogicalItem->getLeft();
4860 
4861  if (pTmpFraction == NULL) return false;
4862 
4863  if (pTmpFraction->checkDenominatorOne() != true) return false;
4864 
4865  const CNormalSum* numerator = &pTmpFraction->getNumerator();
4866 
4867  if (numerator->getFractions().size() != 0) return false;
4868 
4869  const std::set<CNormalProduct*, compareProducts >* products = &numerator->getProducts();
4870 
4871  if (products->size() != 1) return false;
4872 
4873  const CNormalProduct* pProduct = *(products->begin());
4874 
4875  if (pProduct == NULL) return false;
4876 
4877  if (pProduct->getFactor() != 2.0) return false;
4878 
4879  if (pProduct->getItemPowers().size() != 0) return false;
4880 
4881  pTmpFraction = &pLogicalItem->getRight();
4882 
4883  if (pTmpFraction == NULL) return false;
4884 
4885  if (pTmpFraction->checkDenominatorOne() != true) return false;
4886 
4887  numerator = &pTmpFraction->getNumerator();
4888 
4889  if (numerator->getFractions().size() != 0) return false;
4890 
4891  products = &numerator->getProducts();
4892 
4893  if (products->size() != 1) return false;
4894 
4895  pProduct = *(products->begin());
4896 
4897  if (pProduct == NULL) return false;
4898 
4899  if (pProduct->getFactor() != 1.0) return false;
4900 
4901  if (pProduct->getItemPowers().size() != 1) return false;
4902 
4903  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
4904 
4905  if (pItemPower == NULL) return false;
4906 
4907  if (pItemPower->getExp() != 1.0) return false;
4908 
4909  if (pItemPower->getItemType() != CNormalItemPower::ITEM) return false;
4910 
4911  const CNormalItem* pNormalItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
4912 
4913  if (pNormalItem == NULL) return false;
4914 
4915  if (pNormalItem->getType() != CNormalItem::VARIABLE) return false;
4916 
4917  if (pNormalItem->getName() != "T") return false;
4918 
4919  return result;
4920 }
4921 
4922 // D == F
4923 bool test_normalform::check_LogicalItemNotD(const CNormalLogicalItem* pLogicalItem)
4924 {
4925  bool result = true;
4926 
4927  if (pLogicalItem == NULL) return false;
4928 
4929  if (pLogicalItem->getType() != CNormalLogicalItem::EQ) return false;
4930 
4931  const CNormalFraction* pTmpFraction = &pLogicalItem->getLeft();
4932 
4933  if (pTmpFraction == NULL) return false;
4934 
4935  if (pTmpFraction->checkDenominatorOne() != true) return false;
4936 
4937  const CNormalSum* numerator = &pTmpFraction->getNumerator();
4938 
4939  if (numerator->getFractions().size() != 0) return false;
4940 
4941  const std::set<CNormalProduct*, compareProducts >* products = &numerator->getProducts();
4942 
4943  if (products->size() != 1) return false;
4944 
4945  const CNormalProduct* pProduct = *(products->begin());
4946 
4947  if (pProduct == NULL) return false;
4948 
4949  if (pProduct->getFactor() != 1.0) return false;
4950 
4951  if (pProduct->getItemPowers().size() != 1) return false;
4952 
4953  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
4954 
4955  if (pItemPower == NULL) return false;
4956 
4957  if (pItemPower->getExp() != 1.0) return false;
4958 
4959  if (pItemPower->getItemType() != CNormalItemPower::ITEM) return false;
4960 
4961  const CNormalItem* pNormalItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
4962 
4963  if (pNormalItem == NULL) return false;
4964 
4965  if (pNormalItem->getType() != CNormalItem::VARIABLE) return false;
4966 
4967  if (pNormalItem->getName() != "D") return false;
4968 
4969  pTmpFraction = &pLogicalItem->getRight();
4970 
4971  if (pTmpFraction == NULL) return false;
4972 
4973  if (pTmpFraction->checkDenominatorOne() != true) return false;
4974 
4975  numerator = &pTmpFraction->getNumerator();
4976 
4977  if (numerator->getFractions().size() != 0) return false;
4978 
4979  products = &numerator->getProducts();
4980 
4981  if (products->size() != 1) return false;
4982 
4983  pProduct = *(products->begin());
4984 
4985  if (pProduct == NULL) return false;
4986 
4987  if (pProduct->getFactor() != 1.0) return false;
4988 
4989  if (pProduct->getItemPowers().size() != 1) return false;
4990 
4991  pItemPower = *(pProduct->getItemPowers().begin());
4992 
4993  if (pItemPower == NULL) return false;
4994 
4995  if (pItemPower->getExp() != 1.0) return false;
4996 
4997  if (pItemPower->getItemType() != CNormalItemPower::ITEM) return false;
4998 
4999  pNormalItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
5000 
5001  if (pNormalItem == NULL) return false;
5002 
5003  if (pNormalItem->getType() != CNormalItem::VARIABLE) return false;
5004 
5005  if (pNormalItem->getName() != "F") return false;
5006 
5007  return result;
5008 }
5009 
5010 // SIN(PI*D) < X
5011 bool test_normalform::check_LogicalItemE(const CNormalLogicalItem* pLogicalItem)
5012 {
5013  bool result = true;
5014 
5015  if (pLogicalItem == NULL) return false;
5016 
5017  if (pLogicalItem->getType() != CNormalLogicalItem::LT) return false;
5018 
5019  const CNormalFraction* pTmpFraction = &pLogicalItem->getLeft();
5020 
5021  if (pTmpFraction == NULL) return false;
5022 
5023  const CNormalSum* numerator = &pTmpFraction->getNumerator();
5024 
5025  if (numerator->getFractions().size() != 0) return false;
5026 
5027  const std::set<CNormalProduct*, compareProducts >* products = &numerator->getProducts();
5028 
5029  if (products->size() != 1) return false;
5030 
5031  const CNormalProduct* pProduct = *(products->begin());
5032 
5033  if (pProduct == NULL) return false;
5034 
5035  if (pProduct->getFactor() != 1.0) return false;
5036 
5037  if (pProduct->getItemPowers().size() != 1) return false;
5038 
5039  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
5040 
5041  if (pItemPower == NULL) return false;
5042 
5043  if (pItemPower->getExp() != 1.0) return false;
5044 
5045  if (pItemPower->getItemType() != CNormalItemPower::FUNCTION) return false;
5046 
5047  const CNormalFunction* pFunction = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
5048 
5049  if (pFunction == NULL) return false;
5050 
5051  if (pFunction->getType() != CNormalFunction::SIN) return false;
5052 
5053  pTmpFraction = &pFunction->getFraction();
5054 
5055  if (pTmpFraction == NULL) return false;
5056 
5057  if (pTmpFraction->checkDenominatorOne() != true) return false;
5058 
5059  numerator = &pTmpFraction->getNumerator();
5060 
5061  if (numerator->getFractions().size() != 0) return false;
5062 
5063  products = &numerator->getProducts();
5064 
5065  if (products->size() != 1) return false;
5066 
5067  ProductIterator productsIt = products->begin();
5068  pProduct = *(productsIt);
5069 
5070  if (pProduct == NULL) return false;
5071 
5072  if (pProduct->getFactor() != 1.0) return false;
5073 
5074  if (pProduct->getItemPowers().size() != 2) return false;
5075 
5076  std::set<CNormalItemPower*, compareItemPowers>::const_iterator itemPowersIt = pProduct->getItemPowers().begin();
5077  pItemPower = *(itemPowersIt);
5078 
5079  if (pItemPower == NULL) return false;
5080 
5081  if (pItemPower->getExp() != 1.0) return false;
5082 
5083  if (pItemPower->getItemType() != CNormalItemPower::ITEM) return false;
5084 
5085  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
5086 
5087  if (pItem == NULL) return false;
5088 
5089  if (pItem->getType() != CNormalItem::CONSTANT) return false;
5090 
5091  if (pItem->getName() != "PI") return false;
5092 
5093  ++itemPowersIt;
5094  pItemPower = *(itemPowersIt);
5095 
5096  if (pItemPower == NULL) return false;
5097 
5098  if (pItemPower->getExp() != 1.0) return false;
5099 
5100  if (pItemPower->getItemType() != CNormalItemPower::ITEM) return false;
5101 
5102  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
5103 
5104  if (pItem == NULL) return false;
5105 
5106  if (pItem->getType() != CNormalItem::VARIABLE) return false;
5107 
5108  if (pItem->getName() != "D") return false;
5109 
5110  pTmpFraction = &pLogicalItem->getRight();
5111 
5112  if (pTmpFraction == NULL) return false;
5113 
5114  numerator = &pTmpFraction->getNumerator();
5115 
5116  if (numerator->getFractions().size() != 0) return false;
5117 
5118  products = &numerator->getProducts();
5119 
5120  if (products->size() != 1) return false;
5121 
5122  pProduct = *(products->begin());
5123 
5124  if (pProduct == NULL) return false;
5125 
5126  if (pProduct->getFactor() != 1.0) return false;
5127 
5128  if (pProduct->getItemPowers().size() != 1) return false;
5129 
5130  pItemPower = *(pProduct->getItemPowers().begin());
5131 
5132  if (pItemPower == NULL) return false;
5133 
5134  if (pItemPower->getExp() != 1.0) return false;
5135 
5136  if (pItemPower->getItemType() != CNormalItemPower::ITEM) return false;
5137 
5138  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
5139 
5140  if (pItem == NULL) return false;
5141 
5142  if (pItem->getType() != CNormalItem::VARIABLE) return false;
5143 
5144  if (pItem->getName() != "X") return false;
5145 
5146  return result;
5147 }
5148 
5149 // 2*T^(3*J) != 6.2
5150 bool test_normalform::check_LogicalItemF(const CNormalLogicalItem* pLogicalItem)
5151 {
5152  bool result = true;
5153 
5154  if (pLogicalItem == NULL) return false;
5155 
5156  if (pLogicalItem->getType() != CNormalLogicalItem::NE) return false;
5157 
5158  const CNormalFraction* pTmpFraction = &pLogicalItem->getLeft();
5159 
5160  if (pTmpFraction == NULL) return false;
5161 
5162  if (pTmpFraction->checkDenominatorOne() == false) return false;
5163 
5164  const CNormalSum* numerator = &pTmpFraction->getNumerator();
5165 
5166  if (numerator->getFractions().size() != 0) return false;
5167 
5168  const std::set<CNormalProduct*, compareProducts >* products = &numerator->getProducts();
5169 
5170  if (products->size() != 1) return false;
5171 
5172  const CNormalProduct* pProduct = *(products->begin());
5173 
5174  if (pProduct == NULL) return false;
5175 
5176  if (pProduct->getFactor() != 2.0) return false;
5177 
5178  if (pProduct->getItemPowers().size() != 1) return false;
5179 
5180  const CNormalItemPower* pItemPower = *pProduct->getItemPowers().begin();
5181 
5182  if (pItemPower->getExp() != 1.0) return false;
5183 
5184  if (pItemPower->getItemType() != CNormalItemPower::POWER) return false;
5185 
5186  const CNormalGeneralPower* pGeneralPower = dynamic_cast<const CNormalGeneralPower*>(&pItemPower->getItem());
5187 
5188  if (pGeneralPower == NULL) return false;
5189 
5190  // check this general power which should be (t^(3*J))
5191  if (pGeneralPower->getType() != CNormalGeneralPower::POWER) return false;
5192 
5193  pTmpFraction = &pGeneralPower->getLeft();
5194 
5195  if (pTmpFraction == NULL) return false;
5196 
5197  if (pTmpFraction->checkDenominatorOne() != true) return false;
5198 
5199  numerator = &pTmpFraction->getNumerator();
5200 
5201  if (numerator->getFractions().size() != 0) return false;
5202 
5203  products = &numerator->getProducts();
5204 
5205  if (products->size() != 1) return false;
5206 
5207  pProduct = *(products->begin());
5208 
5209  if (pProduct == NULL) return false;
5210 
5211  if (pProduct->getFactor() != 1.0) return false;
5212 
5213  if (pProduct->getItemPowers().size() != 1) return false;
5214 
5215  pItemPower = *(pProduct->getItemPowers().begin());
5216 
5217  if (pItemPower == NULL) return false;
5218 
5219  if (pItemPower->getExp() != 1.0) return false;
5220 
5221  if (pItemPower->getItemType() != CNormalItemPower::ITEM) return false;
5222 
5223  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
5224 
5225  if (pItem == NULL) return false;
5226 
5227  if (pItem->getType() != CNormalItem::VARIABLE) return false;
5228 
5229  if (pItem->getName() != "T") return false;
5230 
5231  pTmpFraction = &pGeneralPower->getRight();
5232 
5233  if (pTmpFraction == NULL) return false;
5234 
5235  if (pTmpFraction->checkDenominatorOne() != true) return false;
5236 
5237  numerator = &pTmpFraction->getNumerator();
5238 
5239  if (numerator->getFractions().size() != 0) return false;
5240 
5241  products = &numerator->getProducts();
5242 
5243  if (products->size() != 1) return false;
5244 
5245  pProduct = *(products->begin());
5246 
5247  if (pProduct == NULL) return false;
5248 
5249  if (pProduct->getFactor() != 3.0) return false;
5250 
5251  if (pProduct->getItemPowers().size() != 1) return false;
5252 
5253  pItemPower = *(pProduct->getItemPowers().begin());
5254 
5255  if (pItemPower == NULL) return false;
5256 
5257  if (pItemPower->getExp() != 1.0) return false;
5258 
5259  if (pItemPower->getItemType() != CNormalItemPower::ITEM) return false;
5260 
5261  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
5262 
5263  if (pItem == NULL) return false;
5264 
5265  if (pItem->getType() != CNormalItem::VARIABLE) return false;
5266 
5267  if (pItem->getName() != "J") return false;
5268 
5269  pTmpFraction = &pLogicalItem->getRight();
5270 
5271  if (pTmpFraction == NULL) return false;
5272 
5273  if (pTmpFraction->checkDenominatorOne() != true) return false;
5274 
5275  numerator = &pTmpFraction->getNumerator();
5276 
5277  if (numerator->getFractions().size() != 0) return false;
5278 
5279  products = &numerator->getProducts();
5280 
5281  if (products->size() != 1) return false;
5282 
5283  pProduct = *(products->begin());
5284 
5285  if (pProduct == NULL) return false;
5286 
5287  if (pProduct->getFactor() != 6.2) return false;
5288 
5289  if (pProduct->getItemPowers().size() != 0) return false;
5290 
5291  return result;
5292 }
5293 
5294 // A <= PI
5295 bool test_normalform::check_LogicalItemNotA(const CNormalLogicalItem* pLogicalItem)
5296 {
5297  bool result = true;
5298 
5299  if (pLogicalItem == NULL) return false;
5300 
5301  if (pLogicalItem->getType() != CNormalLogicalItem::LE) return false;
5302 
5303  const CNormalFraction* pTmpFraction = &pLogicalItem->getLeft();
5304 
5305  if (pTmpFraction == NULL) return false;
5306 
5307  if (pTmpFraction->checkDenominatorOne() != true) return false;
5308 
5309  const CNormalSum* pNumerator = &pTmpFraction->getNumerator();
5310 
5311  if (pNumerator->getFractions().size() != 0) return false;
5312 
5313  const std::set<CNormalProduct*, compareProducts >* pProducts = &pNumerator->getProducts();
5314 
5315  if (pProducts->size() != 1) return false;
5316 
5317  const CNormalProduct* pProduct = *(pProducts->begin());
5318 
5319  if (pProduct == NULL) return false;
5320 
5321  if (pProduct->getFactor() != 1.0) return false;
5322 
5323  if (pProduct->getItemPowers().size() != 1) return false;
5324 
5325  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
5326 
5327  if (pItemPower == NULL) return false;
5328 
5329  if (pItemPower->getExp() != 1.0) return false;
5330 
5331  if (pItemPower->getItemType() != CNormalItemPower::ITEM) return false;
5332 
5333  const CNormalItem* pNormalItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
5334 
5335  if (pNormalItem == NULL) return false;
5336 
5337  if (pNormalItem->getType() != CNormalItem::VARIABLE) return false;
5338 
5339  if (pNormalItem->getName() != "A") return false;
5340 
5341  pTmpFraction = &pLogicalItem->getRight();
5342 
5343  if (pTmpFraction == NULL) return false;
5344 
5345  if (pTmpFraction->checkDenominatorOne() != true) return false;
5346 
5347  pNumerator = &pTmpFraction->getNumerator();
5348 
5349  if (pNumerator->getFractions().size() != 0) return false;
5350 
5351  pProducts = &pNumerator->getProducts();
5352 
5353  if (pProducts->size() != 1) return false;
5354 
5355  pProduct = *(pProducts->begin());
5356 
5357  if (pProduct == NULL) return false;
5358 
5359  if (pProduct->getFactor() != 1.0) return false;
5360 
5361  if (pProduct->getItemPowers().size() != 1) return false;
5362 
5363  pItemPower = *(pProduct->getItemPowers().begin());
5364 
5365  if (pItemPower == NULL) return false;
5366 
5367  if (pItemPower->getExp() != 1.0) return false;
5368 
5369  if (pItemPower->getItemType() != CNormalItemPower::ITEM) return false;
5370 
5371  pNormalItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
5372 
5373  if (pNormalItem == NULL) return false;
5374 
5375  if (pNormalItem->getType() != CNormalItem::CONSTANT) return false;
5376 
5377  if (pNormalItem->getName() != "PI") return false;
5378 
5379  return result;
5380 }
5381 
5382 // 4 == A
5383 bool test_normalform::check_LogicalItemNotB(const CNormalLogicalItem* pLogicalItem)
5384 {
5385  bool result = true;
5386 
5387  if (pLogicalItem == NULL) return false;
5388 
5389  if (pLogicalItem->getType() != CNormalLogicalItem::EQ) return false;
5390 
5391  const CNormalFraction* pTmpFraction = &pLogicalItem->getLeft();
5392 
5393  if (pTmpFraction == NULL) return false;
5394 
5395  if (pTmpFraction->checkDenominatorOne() != true) return false;
5396 
5397  const CNormalSum* pNumerator = &pTmpFraction->getNumerator();
5398 
5399  if (pNumerator->getFractions().size() != 0) return false;
5400 
5401  const std::set<CNormalProduct*, compareProducts >* pProducts = &pNumerator->getProducts();
5402 
5403  if (pProducts->size() != 1) return false;
5404 
5405  const CNormalProduct* pProduct = *(pProducts->begin());
5406 
5407  if (pProduct == NULL) return false;
5408 
5409  if (pProduct->getFactor() != 4.0) return false;
5410 
5411  if (pProduct->getItemPowers().size() != 0) return false;
5412 
5413  pTmpFraction = &pLogicalItem->getRight();
5414 
5415  if (pTmpFraction == NULL) return false;
5416 
5417  if (pTmpFraction->checkDenominatorOne() != true) return false;
5418 
5419  pNumerator = &pTmpFraction->getNumerator();
5420 
5421  if (pNumerator->getFractions().size() != 0) return false;
5422 
5423  pProducts = &pNumerator->getProducts();
5424 
5425  if (pProducts->size() != 1) return false;
5426 
5427  pProduct = *(pProducts->begin());
5428 
5429  if (pProduct == NULL) return false;
5430 
5431  if (pProduct->getFactor() != 1.0) return false;
5432 
5433  if (pProduct->getItemPowers().size() != 1) return false;
5434 
5435  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
5436 
5437  if (pItemPower == NULL) return false;
5438 
5439  if (pItemPower->getExp() != 1.0) return false;
5440 
5441  if (pItemPower->getItemType() != CNormalItemPower::ITEM) return false;
5442 
5443  const CNormalItem* pNormalItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
5444 
5445  if (pNormalItem == NULL) return false;
5446 
5447  if (pNormalItem->getType() != CNormalItem::VARIABLE) return false;
5448 
5449  if (pNormalItem->getName() != "A") return false;
5450 
5451  return result;
5452 }
5453 
5454 // 2!=T
5455 bool test_normalform::check_LogicalItemNotC(const CNormalLogicalItem* pLogicalItem)
5456 {
5457  bool result = true;
5458 
5459  if (pLogicalItem == NULL) return false;
5460 
5461  if (pLogicalItem->getType() != CNormalLogicalItem::NE) return false;
5462 
5463  const CNormalFraction* pTmpFraction = &pLogicalItem->getLeft();
5464 
5465  if (pTmpFraction == NULL) return false;
5466 
5467  if (pTmpFraction->checkDenominatorOne() != true) return false;
5468 
5469  const CNormalSum* numerator = &pTmpFraction->getNumerator();
5470 
5471  if (numerator->getFractions().size() != 0) return false;
5472 
5473  const std::set<CNormalProduct*, compareProducts >* products = &numerator->getProducts();
5474 
5475  if (products->size() != 1) return false;
5476 
5477  const CNormalProduct* pProduct = *(products->begin());
5478 
5479  if (pProduct == NULL) return false;
5480 
5481  if (pProduct->getFactor() != 2.0) return false;
5482 
5483  if (pProduct->getItemPowers().size() != 0) return false;
5484 
5485  pTmpFraction = &pLogicalItem->getRight();
5486 
5487  if (pTmpFraction == NULL) return false;
5488 
5489  if (pTmpFraction->checkDenominatorOne() != true) return false;
5490 
5491  numerator = &pTmpFraction->getNumerator();
5492 
5493  if (numerator->getFractions().size() != 0) return false;
5494 
5495  products = &numerator->getProducts();
5496 
5497  if (products->size() != 1) return false;
5498 
5499  pProduct = *(products->begin());
5500 
5501  if (pProduct == NULL) return false;
5502 
5503  if (pProduct->getFactor() != 1.0) return false;
5504 
5505  if (pProduct->getItemPowers().size() != 1) return false;
5506 
5507  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
5508 
5509  if (pItemPower == NULL) return false;
5510 
5511  if (pItemPower->getExp() != 1.0) return false;
5512 
5513  if (pItemPower->getItemType() != CNormalItemPower::ITEM) return false;
5514 
5515  const CNormalItem* pNormalItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
5516 
5517  if (pNormalItem == NULL) return false;
5518 
5519  if (pNormalItem->getType() != CNormalItem::VARIABLE) return false;
5520 
5521  if (pNormalItem->getName() != "T") return false;
5522 
5523  return result;
5524 }
5525 
5526 // D != F
5527 bool test_normalform::check_LogicalItemD(const CNormalLogicalItem* pLogicalItem)
5528 {
5529  bool result = true;
5530 
5531  if (pLogicalItem == NULL) return false;
5532 
5533  if (pLogicalItem->getType() != CNormalLogicalItem::NE) return false;
5534 
5535  const CNormalFraction* pTmpFraction = &pLogicalItem->getLeft();
5536 
5537  if (pTmpFraction == NULL) return false;
5538 
5539  if (pTmpFraction->checkDenominatorOne() != true) return false;
5540 
5541  const CNormalSum* numerator = &pTmpFraction->getNumerator();
5542 
5543  if (numerator->getFractions().size() != 0) return false;
5544 
5545  const std::set<CNormalProduct*, compareProducts >* products = &numerator->getProducts();
5546 
5547  if (products->size() != 1) return false;
5548 
5549  const CNormalProduct* pProduct = *(products->begin());
5550 
5551  if (pProduct == NULL) return false;
5552 
5553  if (pProduct->getFactor() != 1.0) return false;
5554 
5555  if (pProduct->getItemPowers().size() != 1) return false;
5556 
5557  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
5558 
5559  if (pItemPower == NULL) return false;
5560 
5561  if (pItemPower->getExp() != 1.0) return false;
5562 
5563  if (pItemPower->getItemType() != CNormalItemPower::ITEM) return false;
5564 
5565  const CNormalItem* pNormalItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
5566 
5567  if (pNormalItem == NULL) return false;
5568 
5569  if (pNormalItem->getType() != CNormalItem::VARIABLE) return false;
5570 
5571  if (pNormalItem->getName() != "D") return false;
5572 
5573  pTmpFraction = &pLogicalItem->getRight();
5574 
5575  if (pTmpFraction == NULL) return false;
5576 
5577  if (pTmpFraction->checkDenominatorOne() != true) return false;
5578 
5579  numerator = &pTmpFraction->getNumerator();
5580 
5581  if (numerator->getFractions().size() != 0) return false;
5582 
5583  products = &numerator->getProducts();
5584 
5585  if (products->size() != 1) return false;
5586 
5587  pProduct = *(products->begin());
5588 
5589  if (pProduct == NULL) return false;
5590 
5591  if (pProduct->getFactor() != 1.0) return false;
5592 
5593  if (pProduct->getItemPowers().size() != 1) return false;
5594 
5595  pItemPower = *(pProduct->getItemPowers().begin());
5596 
5597  if (pItemPower == NULL) return false;
5598 
5599  if (pItemPower->getExp() != 1.0) return false;
5600 
5601  if (pItemPower->getItemType() != CNormalItemPower::ITEM) return false;
5602 
5603  pNormalItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
5604 
5605  if (pNormalItem == NULL) return false;
5606 
5607  if (pNormalItem->getType() != CNormalItem::VARIABLE) return false;
5608 
5609  if (pNormalItem->getName() != "F") return false;
5610 
5611  return result;
5612 }
5613 
5614 // X <= SIN(PI*D)
5615 bool test_normalform::check_LogicalItemNotE(const CNormalLogicalItem* pLogicalItem)
5616 {
5617  bool result = true;
5618 
5619  if (pLogicalItem == NULL) return false;
5620 
5621  if (pLogicalItem->getType() != CNormalLogicalItem::LE) return false;
5622 
5623  const CNormalFraction* pTmpFraction = &pLogicalItem->getLeft();
5624 
5625  if (pTmpFraction == NULL) return false;
5626 
5627  const CNormalSum* numerator = &pTmpFraction->getNumerator();
5628 
5629  if (numerator->getFractions().size() != 0) return false;
5630 
5631  const std::set<CNormalProduct*, compareProducts >* products = &numerator->getProducts();
5632 
5633  if (products->size() != 1) return false;
5634 
5635  const CNormalProduct* pProduct = *(products->begin());
5636 
5637  if (pProduct == NULL) return false;
5638 
5639  if (pProduct->getFactor() != 1.0) return false;
5640 
5641  if (pProduct->getItemPowers().size() != 1) return false;
5642 
5643  const CNormalItemPower* pItemPower = *(pProduct->getItemPowers().begin());
5644 
5645  if (pItemPower == NULL) return false;
5646 
5647  if (pItemPower->getExp() != 1.0) return false;
5648 
5649  if (pItemPower->getItemType() != CNormalItemPower::ITEM) return false;
5650 
5651  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
5652 
5653  if (pItem == NULL) return false;
5654 
5655  if (pItem->getType() != CNormalItem::VARIABLE) return false;
5656 
5657  if (pItem->getName() != "X") return false;
5658 
5659  pTmpFraction = &pLogicalItem->getRight();
5660 
5661  if (pTmpFraction == NULL) return false;
5662 
5663  numerator = &pTmpFraction->getNumerator();
5664 
5665  if (numerator->getFractions().size() != 0) return false;
5666 
5667  products = &numerator->getProducts();
5668 
5669  if (products->size() != 1) return false;
5670 
5671  pProduct = *(products->begin());
5672 
5673  if (pProduct == NULL) return false;
5674 
5675  if (pProduct->getFactor() != 1.0) return false;
5676 
5677  if (pProduct->getItemPowers().size() != 1) return false;
5678 
5679  pItemPower = *(pProduct->getItemPowers().begin());
5680 
5681  if (pItemPower == NULL) return false;
5682 
5683  if (pItemPower->getExp() != 1.0) return false;
5684 
5685  if (pItemPower->getItemType() != CNormalItemPower::FUNCTION) return false;
5686 
5687  const CNormalFunction* pFunction = dynamic_cast<const CNormalFunction*>(&pItemPower->getItem());
5688 
5689  if (pFunction == NULL) return false;
5690 
5691  if (pFunction->getType() != CNormalFunction::SIN) return false;
5692 
5693  pTmpFraction = &pFunction->getFraction();
5694 
5695  if (pTmpFraction == NULL) return false;
5696 
5697  if (pTmpFraction->checkDenominatorOne() != true) return false;
5698 
5699  numerator = &pTmpFraction->getNumerator();
5700 
5701  if (numerator->getFractions().size() != 0) return false;
5702 
5703  products = &numerator->getProducts();
5704 
5705  if (products->size() != 1) return false;
5706 
5707  ProductIterator productsIt = products->begin();
5708  pProduct = *(productsIt);
5709 
5710  if (pProduct == NULL) return false;
5711 
5712  if (pProduct->getFactor() != 1.0) return false;
5713 
5714  if (pProduct->getItemPowers().size() != 2) return false;
5715 
5716  std::set<CNormalItemPower*, compareItemPowers>::const_iterator itemPowersIt = pProduct->getItemPowers().begin();
5717  pItemPower = *(itemPowersIt);
5718 
5719  if (pItemPower == NULL) return false;
5720 
5721  if (pItemPower->getExp() != 1.0) return false;
5722 
5723  if (pItemPower->getItemType() != CNormalItemPower::ITEM) return false;
5724 
5725  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
5726 
5727  if (pItem == NULL) return false;
5728 
5729  if (pItem->getType() != CNormalItem::CONSTANT) return false;
5730 
5731  if (pItem->getName() != "PI") return false;
5732 
5733  ++itemPowersIt;
5734  pItemPower = *(itemPowersIt);
5735 
5736  if (pItemPower == NULL) return false;
5737 
5738  if (pItemPower->getExp() != 1.0) return false;
5739 
5740  if (pItemPower->getItemType() != CNormalItemPower::ITEM) return false;
5741 
5742  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
5743 
5744  if (pItem == NULL) return false;
5745 
5746  if (pItem->getType() != CNormalItem::VARIABLE) return false;
5747 
5748  if (pItem->getName() != "D") return false;
5749 
5750  return result;
5751 }
5752 
5753 // 2*T^(3*J) == 6.2
5754 bool test_normalform::check_LogicalItemNotF(const CNormalLogicalItem* pLogicalItem)
5755 {
5756  bool result = true;
5757 
5758  if (pLogicalItem == NULL) return false;
5759 
5760  if (pLogicalItem->getType() != CNormalLogicalItem::EQ) return false;
5761 
5762  const CNormalFraction* pTmpFraction = &pLogicalItem->getLeft();
5763 
5764  if (pTmpFraction == NULL) return false;
5765 
5766  if (pTmpFraction->checkDenominatorOne() != true) return false;
5767 
5768  const CNormalSum* numerator = &pTmpFraction->getNumerator();
5769 
5770  if (numerator->getFractions().size() != 0) return false;
5771 
5772  const std::set<CNormalProduct*, compareProducts >* products = &numerator->getProducts();
5773 
5774  if (products->size() != 1) return false;
5775 
5776  const CNormalProduct* pProduct = *(products->begin());
5777 
5778  if (pProduct == NULL) return false;
5779 
5780  if (pProduct->getFactor() != 2.0) return false;
5781 
5782  if (pProduct->getItemPowers().size() != 1) return false;
5783 
5784  const CNormalItemPower* pItemPower = *pProduct->getItemPowers().begin();
5785 
5786  if (pItemPower->getExp() != 1.0) return false;
5787 
5788  if (pItemPower->getItemType() != CNormalItemPower::POWER) return false;
5789 
5790  const CNormalGeneralPower* pGeneralPower = dynamic_cast<const CNormalGeneralPower*>(&pItemPower->getItem());
5791 
5792  if (pGeneralPower == NULL) return false;
5793 
5794  // check this general power which should be (t^(3*J))
5795  if (pGeneralPower->getType() != CNormalGeneralPower::POWER) return false;
5796 
5797  pTmpFraction = &pGeneralPower->getLeft();
5798 
5799  if (pTmpFraction == NULL) return false;
5800 
5801  if (pTmpFraction->checkDenominatorOne() != true) return false;
5802 
5803  numerator = &pTmpFraction->getNumerator();
5804 
5805  if (numerator->getFractions().size() != 0) return false;
5806 
5807  products = &numerator->getProducts();
5808 
5809  if (products->size() != 1) return false;
5810 
5811  pProduct = *(products->begin());
5812 
5813  if (pProduct == NULL) return false;
5814 
5815  if (pProduct->getFactor() != 1.0) return false;
5816 
5817  if (pProduct->getItemPowers().size() != 1) return false;
5818 
5819  pItemPower = *(pProduct->getItemPowers().begin());
5820 
5821  if (pItemPower == NULL) return false;
5822 
5823  if (pItemPower->getExp() != 1.0) return false;
5824 
5825  if (pItemPower->getItemType() != CNormalItemPower::ITEM) return false;
5826 
5827  const CNormalItem* pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
5828 
5829  if (pItem == NULL) return false;
5830 
5831  if (pItem->getType() != CNormalItem::VARIABLE) return false;
5832 
5833  if (pItem->getName() != "T") return false;
5834 
5835  pTmpFraction = &pGeneralPower->getRight();
5836 
5837  if (pTmpFraction == NULL) return false;
5838 
5839  if (pTmpFraction->checkDenominatorOne() != true) return false;
5840 
5841  numerator = &pTmpFraction->getNumerator();
5842 
5843  if (numerator->getFractions().size() != 0) return false;
5844 
5845  products = &numerator->getProducts();
5846 
5847  if (products->size() != 1) return false;
5848 
5849  pProduct = *(products->begin());
5850 
5851  if (pProduct == NULL) return false;
5852 
5853  if (pProduct->getFactor() != 3.0) return false;
5854 
5855  if (pProduct->getItemPowers().size() != 1) return false;
5856 
5857  pItemPower = *(pProduct->getItemPowers().begin());
5858 
5859  if (pItemPower == NULL) return false;
5860 
5861  if (pItemPower->getExp() != 1.0) return false;
5862 
5863  if (pItemPower->getItemType() != CNormalItemPower::ITEM) return false;
5864 
5865  pItem = dynamic_cast<const CNormalItem*>(&pItemPower->getItem());
5866 
5867  if (pItem == NULL) return false;
5868 
5869  if (pItem->getType() != CNormalItem::VARIABLE) return false;
5870 
5871  if (pItem->getName() != "J") return false;
5872 
5873  pTmpFraction = &pLogicalItem->getRight();
5874 
5875  if (pTmpFraction == NULL) return false;
5876 
5877  if (pTmpFraction->checkDenominatorOne() != true) return false;
5878 
5879  numerator = &pTmpFraction->getNumerator();
5880 
5881  if (numerator->getFractions().size() != 0) return false;
5882 
5883  products = &numerator->getProducts();
5884 
5885  if (products->size() != 1) return false;
5886 
5887  pProduct = *(products->begin());
5888 
5889  if (pProduct == NULL) return false;
5890 
5891  if (pProduct->getFactor() != 6.2) return false;
5892 
5893  if (pProduct->getItemPowers().size() != 0) return false;