|
|
@ -9,11 +9,12 @@ |
|
|
|
#include "gtest/gtest.h"
|
|
|
|
#include "storm-config.h"
|
|
|
|
#include "src/parser/PrctlParser.h"
|
|
|
|
#include "src/parser/PrctlFileParser.h"
|
|
|
|
|
|
|
|
TEST(PrctlParserTest, parseApOnlyTest) { |
|
|
|
storm::parser::PrctlParser* prctlParser = nullptr; |
|
|
|
ASSERT_NO_THROW( |
|
|
|
prctlParser = new storm::parser::PrctlParser(STORM_CPP_TESTS_BASE_PATH "/parser/prctl_files/apOnly.prctl") |
|
|
|
prctlParser = new storm::parser::PrctlParser("P"); |
|
|
|
); |
|
|
|
|
|
|
|
ASSERT_NE(prctlParser->getFormula(), nullptr); |
|
|
@ -27,103 +28,103 @@ TEST(PrctlParserTest, parseApOnlyTest) { |
|
|
|
} |
|
|
|
|
|
|
|
TEST(PrctlParserTest, parsePropositionalFormulaTest) { |
|
|
|
storm::parser::PrctlParser* prctlParser = nullptr; |
|
|
|
storm::parser::PrctlFileParser* prctlFileParser = nullptr; |
|
|
|
ASSERT_NO_THROW( |
|
|
|
prctlParser = new storm::parser::PrctlParser(STORM_CPP_TESTS_BASE_PATH "/parser/prctl_files/propositionalFormula.prctl") |
|
|
|
prctlFileParser = new storm::parser::PrctlFileParser(STORM_CPP_TESTS_BASE_PATH "/parser/prctl_files/propositionalFormula.prctl") |
|
|
|
); |
|
|
|
|
|
|
|
ASSERT_NE(prctlParser->getFormula(), nullptr); |
|
|
|
ASSERT_NE(prctlFileParser->getFormula(), nullptr); |
|
|
|
|
|
|
|
|
|
|
|
ASSERT_EQ(prctlParser->getFormula()->toString(), "(!(a && b) || (a && !c))"); |
|
|
|
ASSERT_EQ(prctlFileParser->getFormula()->toString(), "(!(a && b) || (a && !c))"); |
|
|
|
|
|
|
|
delete prctlParser->getFormula(); |
|
|
|
delete prctlParser; |
|
|
|
delete prctlFileParser->getFormula(); |
|
|
|
delete prctlFileParser; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
TEST(PrctlParserTest, parseProbabilisticFormulaTest) { |
|
|
|
storm::parser::PrctlParser* prctlParser = nullptr; |
|
|
|
storm::parser::PrctlFileParser* prctlFileParser = nullptr; |
|
|
|
ASSERT_NO_THROW( |
|
|
|
prctlParser = new storm::parser::PrctlParser(STORM_CPP_TESTS_BASE_PATH "/parser/prctl_files/probabilisticFormula.prctl") |
|
|
|
prctlFileParser = new storm::parser::PrctlFileParser(STORM_CPP_TESTS_BASE_PATH "/parser/prctl_files/probabilisticFormula.prctl") |
|
|
|
); |
|
|
|
|
|
|
|
ASSERT_NE(prctlParser->getFormula(), nullptr); |
|
|
|
ASSERT_NE(prctlFileParser->getFormula(), nullptr); |
|
|
|
|
|
|
|
storm::formula::ProbabilisticBoundOperator<double>* op = static_cast<storm::formula::ProbabilisticBoundOperator<double>*>(prctlParser->getFormula()); |
|
|
|
storm::formula::ProbabilisticBoundOperator<double>* op = static_cast<storm::formula::ProbabilisticBoundOperator<double>*>(prctlFileParser->getFormula()); |
|
|
|
|
|
|
|
ASSERT_EQ(storm::formula::BoundOperator<double>::GREATER, op->getComparisonOperator()); |
|
|
|
ASSERT_EQ(0.5, op->getBound()); |
|
|
|
|
|
|
|
ASSERT_EQ(prctlParser->getFormula()->toString(), "P > 0.500000 [F a]"); |
|
|
|
ASSERT_EQ(prctlFileParser->getFormula()->toString(), "P > 0.500000 [F a]"); |
|
|
|
|
|
|
|
delete prctlParser->getFormula(); |
|
|
|
delete prctlParser; |
|
|
|
delete prctlFileParser->getFormula(); |
|
|
|
delete prctlFileParser; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
TEST(PrctlParserTest, parseRewardFormulaTest) { |
|
|
|
storm::parser::PrctlParser* prctlParser = nullptr; |
|
|
|
storm::parser::PrctlFileParser* prctlFileParser = nullptr; |
|
|
|
ASSERT_NO_THROW( |
|
|
|
prctlParser = new storm::parser::PrctlParser(STORM_CPP_TESTS_BASE_PATH "/parser/prctl_files/rewardFormula.prctl") |
|
|
|
prctlFileParser = new storm::parser::PrctlFileParser(STORM_CPP_TESTS_BASE_PATH "/parser/prctl_files/rewardFormula.prctl") |
|
|
|
); |
|
|
|
|
|
|
|
ASSERT_NE(prctlParser->getFormula(), nullptr); |
|
|
|
ASSERT_NE(prctlFileParser->getFormula(), nullptr); |
|
|
|
|
|
|
|
storm::formula::RewardBoundOperator<double>* op = static_cast<storm::formula::RewardBoundOperator<double>*>(prctlParser->getFormula()); |
|
|
|
storm::formula::RewardBoundOperator<double>* op = static_cast<storm::formula::RewardBoundOperator<double>*>(prctlFileParser->getFormula()); |
|
|
|
|
|
|
|
ASSERT_EQ(storm::formula::BoundOperator<double>::GREATER_EQUAL, op->getComparisonOperator()); |
|
|
|
ASSERT_EQ(15.0, op->getBound()); |
|
|
|
|
|
|
|
ASSERT_EQ(prctlParser->getFormula()->toString(), "R >= 15.000000 [(a U !b)]"); |
|
|
|
ASSERT_EQ(prctlFileParser->getFormula()->toString(), "R >= 15.000000 [(a U !b)]"); |
|
|
|
|
|
|
|
delete prctlParser->getFormula(); |
|
|
|
delete prctlParser; |
|
|
|
delete prctlFileParser->getFormula(); |
|
|
|
delete prctlFileParser; |
|
|
|
} |
|
|
|
|
|
|
|
TEST(PrctlParserTest, parseRewardNoBoundFormulaTest) { |
|
|
|
storm::parser::PrctlParser* prctlParser = nullptr; |
|
|
|
storm::parser::PrctlFileParser* prctlFileParser = nullptr; |
|
|
|
ASSERT_NO_THROW( |
|
|
|
prctlParser = new storm::parser::PrctlParser(STORM_CPP_TESTS_BASE_PATH "/parser/prctl_files/rewardNoBoundFormula.prctl") |
|
|
|
prctlFileParser = new storm::parser::PrctlFileParser(STORM_CPP_TESTS_BASE_PATH "/parser/prctl_files/rewardNoBoundFormula.prctl") |
|
|
|
); |
|
|
|
|
|
|
|
ASSERT_NE(prctlParser->getFormula(), nullptr); |
|
|
|
ASSERT_NE(prctlFileParser->getFormula(), nullptr); |
|
|
|
|
|
|
|
|
|
|
|
ASSERT_EQ(prctlParser->getFormula()->toString(), "R = ? [(a U<=4 (b && !c))]"); |
|
|
|
ASSERT_EQ(prctlFileParser->getFormula()->toString(), "R = ? [(a U<=4 (b && !c))]"); |
|
|
|
|
|
|
|
delete prctlParser->getFormula(); |
|
|
|
delete prctlParser; |
|
|
|
delete prctlFileParser->getFormula(); |
|
|
|
delete prctlFileParser; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
TEST(PrctlParserTest, parseProbabilisticNoBoundFormulaTest) { |
|
|
|
storm::parser::PrctlParser* prctlParser = nullptr; |
|
|
|
storm::parser::PrctlFileParser* prctlFileParser = nullptr; |
|
|
|
ASSERT_NO_THROW( |
|
|
|
prctlParser = new storm::parser::PrctlParser(STORM_CPP_TESTS_BASE_PATH "/parser/prctl_files/probabilisticNoBoundFormula.prctl") |
|
|
|
prctlFileParser = new storm::parser::PrctlFileParser(STORM_CPP_TESTS_BASE_PATH "/parser/prctl_files/probabilisticNoBoundFormula.prctl") |
|
|
|
); |
|
|
|
|
|
|
|
ASSERT_NE(prctlParser->getFormula(), nullptr); |
|
|
|
ASSERT_NE(prctlFileParser->getFormula(), nullptr); |
|
|
|
|
|
|
|
|
|
|
|
ASSERT_EQ(prctlParser->getFormula()->toString(), "P = ? [F<=42 !a]"); |
|
|
|
ASSERT_EQ(prctlFileParser->getFormula()->toString(), "P = ? [F<=42 !a]"); |
|
|
|
|
|
|
|
delete prctlParser->getFormula(); |
|
|
|
delete prctlParser; |
|
|
|
delete prctlFileParser->getFormula(); |
|
|
|
delete prctlFileParser; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
TEST(PrctlParserTest, parseComplexFormulaTest) { |
|
|
|
storm::parser::PrctlParser* prctlParser = nullptr; |
|
|
|
storm::parser::PrctlFileParser* prctlFileParser = nullptr; |
|
|
|
ASSERT_NO_THROW( |
|
|
|
prctlParser = new storm::parser::PrctlParser(STORM_CPP_TESTS_BASE_PATH "/parser/prctl_files/complexFormula.prctl") |
|
|
|
prctlFileParser = new storm::parser::PrctlFileParser(STORM_CPP_TESTS_BASE_PATH "/parser/prctl_files/complexFormula.prctl") |
|
|
|
); |
|
|
|
|
|
|
|
ASSERT_NE(prctlParser->getFormula(), nullptr); |
|
|
|
ASSERT_NE(prctlFileParser->getFormula(), nullptr); |
|
|
|
|
|
|
|
|
|
|
|
ASSERT_EQ(prctlParser->getFormula()->toString(), "(P <= 0.500000 [F a] && (R > 15.000000 [G P > 0.900000 [F<=7 (a && b)]] || !P < 0.400000 [G !b]))"); |
|
|
|
delete prctlParser->getFormula(); |
|
|
|
delete prctlParser; |
|
|
|
ASSERT_EQ(prctlFileParser->getFormula()->toString(), "(P <= 0.500000 [F a] && (R > 15.000000 [G P > 0.900000 [F<=7 (a && b)]] || !P < 0.400000 [G !b]))"); |
|
|
|
delete prctlFileParser->getFormula(); |
|
|
|
delete prctlFileParser; |
|
|
|
|
|
|
|
} |