Added YAZ_CHECK_TERM which terminates test program. Using yaz/test.h
[yaz-moved-to-github.git] / include / yaz / test.h
1 /*
2  * Copyright (C) 1995-2005, Index Data ApS
3  * See the file LICENSE for details.
4  *
5  * $Id: test.h,v 1.3 2006-01-29 21:59:12 adam Exp $
6  */
7
8 #ifndef YAZ_TEST_H
9 #define YAZ_TEST_H
10
11 #include <yaz/yconfig.h>
12 #include <stdio.h>
13
14 #define YAZ_TEST_TYPE_OK 1
15 #define YAZ_TEST_TYPE_FAIL 2
16
17 #define YAZ_CHECK(as) { \
18   if (as) { \
19     yaz_check_print1(YAZ_TEST_TYPE_OK, __FILE__, __LINE__, #as); \
20   } else { \
21     yaz_check_print1(YAZ_TEST_TYPE_FAIL, __FILE__, __LINE__, #as); \
22   } \
23 }
24
25 #define YAZ_CHECK_INIT(argc, argv) yaz_check_init1(&argc, &argv)
26 #define YAZ_CHECK_TERM yaz_check_term1(); return 0
27
28 YAZ_BEGIN_CDECL
29 YAZ_EXPORT void yaz_check_init1(int *argc, char ***argv);
30 YAZ_EXPORT void yaz_check_term1(void);
31 YAZ_EXPORT void yaz_check_print1(int type, const char *file, int line,
32                                  const char *expr);
33 YAZ_END_CDECL
34
35
36 #endif
37 /*
38  * Local variables:
39  * c-basic-offset: 4
40  * indent-tabs-mode: nil
41  * End:
42  * vim: shiftwidth=4 tabstop=8 expandtab
43  */
44