Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
AutoParserTest.cpp
Go to the documentation of this file.
1#include "storm-config.h"
2#include "test/storm_gtest.h"
3
8
9TEST(AutoParserTest, NonExistingFile) {
10 // No matter what happens, please do NOT create a file with the name "nonExistingFile.not"!
12 storm::parser::AutoParser<>::parseModel(STORM_TEST_RESOURCES_DIR "/nonExistingFile.not", STORM_TEST_RESOURCES_DIR "/nonExistingFile.not"),
13 storm::exceptions::FileIoException);
14}
15
16TEST(AutoParserTest, BasicParsing) {
17 // Parse model, which is a Dtmc.
18 std::shared_ptr<storm::models::sparse::Model<double>> modelPtr =
19 storm::parser::AutoParser<>::parseModel(STORM_TEST_RESOURCES_DIR "/tra/dtmc.tra", STORM_TEST_RESOURCES_DIR "/lab/autoParser.lab");
20
21 // Test if parsed correctly.
22 ASSERT_EQ(storm::models::ModelType::Dtmc, modelPtr->getType());
23 ASSERT_EQ(12ul, modelPtr->getNumberOfStates());
24 ASSERT_EQ(26ul, modelPtr->getNumberOfTransitions());
25 ASSERT_EQ(1ul, modelPtr->getInitialStates().getNumberOfSetBits());
26 ASSERT_TRUE(modelPtr->hasLabel("three"));
27 ASSERT_FALSE(modelPtr->hasRewardModel());
28}
29
30TEST(AutoParserTest, WrongHint) {
31 // The hint given describes the content but does not conform to the format.
33 storm::parser::AutoParser<>::parseModel(STORM_TEST_RESOURCES_DIR "/tra/wrongHint.tra", STORM_TEST_RESOURCES_DIR "/lab/autoParser.lab"),
34 storm::exceptions::WrongFormatException);
35}
36
37TEST(AutoParserTest, NoHint) {
38 // There is no hint contained in the given file, so the parser cannot decide which kind of model it is.
40 storm::parser::AutoParser<>::parseModel(STORM_TEST_RESOURCES_DIR "/tra/noHint.tra", STORM_TEST_RESOURCES_DIR "/lab/autoParser.lab"),
41 storm::exceptions::WrongFormatException);
42}
43
44TEST(AutoParserTest, Decision) {
45 // Test if the AutoParser recognizes each model kind and correctly parses it.
46
47 // Dtmc
48 std::shared_ptr<storm::models::sparse::Model<double>> modelPtr =
49 storm::parser::AutoParser<>::parseModel(STORM_TEST_RESOURCES_DIR "/tra/dtmc.tra", STORM_TEST_RESOURCES_DIR "/lab/autoParser.lab");
50 ASSERT_EQ(storm::models::ModelType::Dtmc, modelPtr->getType());
51 ASSERT_EQ(12ul, modelPtr->getNumberOfStates());
52 ASSERT_EQ(26ul, modelPtr->getNumberOfTransitions());
53
54 // Ctmc
55 modelPtr.reset();
56 modelPtr = storm::parser::AutoParser<>::parseModel(STORM_TEST_RESOURCES_DIR "/tra/ctmc.tra", STORM_TEST_RESOURCES_DIR "/lab/autoParser.lab");
57 ASSERT_EQ(storm::models::ModelType::Ctmc, modelPtr->getType());
58 ASSERT_EQ(12ul, modelPtr->getNumberOfStates());
59 ASSERT_EQ(26ul, modelPtr->getNumberOfTransitions());
60
61 // Mdp
62 modelPtr.reset();
63 modelPtr = storm::parser::AutoParser<>::parseModel(STORM_TEST_RESOURCES_DIR "/tra/mdp.tra", STORM_TEST_RESOURCES_DIR "/lab/autoParser.lab");
64 ASSERT_EQ(storm::models::ModelType::Mdp, modelPtr->getType());
65 ASSERT_EQ(12ul, modelPtr->getNumberOfStates());
66 ASSERT_EQ(28ul, modelPtr->getNumberOfTransitions());
67
68 // MA
69 modelPtr.reset();
70 modelPtr = storm::parser::AutoParser<>::parseModel(STORM_TEST_RESOURCES_DIR "/tra/ma.tra", STORM_TEST_RESOURCES_DIR "/lab/autoParser.lab");
71 ASSERT_EQ(storm::models::ModelType::MarkovAutomaton, modelPtr->getType());
72 ASSERT_EQ(12ul, modelPtr->getNumberOfStates());
73 ASSERT_EQ(27ul, modelPtr->getNumberOfTransitions());
74}
TEST(AutoParserTest, NonExistingFile)
This class automatically chooses the correct parser for the given files and returns the corresponding...
Definition AutoParser.h:26
static std::shared_ptr< storm::models::sparse::Model< ValueType, storm::models::sparse::StandardRewardModel< RewardValueType > > > parseModel(std::string const &transitionsFilename, std::string const &labelingFilename, std::string const &stateRewardFilename="", std::string const &transitionRewardFilename="", std::string const &choiceLabelingFilename="")
Checks the given files and parses the model within these files.
#define STORM_SILENT_ASSERT_THROW(statement, expected_exception)
Definition storm_gtest.h:99