You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

132 lines
6.1 KiB

  1. #include "gtest/gtest.h"
  2. #include "storm-config.h"
  3. #include "src/parser/FormulaParser.h"
  4. #include "src/logic/FragmentChecker.h"
  5. #include "src/exceptions/WrongFormatException.h"
  6. TEST(FragmentCheckerTest, Propositional) {
  7. storm::logic::FragmentChecker checker;
  8. storm::logic::FragmentSpecification prop = storm::logic::propositional();
  9. storm::parser::FormulaParser formulaParser;
  10. std::shared_ptr<const storm::logic::Formula> formula;
  11. ASSERT_NO_THROW(formula = formulaParser.parseSingleFormulaFromString("\"label\""));
  12. EXPECT_TRUE(checker.conformsToSpecification(*formula, prop));
  13. ASSERT_NO_THROW(formula = formulaParser.parseSingleFormulaFromString("true"));
  14. EXPECT_TRUE(checker.conformsToSpecification(*formula, prop));
  15. ASSERT_NO_THROW(formula = formulaParser.parseSingleFormulaFromString("true | \"label\""));
  16. EXPECT_TRUE(checker.conformsToSpecification(*formula, prop));
  17. ASSERT_NO_THROW(formula = formulaParser.parseSingleFormulaFromString("!true"));
  18. EXPECT_TRUE(checker.conformsToSpecification(*formula, prop));
  19. ASSERT_NO_THROW(formula = formulaParser.parseSingleFormulaFromString("true"));
  20. EXPECT_TRUE(checker.conformsToSpecification(*formula, prop));
  21. ASSERT_NO_THROW(formula = formulaParser.parseSingleFormulaFromString("P=? [F true]"));
  22. EXPECT_FALSE(checker.conformsToSpecification(*formula, prop));
  23. ASSERT_NO_THROW(formula = formulaParser.parseSingleFormulaFromString("false | P>0.5 [G \"label\"]"));
  24. EXPECT_FALSE(checker.conformsToSpecification(*formula, prop));
  25. ASSERT_NO_THROW(formula = formulaParser.parseSingleFormulaFromString("P=? [F \"label\"]"));
  26. EXPECT_FALSE(checker.conformsToSpecification(*formula, prop));
  27. }
  28. TEST(FragmentCheckerTest, Pctl) {
  29. storm::logic::FragmentChecker checker;
  30. storm::logic::FragmentSpecification pctl = storm::logic::pctl();
  31. storm::parser::FormulaParser formulaParser;
  32. std::shared_ptr<const storm::logic::Formula> formula;
  33. ASSERT_NO_THROW(formula = formulaParser.parseSingleFormulaFromString("\"label\""));
  34. EXPECT_TRUE(checker.conformsToSpecification(*formula, pctl));
  35. ASSERT_NO_THROW(formula = formulaParser.parseSingleFormulaFromString("P=? [F \"label\"]"));
  36. EXPECT_TRUE(checker.conformsToSpecification(*formula, pctl));
  37. ASSERT_NO_THROW(formula = formulaParser.parseSingleFormulaFromString("P=? [F P=? [F \"label\"]]"));
  38. EXPECT_TRUE(checker.conformsToSpecification(*formula, pctl));
  39. ASSERT_NO_THROW(formula = formulaParser.parseSingleFormulaFromString("R=? [F \"label\"]"));
  40. EXPECT_FALSE(checker.conformsToSpecification(*formula, pctl));
  41. }
  42. TEST(FragmentCheckerTest, Prctl) {
  43. storm::logic::FragmentChecker checker;
  44. storm::logic::FragmentSpecification prctl = storm::logic::prctl();
  45. storm::parser::FormulaParser formulaParser;
  46. std::shared_ptr<const storm::logic::Formula> formula;
  47. ASSERT_NO_THROW(formula = formulaParser.parseSingleFormulaFromString("\"label\""));
  48. EXPECT_TRUE(checker.conformsToSpecification(*formula, prctl));
  49. ASSERT_NO_THROW(formula = formulaParser.parseSingleFormulaFromString("P=? [F \"label\"]"));
  50. EXPECT_TRUE(checker.conformsToSpecification(*formula, prctl));
  51. ASSERT_NO_THROW(formula = formulaParser.parseSingleFormulaFromString("P=? [F P=? [F \"label\"]]"));
  52. EXPECT_TRUE(checker.conformsToSpecification(*formula, prctl));
  53. ASSERT_NO_THROW(formula = formulaParser.parseSingleFormulaFromString("R=? [F \"label\"]"));
  54. EXPECT_TRUE(checker.conformsToSpecification(*formula, prctl));
  55. ASSERT_NO_THROW(formula = formulaParser.parseSingleFormulaFromString("R=? [C<=3]"));
  56. EXPECT_TRUE(checker.conformsToSpecification(*formula, prctl));
  57. ASSERT_NO_THROW(formula = formulaParser.parseSingleFormulaFromString("P=? [F[0,1] \"label\"]"));
  58. EXPECT_FALSE(checker.conformsToSpecification(*formula, prctl));
  59. }
  60. TEST(FragmentCheckerTest, Csl) {
  61. storm::logic::FragmentChecker checker;
  62. storm::logic::FragmentSpecification csl = storm::logic::csl();
  63. storm::parser::FormulaParser formulaParser;
  64. std::shared_ptr<const storm::logic::Formula> formula;
  65. ASSERT_NO_THROW(formula = formulaParser.parseSingleFormulaFromString("\"label\""));
  66. EXPECT_TRUE(checker.conformsToSpecification(*formula, csl));
  67. ASSERT_NO_THROW(formula = formulaParser.parseSingleFormulaFromString("P=? [F \"label\"]"));
  68. EXPECT_TRUE(checker.conformsToSpecification(*formula, csl));
  69. ASSERT_NO_THROW(formula = formulaParser.parseSingleFormulaFromString("P=? [F P=? [F \"label\"]]"));
  70. EXPECT_TRUE(checker.conformsToSpecification(*formula, csl));
  71. ASSERT_NO_THROW(formula = formulaParser.parseSingleFormulaFromString("R=? [F \"label\"]"));
  72. EXPECT_FALSE(checker.conformsToSpecification(*formula, csl));
  73. ASSERT_NO_THROW(formula = formulaParser.parseSingleFormulaFromString("P=? [F[0,1] \"label\"]"));
  74. EXPECT_TRUE(checker.conformsToSpecification(*formula, csl));
  75. }
  76. TEST(FragmentCheckerTest, Csrl) {
  77. storm::logic::FragmentChecker checker;
  78. storm::logic::FragmentSpecification csrl = storm::logic::csrl();
  79. storm::parser::FormulaParser formulaParser;
  80. std::shared_ptr<const storm::logic::Formula> formula;
  81. ASSERT_NO_THROW(formula = formulaParser.parseSingleFormulaFromString("\"label\""));
  82. EXPECT_TRUE(checker.conformsToSpecification(*formula, csrl));
  83. ASSERT_NO_THROW(formula = formulaParser.parseSingleFormulaFromString("P=? [F \"label\"]"));
  84. EXPECT_TRUE(checker.conformsToSpecification(*formula, csrl));
  85. ASSERT_NO_THROW(formula = formulaParser.parseSingleFormulaFromString("P=? [F P=? [F \"label\"]]"));
  86. EXPECT_TRUE(checker.conformsToSpecification(*formula, csrl));
  87. ASSERT_NO_THROW(formula = formulaParser.parseSingleFormulaFromString("R=? [F \"label\"]"));
  88. EXPECT_TRUE(checker.conformsToSpecification(*formula, csrl));
  89. ASSERT_NO_THROW(formula = formulaParser.parseSingleFormulaFromString("R=? [C<=3]"));
  90. EXPECT_TRUE(checker.conformsToSpecification(*formula, csrl));
  91. ASSERT_NO_THROW(formula = formulaParser.parseSingleFormulaFromString("P=? [F[0,1] \"label\"]"));
  92. EXPECT_TRUE(checker.conformsToSpecification(*formula, csrl));
  93. }