From 8e460897f052771f844898b58777b09352a73fe1 Mon Sep 17 00:00:00 2001 From: Thomas Heinemann Date: Thu, 13 Sep 2012 16:03:12 +0200 Subject: [PATCH] Minor corrections (Memory initialization in AtomicProposition) and more test cases --- src/dtmc/atomic_proposition.h | 8 +++++--- test/parser/read_lab_file_test.cpp | 12 ++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/dtmc/atomic_proposition.h b/src/dtmc/atomic_proposition.h index 19acc9e16..3af284cc9 100644 --- a/src/dtmc/atomic_proposition.h +++ b/src/dtmc/atomic_proposition.h @@ -51,9 +51,11 @@ class AtomicProposition { void initialize(uint_fast32_t nodeCount) { if (node_array == NULL) { node_count = nodeCount; - node_array = new uint_fast64_t[(int) std::ceil(nodeCount / 64)](); - if (node_array == NULL) { - throw std::bad_alloc(); + int n = (int) std::ceil(nodeCount / 64.0); + node_array = new uint_fast64_t[n]; + //Initialization with 0 is crucial! + for (int i = 0; i < n; i++) { + node_array[i] = 0L; } } diff --git a/test/parser/read_lab_file_test.cpp b/test/parser/read_lab_file_test.cpp index e7fa6bcb9..2702ddf3f 100644 --- a/test/parser/read_lab_file_test.cpp +++ b/test/parser/read_lab_file_test.cpp @@ -75,3 +75,15 @@ TEST(ReadLabFileTest, ParseTest) { //Deleting the labelling delete labelling; } + +TEST(ReadLabFileTest, WrongHeaderTest1) { + ASSERT_THROW(mrmc::parser::read_lab_file(3,"test/parser/lab_files/wrong_format_header1.lab"), mrmc::exceptions::wrong_file_format); +} + +TEST(ReadLabFileTest, WrongHeaderTest2) { + ASSERT_THROW(mrmc::parser::read_lab_file(3,"test/parser/lab_files/wrong_format_header2.lab"), mrmc::exceptions::wrong_file_format); +} + +TEST(ReadLabFileTest, WrongPropositionTest) { + ASSERT_THROW(mrmc::parser::read_lab_file(3,"test/parser/lab_files/wrong_format_proposition.lab"), mrmc::exceptions::wrong_file_format); +}