blob: c898abbdf360cf89d42da2f9e71e7cf24b30f36f [file] [log] [blame]
Narayan Kamathf163f692012-09-14 15:02:00 +01001#ifndef MARISA_ASSERT_H_
2#define MARISA_ASSERT_H_
3
4#include <stdio.h>
5#include <stdlib.h>
6
7#define ASSERT(cond) (void)((!!(cond)) || \
8 (printf("%d: Assertion `%s' failed.\n", __LINE__, #cond), exit(-1), 0))
9
10#define EXCEPT(code, expected_status) try { \
11 code; \
12 printf("%d: Exception `%s' failed.\n", __LINE__, #code); \
13 exit(-1); \
14} catch (const marisa::Exception &ex) { \
15 ASSERT(ex.status() == expected_status); \
16}
17
18#define TEST_START() \
19 printf("%s:%d: %s(): ", __FILE__, __LINE__, __FUNCTION__)
20
21#define TEST_END() \
22 printf("ok\n")
23
24#endif // MARISA_ASSERT_H_