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.

77 lines
3.1 KiB

  1. /*
  2. * read_lab_file_test.cpp
  3. *
  4. * Created on: 12.09.2012
  5. * Author: Thomas Heinemann
  6. */
  7. #include "gtest/gtest.h"
  8. #include "src/dtmc/labelling.h"
  9. #include "src/parser/read_lab_file.h"
  10. #include "src/exceptions/file_IO_exception.h"
  11. #include "src/exceptions/wrong_file_format.h"
  12. TEST(ReadLabFileTest, NonExistingFileTest) {
  13. //No matter what happens, please don't create a file with the name "nonExistingFile.not"! :-)
  14. ASSERT_THROW(mrmc::parser::read_lab_file(0,"nonExistingFile.not"), mrmc::exceptions::file_IO_exception);
  15. }
  16. TEST(ReadLabFileTest, ParseTest) {
  17. //This test is based on a testcase from the original MRMC.
  18. mrmc::dtmc::labelling* labelling;
  19. //Parsing the file
  20. ASSERT_NO_THROW(labelling = mrmc::parser::read_lab_file(12,"test/parser/lab_files/pctl_general_input_01.lab"));
  21. //Checking whether all propositions are in the labelling
  22. char phi[] = "phi", psi[] = "psi", smth[] = "smth";
  23. ASSERT_TRUE(labelling->containsProposition(phi));
  24. ASSERT_TRUE(labelling->containsProposition(psi));
  25. ASSERT_TRUE(labelling->containsProposition(smth));
  26. //Testing whether all and only the correct nodes are labeled with "phi"
  27. ASSERT_TRUE(labelling->nodeHasProposition(phi,1));
  28. ASSERT_TRUE(labelling->nodeHasProposition(phi,2));
  29. ASSERT_TRUE(labelling->nodeHasProposition(phi,3));
  30. ASSERT_TRUE(labelling->nodeHasProposition(phi,5));
  31. ASSERT_TRUE(labelling->nodeHasProposition(phi,7));
  32. ASSERT_TRUE(labelling->nodeHasProposition(phi,9));
  33. ASSERT_TRUE(labelling->nodeHasProposition(phi,10));
  34. ASSERT_TRUE(labelling->nodeHasProposition(phi,11));
  35. ASSERT_FALSE(labelling->nodeHasProposition(phi,4));
  36. ASSERT_FALSE(labelling->nodeHasProposition(phi,6));
  37. //Testing whether all and only the correct nodes are labeled with "psi"
  38. ASSERT_TRUE(labelling->nodeHasProposition(psi,6));
  39. ASSERT_TRUE(labelling->nodeHasProposition(psi,7));
  40. ASSERT_TRUE(labelling->nodeHasProposition(psi,8));
  41. ASSERT_FALSE(labelling->nodeHasProposition(psi,1));
  42. ASSERT_FALSE(labelling->nodeHasProposition(psi,2));
  43. ASSERT_FALSE(labelling->nodeHasProposition(psi,3));
  44. ASSERT_FALSE(labelling->nodeHasProposition(psi,4));
  45. ASSERT_FALSE(labelling->nodeHasProposition(psi,5));
  46. ASSERT_FALSE(labelling->nodeHasProposition(psi,9));
  47. ASSERT_FALSE(labelling->nodeHasProposition(psi,10));
  48. ASSERT_FALSE(labelling->nodeHasProposition(psi,11));
  49. //Testing whether all and only the correct nodes are labeled with "smth"
  50. ASSERT_TRUE(labelling->nodeHasProposition(smth,4));
  51. ASSERT_TRUE(labelling->nodeHasProposition(smth,5));
  52. ASSERT_FALSE(labelling->nodeHasProposition(smth,1));
  53. ASSERT_FALSE(labelling->nodeHasProposition(smth,2));
  54. ASSERT_FALSE(labelling->nodeHasProposition(smth,3));
  55. ASSERT_FALSE(labelling->nodeHasProposition(smth,6));
  56. ASSERT_FALSE(labelling->nodeHasProposition(smth,7));
  57. ASSERT_FALSE(labelling->nodeHasProposition(smth,8));
  58. ASSERT_FALSE(labelling->nodeHasProposition(smth,9));
  59. ASSERT_FALSE(labelling->nodeHasProposition(smth,10));
  60. ASSERT_FALSE(labelling->nodeHasProposition(smth,11));
  61. //Deleting the labelling
  62. delete labelling;
  63. }