AppAssert.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef APPASSERT_H
00011 #define APPASSERT_H
00012
00013 #include <string>
00014
00015 class AssertException
00016 {
00017 public:
00018 explicit AssertException(const char* pText) :
00019 mText(pText) {}
00020
00021 explicit AssertException(const std::string& str) :
00022 mText(str) {}
00023
00024 std::string getText() const
00025 {
00026 return mText;
00027 }
00028
00029 private:
00030 std::string mText;
00031 };
00032
00033 extern void AppAssert(const char* pExpression, const char* pFilename, unsigned line);
00034
00035 #define APP_ASSERT(test) ((test) ? (void)0 : AppAssert(#test, __FILE__, __LINE__))
00036
00037 #define REQUIRE(test) APP_ASSERT(test)
00038 #define ENSURE(test) APP_ASSERT(test)
00039 #define INVARIANT(test) APP_ASSERT(test)
00040
00041 #ifdef NDEBUG
00042 #define REQUIRE_DEBUG(test)
00043 #define ENSURE_DEBUG(test)
00044 #define INVARIANT_DEBUG(test)
00045 #else
00046 #define REQUIRE_DEBUG(test) REQUIRE(test)
00047 #define ENSURE_DEBUG(test) ENSURE(test)
00048 #define INVARIANT_DEBUG(test) INVARIANT(test)
00049 #endif
00050
00051 #endif