@ -9,6 +9,10 @@
# include "storm-config.h"
# include "src/parser/LtlParser.h"
# include "src/exceptions/WrongFormatException.h"
# include "src/formula/actions/InvertAction.h"
# include "src/formula/actions/SortAction.h"
# include "src/formula/actions/RangeAction.h"
# include "src/formula/actions/BoundAction.h"
namespace ltl = storm : : property : : ltl ;
@ -20,7 +24,7 @@ TEST(LtlParserTest, parseApOnlyTest) {
) ;
ASSERT_NE ( ltlFormula . get ( ) , nullptr ) ;
ASSERT_EQ ( ltlFormula - > toString ( ) , formula ) ;
ASSERT_EQ ( formula , ltlFormula - > toString ( ) ) ;
}
TEST ( LtlParserTest , parsePropositionalFormulaTest ) {
@ -31,7 +35,7 @@ TEST(LtlParserTest, parsePropositionalFormulaTest) {
) ;
ASSERT_NE ( ltlFormula . get ( ) , nullptr ) ;
ASSERT_EQ ( ltlFormula - > toString ( ) , " (!(a & b) | (a & !c)) " ) ;
ASSERT_EQ ( " (!(a & b) | (a & !c)) " , ltlFormula - > toString ( ) ) ;
}
/*!
@ -46,7 +50,7 @@ TEST(LtlParserTest, parseAmbiguousFormulaTest) {
) ;
ASSERT_NE ( ltlFormula . get ( ) , nullptr ) ;
ASSERT_EQ ( ltlFormula - > toString ( ) , " (F & b) " ) ;
ASSERT_EQ ( " (F & b) " , ltlFormula - > toString ( ) ) ;
}
/*!
@ -61,7 +65,7 @@ TEST(LtlParserTest, parseAmbiguousFormulaTest2) {
) ;
ASSERT_NE ( ltlFormula . get ( ) , nullptr ) ;
ASSERT_EQ ( ltlFormula - > toString ( ) , " F F " ) ;
ASSERT_EQ ( " F F " , ltlFormula - > toString ( ) ) ;
}
TEST ( LtlParserTest , parseBoundedEventuallyFormulaTest ) {
@ -78,7 +82,7 @@ TEST(LtlParserTest, parseBoundedEventuallyFormulaTest) {
ASSERT_EQ ( static_cast < uint_fast64_t > ( 5 ) , op - > getBound ( ) ) ;
ASSERT_EQ ( ltlFormula - > toString ( ) , " F<=5 a " ) ;
ASSERT_EQ ( " F<=5 a " , ltlFormula - > toString ( ) ) ;
}
TEST ( LtlParserTest , parseBoundedUntilFormulaTest ) {
@ -95,7 +99,47 @@ TEST(LtlParserTest, parseBoundedUntilFormulaTest) {
ASSERT_EQ ( static_cast < uint_fast64_t > ( 3 ) , op - > getBound ( ) ) ;
ASSERT_EQ ( ltlFormula - > toString ( ) , " (a U<=3 b) " ) ;
ASSERT_EQ ( " (a U<=3 b) " , ltlFormula - > toString ( ) ) ;
}
TEST ( LtlParserTest , parseLtlFilterTest ) {
std : : string input = " filter[max; invert; bound(<, 0.5); sort(value); range(0,3)](X a) " ;
std : : shared_ptr < ltl : : LtlFilter < double > > formula ( nullptr ) ;
ASSERT_NO_THROW (
formula = storm : : parser : : LtlParser : : parseLtlFormula ( input )
) ;
// The parser did not falsely recognize the input as a comment.
ASSERT_NE ( formula , nullptr ) ;
ASSERT_EQ ( storm : : property : : MAXIMIZE , formula - > getOptimizingOperator ( ) ) ;
ASSERT_EQ ( 4 , formula - > getActionCount ( ) ) ;
ASSERT_NE ( std : : dynamic_pointer_cast < storm : : property : : action : : InvertAction < double > > ( formula - > getAction ( 0 ) ) . get ( ) , nullptr ) ;
ASSERT_NE ( std : : dynamic_pointer_cast < storm : : property : : action : : BoundAction < double > > ( formula - > getAction ( 1 ) ) . get ( ) , nullptr ) ;
ASSERT_NE ( std : : dynamic_pointer_cast < storm : : property : : action : : SortAction < double > > ( formula - > getAction ( 2 ) ) . get ( ) , nullptr ) ;
ASSERT_NE ( std : : dynamic_pointer_cast < storm : : property : : action : : RangeAction < double > > ( formula - > getAction ( 3 ) ) . get ( ) , nullptr ) ;
// The input was parsed correctly.
ASSERT_EQ ( " filter[max; invert; bound(<, 0.500000); sort(value, ascending); range(0, 3)](X a) " , formula - > toString ( ) ) ;
}
TEST ( PrctlParserTest , commentTest ) {
std : : string input = " // This is a comment. And this is a commented out formula: F X a " ;
std : : shared_ptr < ltl : : LtlFilter < double > > formula ( nullptr ) ;
ASSERT_NO_THROW (
formula = storm : : parser : : LtlParser : : parseLtlFormula ( input )
) ;
// The parser recognized the input as a comment.
ASSERT_NE ( nullptr , formula . get ( ) ) ;
// Test if the parser recognizes the comment at the end of a line.
input = " F X a // This is a comment. " ;
ASSERT_NO_THROW (
formula = storm : : parser : : LtlParser : : parseLtlFormula ( input )
) ;
ASSERT_EQ ( " F X a " , formula - > toString ( ) ) ;
}
TEST ( LtlParserTest , parseComplexUntilTest ) {
@ -106,7 +150,7 @@ TEST(LtlParserTest, parseComplexUntilTest) {
) ;
ASSERT_NE ( ltlFormula . get ( ) , nullptr ) ;
ASSERT_EQ ( ltlFormula - > toString ( ) , " ((a U b) U<=3 c) " ) ;
ASSERT_EQ ( " ((a U b) U<=3 c) " , ltlFormula - > toString ( ) ) ;
}
TEST ( LtlParserTest , parseComplexFormulaTest ) {
@ -117,7 +161,7 @@ TEST(LtlParserTest, parseComplexFormulaTest) {
) ;
ASSERT_NE ( ltlFormula . get ( ) , nullptr ) ;
ASSERT_EQ ( ltlFormula - > toString ( ) , " (a U F (b | G (a & F<=3 (a U<=7 b)))) " ) ;
ASSERT_EQ ( " (a U F (b | G (a & F<=3 (a U<=7 b)))) " , ltlFormula - > toString ( ) ) ;
}
TEST ( LtlParserTest , wrongFormulaTest ) {