2011-09-09 21:24:18 +02:00
|
|
|
#ifndef assert_hh_INCLUDED
|
|
|
|
#define assert_hh_INCLUDED
|
|
|
|
|
|
|
|
#include "exception.hh"
|
|
|
|
|
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
|
|
|
struct assert_failed : logic_error
|
|
|
|
{
|
2012-04-14 03:17:09 +02:00
|
|
|
assert_failed(const String& message);
|
2012-09-04 00:17:41 +02:00
|
|
|
String description() const override;
|
2011-09-09 21:24:18 +02:00
|
|
|
|
|
|
|
private:
|
2012-04-14 03:17:09 +02:00
|
|
|
String m_message;
|
2011-09-09 21:24:18 +02:00
|
|
|
};
|
|
|
|
|
2012-10-16 16:16:32 +02:00
|
|
|
void on_assert_failed(const String& message);
|
|
|
|
|
2011-09-09 21:24:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#define STRINGIFY(X) #X
|
|
|
|
#define TOSTRING(X) STRINGIFY(X)
|
2012-03-25 22:15:54 +02:00
|
|
|
#define COMMA ,
|
2011-09-09 21:24:18 +02:00
|
|
|
|
|
|
|
#ifdef assert
|
|
|
|
#undef assert
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define assert(condition) \
|
|
|
|
if (not (condition)) \
|
2012-10-16 16:16:32 +02:00
|
|
|
on_assert_failed("assert failed \"" #condition "\" at " __FILE__ ":" TOSTRING(__LINE__))
|
2011-09-09 21:24:18 +02:00
|
|
|
|
|
|
|
#endif // assert_hh_INCLUDED
|