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.

92 lines
4.3 KiB

  1. /*
  2. * ReadLabFileTest.cpp
  3. *
  4. * Created on: 12.09.2012
  5. * Author: Thomas Heinemann
  6. */
  7. #include "gtest/gtest.h"
  8. #include "storm-config.h"
  9. #include "src/models/AtomicPropositionsLabeling.h"
  10. #include "src/parser/AtomicPropositionLabelingParser.h"
  11. #include "src/exceptions/FileIoException.h"
  12. #include "src/exceptions/WrongFormatException.h"
  13. #include <memory>
  14. TEST(ReadLabFileTest, NonExistingFileTest) {
  15. // No matter what happens, please do NOT create a file with the name "nonExistingFile.not"!
  16. ASSERT_THROW(storm::parser::AtomicPropositionLabelingParser(0,STORM_CPP_TESTS_BASE_PATH "/nonExistingFile.not"), storm::exceptions::FileIoException);
  17. }
  18. TEST(ReadLabFileTest, ParseTest) {
  19. // This test is based on a test case from the original MRMC.
  20. // Parsing the file
  21. storm::models::AtomicPropositionsLabeling labeling = storm::parser::AtomicPropositionLabelingParser(12, STORM_CPP_TESTS_BASE_PATH "/functional/parser/lab_files/pctl_general_input_01.lab");
  22. // Checking whether all propositions are in the labelling
  23. char phi[] = "phi", psi[] = "psi", smth[] = "smth";
  24. ASSERT_TRUE(labeling.containsAtomicProposition(phi));
  25. ASSERT_TRUE(labeling.containsAtomicProposition(psi));
  26. ASSERT_TRUE(labeling.containsAtomicProposition(smth));
  27. // Testing whether all and only the correct nodes are labeled with "phi"
  28. ASSERT_TRUE(labeling.getStateHasAtomicProposition(phi,0));
  29. ASSERT_TRUE(labeling.getStateHasAtomicProposition(phi,1));
  30. ASSERT_TRUE(labeling.getStateHasAtomicProposition(phi,2));
  31. ASSERT_FALSE(labeling.getStateHasAtomicProposition(phi,3));
  32. ASSERT_FALSE(labeling.getStateHasAtomicProposition(phi,4));
  33. ASSERT_FALSE(labeling.getStateHasAtomicProposition(phi,5));
  34. ASSERT_FALSE(labeling.getStateHasAtomicProposition(phi,6));
  35. ASSERT_FALSE(labeling.getStateHasAtomicProposition(phi,7));
  36. ASSERT_FALSE(labeling.getStateHasAtomicProposition(phi,8));
  37. ASSERT_FALSE(labeling.getStateHasAtomicProposition(phi,9));
  38. ASSERT_FALSE(labeling.getStateHasAtomicProposition(phi,10));
  39. ASSERT_FALSE(labeling.getStateHasAtomicProposition(phi,11));
  40. //Testing whether all and only the correct nodes are labeled with "psi"
  41. ASSERT_FALSE(labeling.getStateHasAtomicProposition(psi,0));
  42. ASSERT_FALSE(labeling.getStateHasAtomicProposition(psi,1));
  43. ASSERT_FALSE(labeling.getStateHasAtomicProposition(psi,2));
  44. ASSERT_FALSE(labeling.getStateHasAtomicProposition(psi,3));
  45. ASSERT_FALSE(labeling.getStateHasAtomicProposition(psi,4));
  46. ASSERT_FALSE(labeling.getStateHasAtomicProposition(psi,5));
  47. ASSERT_FALSE(labeling.getStateHasAtomicProposition(psi,6));
  48. ASSERT_FALSE(labeling.getStateHasAtomicProposition(psi,7));
  49. ASSERT_FALSE(labeling.getStateHasAtomicProposition(psi,8));
  50. ASSERT_FALSE(labeling.getStateHasAtomicProposition(psi,9));
  51. ASSERT_FALSE(labeling.getStateHasAtomicProposition(psi,10));
  52. ASSERT_FALSE(labeling.getStateHasAtomicProposition(psi,11));
  53. //Testing whether all and only the correct nodes are labeled with "smth"
  54. ASSERT_TRUE(labeling.getStateHasAtomicProposition(smth,2));
  55. ASSERT_FALSE(labeling.getStateHasAtomicProposition(smth,0));
  56. ASSERT_FALSE(labeling.getStateHasAtomicProposition(smth,1));
  57. ASSERT_FALSE(labeling.getStateHasAtomicProposition(smth,3));
  58. ASSERT_FALSE(labeling.getStateHasAtomicProposition(smth,4));
  59. ASSERT_FALSE(labeling.getStateHasAtomicProposition(smth,5));
  60. ASSERT_FALSE(labeling.getStateHasAtomicProposition(smth,6));
  61. ASSERT_FALSE(labeling.getStateHasAtomicProposition(smth,7));
  62. ASSERT_FALSE(labeling.getStateHasAtomicProposition(smth,8));
  63. ASSERT_FALSE(labeling.getStateHasAtomicProposition(smth,9));
  64. ASSERT_FALSE(labeling.getStateHasAtomicProposition(smth,10));
  65. ASSERT_FALSE(labeling.getStateHasAtomicProposition(smth,11));
  66. }
  67. TEST(ReadLabFileTest, WrongHeaderTest1) {
  68. ASSERT_THROW(storm::parser::AtomicPropositionLabelingParser(3, STORM_CPP_TESTS_BASE_PATH "/functional/parser/lab_files/wrong_format_header1.lab"), storm::exceptions::WrongFormatException);
  69. }
  70. TEST(ReadLabFileTest, WrongHeaderTest2) {
  71. ASSERT_THROW(storm::parser::AtomicPropositionLabelingParser(3, STORM_CPP_TESTS_BASE_PATH "/functional/parser/lab_files/wrong_format_header2.lab"), storm::exceptions::WrongFormatException);
  72. }
  73. TEST(ReadLabFileTest, WrongPropositionTest) {
  74. ASSERT_THROW(storm::parser::AtomicPropositionLabelingParser(3, STORM_CPP_TESTS_BASE_PATH "/functional/parser/lab_files/wrong_format_proposition.lab"), storm::exceptions::WrongFormatException);
  75. }