File: Assert.h

package info (click to toggle)
storm-lang 0.7.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 52,100 kB
  • sloc: ansic: 261,471; cpp: 140,438; sh: 14,891; perl: 9,846; python: 2,525; lisp: 2,504; asm: 860; makefile: 678; pascal: 70; java: 52; xml: 37; awk: 12
file content (40 lines) | stat: -rw-r--r-- 909 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#pragma once

#ifdef assert
#undef assert
#endif

#ifdef DEBUG

#ifdef VISUAL_STUDIO
#define assert(X, ...) if (!(X)) throw AssertionException(WIDEN(__FILE__), __LINE__, WIDEN(#X), __VA_ARGS__)
#else
#define assert(X, ...) if (!(X)) throw AssertionException(WIDEN(__FILE__), __LINE__, WIDEN(#X), ##__VA_ARGS__)
#endif

#define dbg_assert(X, msg) if (!(X)) { ::debugAssertFailed(msg); }

#else

#define assert(X, ...)
#define dbg_assert(X, msg)

#endif

void debugAssertFailed();
void debugAssertFailed(const wchar_t *msg);
void debugAssertFailed(const String &str);

#include "Exception.h"

class AssertionException : public Exception {
public:
	AssertionException(const String &file, nat line, const String &expr, const String &msg = L"");
	AssertionException(const String &file, nat line, const String &expr, const char *msg);

	virtual String what() const;

private:
	String file, expr, msg;
	nat line;
};