Skip to content

Commit 590fa37

Browse files
committed
Add unit tests of UNIMPLEMENTED macros
To confirm that the new macro is working as expected.
1 parent a63ed68 commit 590fa37

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

unit/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ SRC += analyses/ai/ai.cpp \
114114
util/interval_union.cpp \
115115
util/irep.cpp \
116116
util/irep_sharing.cpp \
117+
util/invariant.cpp \
117118
util/json_array.cpp \
118119
util/json_object.cpp \
119120
util/lazy.cpp \

unit/util/invariant.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Author: Diffblue Ltd.
2+
3+
/// \file Tests for macros in src/util/invariant.h
4+
5+
#include <testing-utils/invariant.h>
6+
#include <testing-utils/use_catch.h>
7+
8+
#include <util/invariant.h>
9+
10+
TEST_CASE("Using the UNIMPLEMENTED macro", "[invariant]")
11+
{
12+
cbmc_invariants_should_throwt invariants_throw;
13+
REQUIRE_THROWS_MATCHES(
14+
[]() { UNIMPLEMENTED; }(),
15+
invariant_failedt,
16+
invariant_failure_containing("Reason: Unimplemented"));
17+
}
18+
19+
TEST_CASE("Using the UNIMPLEMENTED_FEATURE macro", "[invariant]")
20+
{
21+
cbmc_invariants_should_throwt invariants_throw;
22+
REQUIRE_THROWS_MATCHES(
23+
[]() { UNIMPLEMENTED_FEATURE("example"); }(),
24+
invariant_failedt,
25+
invariant_failure_containing("Reason: Reached unimplemented example"));
26+
}

0 commit comments

Comments
 (0)