assert toggle (#1377)

* assert toggle

* Update Assert.h
This commit is contained in:
ManDude
2022-05-29 00:27:58 +01:00
committed by GitHub
parent c1faeac042
commit 9449078a9b
4 changed files with 20 additions and 3 deletions
+6 -2
View File
@@ -1,7 +1,9 @@
#include "Assert.h"
#ifndef NO_ASSERT
#include <cstdio>
#include <cstdlib>
#include "Assert.h"
#include <string_view>
void private_assert_failed(const char* expr,
@@ -32,3 +34,5 @@ void private_assert_failed(const char* expr,
private_assert_failed(expr, file, line, function, msg.data());
}
}
#endif
+9
View File
@@ -5,6 +5,8 @@
#pragma once
#ifndef NO_ASSERT
#include <string_view>
[[noreturn]] void private_assert_failed(const char* expr,
@@ -28,3 +30,10 @@
#define ASSERT_MSG(EXPR, STR) \
(void)((EXPR) || (private_assert_failed(#EXPR, __FILE__, __LINE__, __PRETTY_FUNCTION__, STR), 0))
#else
#define ASSERT(EX) ((void)0)
#define ASSERT_MSG(EXPR, STR) ((void)0)
#endif
@@ -11,6 +11,7 @@
#include "common/util/print_float.h"
#include "decompiler/IR2/ExpressionHelpers.h"
#include "decompiler/util/goal_constants.h"
#include "common/util/Assert.h"
/*
* TODO
+4 -1
View File
@@ -16,6 +16,7 @@
#include "common/util/CopyOnWrite.h"
#include "common/util/SmallVector.h"
#include "common/util/crc32.h"
#include "common/util/Assert.h"
TEST(CommonUtil, CpuInfo) {
setup_cpu_info();
@@ -393,9 +394,11 @@ TEST(SmallVector, Construction) {
EXPECT_FALSE(one.empty());
}
#ifndef NO_ASSERT
TEST(Assert, Death) {
EXPECT_DEATH(private_assert_failed("foo", "bar", 12, "aaa"), "");
}
#endif
uint32_t crc_reference(const u8* data, size_t size) {
u32 crc = 0xffffffff;
@@ -419,4 +422,4 @@ TEST(CRC32, Reference) {
}
} // namespace test
} // namespace cu
} // namespace cu