Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
DftValidatorTest.cpp
Go to the documentation of this file.
1#include "gmock/gmock.h"
2#include "storm-config.h"
3#include "test/storm_gtest.h"
4
7
8namespace {
9
10TEST(DftValidatorTest, Cyclic) {
11 std::string file = STORM_TEST_RESOURCES_DIR "/dft/cyclic.dft";
12 STORM_SILENT_EXPECT_THROW(storm::dft::api::loadDFTGalileoFile<double>(file), storm::exceptions::WrongFormatException);
13}
14
15TEST(DftValidatorTest, NonBinaryDependency) {
16 std::string file = STORM_TEST_RESOURCES_DIR "/dft/fdep.dft";
17 std::shared_ptr<storm::dft::storage::DFT<double>> dft = storm::dft::api::loadDFTGalileoFile<double>(file);
18 EXPECT_TRUE(storm::dft::api::isWellFormed(*dft, false).first);
19 auto result = storm::dft::api::isWellFormed(*dft, true);
20 EXPECT_FALSE(result.first);
21 EXPECT_THAT(result.second, ::testing::MatchesRegex("DFT has dependency with more than one dependent event."));
22}
23
24TEST(DftValidatorTest, MultipleConstantFailed) {
25 std::string file = STORM_TEST_RESOURCES_DIR "/dft/const_be_test.dft";
26 std::shared_ptr<storm::dft::storage::DFT<double>> dft = storm::dft::api::loadDFTGalileoFile<double>(file);
27 EXPECT_TRUE(storm::dft::api::isWellFormed(*dft, false).first);
28 auto result = storm::dft::api::isWellFormed(*dft, true);
29 EXPECT_FALSE(result.first);
30 EXPECT_THAT(result.second, ::testing::MatchesRegex("DFT has more than one constant failed BE."));
31}
32
33TEST(DftValidatorTest, OverlappingSpareModules) {
34 std::string file = STORM_TEST_RESOURCES_DIR "/dft/spare_overlapping.dft";
35 std::shared_ptr<storm::dft::storage::DFT<double>> dft = storm::dft::api::loadDFTGalileoFile<double>(file);
36 EXPECT_TRUE(storm::dft::api::isWellFormed(*dft, false).first);
37 auto result = storm::dft::api::isWellFormed(*dft, true);
38 EXPECT_FALSE(result.first);
39 EXPECT_THAT(result.second, ::testing::MatchesRegex("Spare modules .* should not overlap."));
40}
41
42TEST(DftValidatorTest, SharedPrimaryModule) {
43 std::string file = STORM_TEST_RESOURCES_DIR "/dft/spare_shared_primary.dft";
44 std::shared_ptr<storm::dft::storage::DFT<double>> dft = storm::dft::api::loadDFTGalileoFile<double>(file);
45 EXPECT_TRUE(storm::dft::api::isWellFormed(*dft, false).first);
46 auto result = storm::dft::api::isWellFormed(*dft, true);
47 EXPECT_FALSE(result.first);
48 EXPECT_THAT(result.second, ::testing::HasSubstr("shared primary module"));
49}
50
51TEST(DftValidatorTest, SpareConstantFailed) {
52 std::string file = STORM_TEST_RESOURCES_DIR "/dft/spare_const_failed.dft";
53 std::shared_ptr<storm::dft::storage::DFT<double>> dft = storm::dft::api::loadDFTGalileoFile<double>(file);
54 EXPECT_TRUE(storm::dft::api::isWellFormed(*dft, false).first);
55 auto result = storm::dft::api::isWellFormed(*dft, true);
56 EXPECT_FALSE(result.first);
57 EXPECT_THAT(result.second, ::testing::MatchesRegex("Spare module of .* contains a constant failed BE .*"));
58}
59
60TEST(DftValidatorTest, NonExponential) {
61 std::string file = STORM_TEST_RESOURCES_DIR "/dft/all_be_distributions.dft";
62 std::shared_ptr<storm::dft::storage::DFT<double>> dft = storm::dft::api::loadDFTGalileoFile<double>(file);
63 EXPECT_TRUE(storm::dft::api::isWellFormed(*dft, false).first);
64 auto result = storm::dft::api::isWellFormed(*dft, true);
65 EXPECT_FALSE(result.first);
66 EXPECT_THAT(result.second, ::testing::HasSubstr("DFT has BE distributions which are neither exponential nor constant failed/failsafe."));
67}
68
69TEST(DftValidatorTest, OverlappingWithTopModule) {
70 std::string file = STORM_TEST_RESOURCES_DIR "/dft/modules3.dft";
71 std::shared_ptr<storm::dft::storage::DFT<double>> dft = storm::dft::api::loadDFTGalileoFile<double>(file);
72 EXPECT_TRUE(storm::dft::api::isWellFormed(*dft, true).first);
74 EXPECT_TRUE(result.first);
75 EXPECT_THAT(result.second, ::testing::HasSubstr(" All elements of this spare module will be activated from the beginning on."));
76}
77
78TEST(DftValidatorTest, SpareModuleContainsParent) {
79 std::string file = STORM_TEST_RESOURCES_DIR "/dft/spare_contains_spare.dft";
80 std::shared_ptr<storm::dft::storage::DFT<double>> dft = storm::dft::api::loadDFTGalileoFile<double>(file);
81 EXPECT_TRUE(storm::dft::api::isWellFormed(*dft, true).first);
83 EXPECT_TRUE(result.first);
84 EXPECT_THAT(result.second, ::testing::HasSubstr("also contains the parent SPARE-gate"));
85 EXPECT_THAT(result.second, ::testing::HasSubstr("This can prevent proper activation of the spare module."));
86}
87
88TEST(DftValidatorTest, NoModelingIssues) {
89 std::shared_ptr<storm::dft::storage::DFT<double>> dft = storm::dft::api::loadDFTGalileoFile<double>(STORM_TEST_RESOURCES_DIR "/dft/spare.dft");
90 EXPECT_TRUE(storm::dft::api::isWellFormed(*dft, true).first);
91 EXPECT_FALSE(storm::dft::api::hasPotentialModelingIssues(*dft).first);
92
93 dft = storm::dft::api::loadDFTGalileoFile<double>(STORM_TEST_RESOURCES_DIR "/dft/spare2.dft");
94 EXPECT_TRUE(storm::dft::api::isWellFormed(*dft, true).first);
95 EXPECT_FALSE(storm::dft::api::hasPotentialModelingIssues(*dft).first);
96
97 dft = storm::dft::api::loadDFTGalileoFile<double>(STORM_TEST_RESOURCES_DIR "/dft/spare3.dft");
98 EXPECT_TRUE(storm::dft::api::isWellFormed(*dft, true).first);
99 EXPECT_FALSE(storm::dft::api::hasPotentialModelingIssues(*dft).first);
100
101 dft = storm::dft::api::loadDFTGalileoFile<double>(STORM_TEST_RESOURCES_DIR "/dft/spare4.dft");
102 EXPECT_TRUE(storm::dft::api::isWellFormed(*dft, true).first);
103 EXPECT_FALSE(storm::dft::api::hasPotentialModelingIssues(*dft).first);
104
105 dft = storm::dft::api::loadDFTGalileoFile<double>(STORM_TEST_RESOURCES_DIR "/dft/spare5.dft");
106 EXPECT_TRUE(storm::dft::api::isWellFormed(*dft, true).first);
107 EXPECT_FALSE(storm::dft::api::hasPotentialModelingIssues(*dft).first);
108
109 dft = storm::dft::api::loadDFTGalileoFile<double>(STORM_TEST_RESOURCES_DIR "/dft/spare6.dft");
110 EXPECT_TRUE(storm::dft::api::isWellFormed(*dft, true).first);
111 EXPECT_FALSE(storm::dft::api::hasPotentialModelingIssues(*dft).first);
112
113 dft = storm::dft::api::loadDFTGalileoFile<double>(STORM_TEST_RESOURCES_DIR "/dft/spare7.dft");
114 EXPECT_TRUE(storm::dft::api::isWellFormed(*dft, true).first);
115 EXPECT_FALSE(storm::dft::api::hasPotentialModelingIssues(*dft).first);
116
117 dft = storm::dft::api::loadDFTGalileoFile<double>(STORM_TEST_RESOURCES_DIR "/dft/spare8.dft");
118 EXPECT_TRUE(storm::dft::api::isWellFormed(*dft, true).first);
119 EXPECT_FALSE(storm::dft::api::hasPotentialModelingIssues(*dft).first);
120}
121
122} // namespace
TEST(OrderTest, Simple)
Definition OrderTest.cpp:8
std::pair< bool, std::string > isWellFormed(storm::dft::storage::DFT< ValueType > const &dft, bool validForMarkovianAnalysis=true)
Check whether the DFT is well-formed.
Definition storm-dft.h:64
std::pair< bool, std::string > hasPotentialModelingIssues(storm::dft::storage::DFT< ValueType > const &dft)
Check whether the DFT has potential modeling issues.
Definition storm-dft.h:82
#define STORM_SILENT_EXPECT_THROW(statement, expected_exception)