Code cleanups.
This commit is contained in:
26
Test.cc
26
Test.cc
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user