Code cleanups.

This commit is contained in:
2023-10-10 18:57:43 -07:00
parent 8dba3d27f2
commit bf1ea5e749
10 changed files with 108 additions and 65 deletions

26
Test.cc
View File

@@ -5,14 +5,13 @@
#include "Exceptions.h"
#include "Test.h"
#include <iostream>
#include <cassert>
#include <iostream>
#include <sstream>
namespace klib {
void
TestAssert(bool condition, std::string message = "Assertion failed.")
{
@@ -29,4 +28,25 @@ TestAssert(bool condition, std::string message = "Assertion failed.")
}
void
TestAssert(bool condition)
{
#if defined(NDEBUG)
if (condition) {
return;
}
#if defined(KLIB_NO_ASSERT)
std::cerr << "Assertion failed!\n";
#else
std::stringstream msg;
msg << "assertion failed at " << __FILE__ << ":" << __LINE__;
throw AssertionFailed(msg.str());
#endif
#else
assert(condition);
#endif
}
} // namespace klib