2016-02-10 00:58:03 +01:00
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <gmock/gmock.h>
|
2015-07-22 13:38:36 +02:00
|
|
|
|
|
|
|
//Include the ASSERT macro for a debug build
|
|
|
|
#undef NDEBUG
|
2016-02-11 12:53:42 +01:00
|
|
|
#include "cpp-utils/assert/assert.h"
|
2015-07-22 13:38:36 +02:00
|
|
|
|
|
|
|
using testing::MatchesRegex;
|
|
|
|
|
|
|
|
TEST(AssertTest_DebugBuild, DoesntDieIfTrue) {
|
|
|
|
ASSERT(true, "bla");
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(AssertTest_DebugBuild, DiesIfFalse) {
|
|
|
|
EXPECT_DEATH(
|
|
|
|
ASSERT(false, "bla"),
|
|
|
|
""
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(AssertTest_DebugBuild, AssertMessage) {
|
|
|
|
EXPECT_DEATH(
|
|
|
|
ASSERT(2==5, "my message"),
|
2015-11-30 03:17:19 +01:00
|
|
|
"Assertion \\[2==5\\] failed in .*/assert_debug_test.cpp:[0-9]+: my message"
|
2015-07-22 13:38:36 +02:00
|
|
|
);
|
2015-11-30 03:17:19 +01:00
|
|
|
}
|