Compare commits

..

No commits in common. "0ba9416a57c86feb5dbbac8439e9775742043227" and "c0a622c5e43e4f8df8485c97f3e1469667307fff" have entirely different histories.

6 changed files with 28 additions and 39 deletions

View File

@ -20,12 +20,12 @@ namespace
bool assert_flag = false;
void assertCallback(const char*, const char*, const int)
void assertCallback(const char*, const int)
{
assert_flag = true;
}
}// namespace
}
TEST_CASE("Assert debug without NDEBUG gets triggered if check is false.", "[utility],[assert]")
{

View File

@ -20,12 +20,12 @@ namespace
bool assert_flag = false;
void assertCallback(const char*, const char*, const int)
void assertCallback(const char*, const int)
{
assert_flag = true;
}
}// namespace
}
TEST_CASE("Assert debug with NDEBUG is a null-opt.", "[utility],[assert]")
{

View File

@ -8,26 +8,26 @@
namespace Utility::Assert::Detail
{
void assertImpl(const char* expression, const char* file, const int line);
void assertImpl(const bool expr, const char* file, const int line);
}
#ifndef NDEBUG
#define SKULLC_ASSERT_DEBUG(e) (!(e) ? Utility::Assert::Detail::assertImpl(#e, __FILE__, __LINE__) : ((void) 0))
# define SKULLC_ASSERT_DEBUG(e) Utility::Assert::Detail::assertImpl(e, __FILE__, __LINE__)
#else
# define SKULLC_ASSERT_DEBUG(e)
#endif
#define SKULLC_ASSERT_SAFE(e) (!(e) ? Utility::Assert::Detail::assertImpl(#e, __FILE__, __LINE__) : ((void) 0))
#define SKULLC_ASSERT_SAFE(e) Utility::Assert::Detail::assertImpl(e, __FILE__, __LINE__)
namespace Utility::Assert
{
using assert_cb = void (*)(const char* expression, const char* file, const int line);
using assert_cb = void (*)(const char* file, const int line);
void setHandler(assert_cb callback);
assert_cb getHandler();
}// namespace Utility::Assert
}
#endif // SKULLC_UTILITY_ASSERT_HPP_

View File

@ -8,11 +8,8 @@
#ifndef SKULLC_UTILITY_STATICPOINTER_HPP_
#define SKULLC_UTILITY_STATICPOINTER_HPP_
#include <new>
#include <utility>
#include <utility_assert.hpp>
namespace Utility
{
@ -60,17 +57,6 @@ struct StaticPointer
return initialized_;
}
value_type* get()
{
SKULLC_ASSERT_DEBUG(initialized_);
return reinterpret_cast<value_type*>(storage);
}
const value_type* get() const
{
SKULLC_ASSERT_DEBUG(initialized_);
return reinterpret_cast<const value_type*>(storage);
}
private:
bool initialized_ = false;
};

View File

@ -19,15 +19,18 @@ namespace Utility::Assert
namespace Detail
{
void assertImpl(const char* expression, const char* file, const int line)
void assertImpl(const bool expr, const char* file, const int line)
{
if (!expr)
{
if (INSTALLED_HANDLER)
INSTALLED_HANDLER(expression, file, line);
INSTALLED_HANDLER(file, line);
else
std::terminate();
}
}
}// namespace Detail
}
void setHandler(assert_cb callback)
{
@ -39,4 +42,4 @@ assert_cb getHandler()
return INSTALLED_HANDLER;
}
}// namespace Utility::Assert
}