Debugging another memory bug.
This commit is contained in:
42
Test.cc
Normal file
42
Test.cc
Normal file
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// Created by kyle on 2023-10-09.
|
||||
//
|
||||
|
||||
#include "Test.h"
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
|
||||
|
||||
namespace klib {
|
||||
|
||||
|
||||
void
|
||||
TestAssert(bool condition, std::string message = "Assertion failed.")
|
||||
{
|
||||
#if defined(NDEBUG)
|
||||
if (!condition) {
|
||||
throw AssertionFailed(message);
|
||||
}
|
||||
#else
|
||||
if (!condition) {
|
||||
std::cerr << message << std::endl;
|
||||
}
|
||||
assert(condition);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
AssertionFailed::AssertionFailed(std::string message) : msg(message)
|
||||
{
|
||||
}
|
||||
|
||||
char *
|
||||
AssertionFailed::what() const noexcept
|
||||
{
|
||||
return const_cast<char *>(this->msg.c_str());
|
||||
}
|
||||
|
||||
|
||||
} // namespace klib
|
||||
Reference in New Issue
Block a user