Browse Source

Some minor changes in output of formulas

tempestpy_adaptions
Lanchid 12 years ago
parent
commit
f996829836
  1. 17
      src/formula/TimeBoundedOperator.h
  2. 5
      test/parser/CslParserTest.cpp

17
src/formula/TimeBoundedOperator.h

@ -8,6 +8,8 @@
#ifndef TIMEBOUNDEDOPERATOR_H_ #ifndef TIMEBOUNDEDOPERATOR_H_
#define TIMEBOUNDEDOPERATOR_H_ #define TIMEBOUNDEDOPERATOR_H_
#include <limits>
#include "AbstractPathFormula.h" #include "AbstractPathFormula.h"
#include "exceptions/InvalidArgumentException.h" #include "exceptions/InvalidArgumentException.h"
@ -85,11 +87,16 @@ public:
* May be used in subclasses to simplify string output. * May be used in subclasses to simplify string output.
*/ */
virtual std::string toString() const { virtual std::string toString() const {
std::string result = "[";
result += std::to_string(lowerBound);
result += ",";
result += std::to_string(upperBound);
result += "]";
std::string result = "";
if (upperBound == std::numeric_limits<double>::infinity()) {
result = ">=" + std::to_string(lowerBound);
} else {
result = "[";
result += std::to_string(lowerBound);
result += ",";
result += std::to_string(upperBound);
result += "]";
}
return result; return result;
} }

5
test/parser/CslParserTest.cpp

@ -121,10 +121,7 @@ TEST(CslParserTest, parseComplexFormulaTest) {
ASSERT_NE(cslParser->getFormula(), nullptr); ASSERT_NE(cslParser->getFormula(), nullptr);
//NOTE: This test case is dependent on the string output of the double value infinity.
// In g++ and clang++ on Linux, it is "inf". If some compiler (or library) uses a different output, please
// notify me and I will restructure this test case.
ASSERT_EQ("(S <= 0.500000 [P <= 0.500000 [a U c]] & (P > 0.500000 [G b] | !P < 0.400000 [G P > 0.900000 [F[7.000000,inf] (a & b)]]))", cslParser->getFormula()->toString());
ASSERT_EQ("(S <= 0.500000 [P <= 0.500000 [a U c]] & (P > 0.500000 [G b] | !P < 0.400000 [G P > 0.900000 [F>=7.000000 (a & b)]]))", cslParser->getFormula()->toString());
delete cslParser->getFormula(); delete cslParser->getFormula();
delete cslParser; delete cslParser;

Loading…
Cancel
Save