yaz_query2xml complete and tested
[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.4 2006-01-30 14:02:06 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_EQ(left, right) { \
26   int lval = left; \
27   int rval = right; \
28   if (lval == rval) { \
29     yaz_check_eq1(YAZ_TEST_TYPE_OK, __FILE__, __LINE__, \
30      #left, #right, lval, rval); \
31   } else { \
32     yaz_check_eq1(YAZ_TEST_TYPE_FAIL, __FILE__, __LINE__, \
33      #left, #right, lval, rval); \
34   } \
35 }
36
37 #define YAZ_CHECK_INIT(argc, argv) yaz_check_init1(&argc, &argv)
38 #define YAZ_CHECK_TERM yaz_check_term1(); return 0
39
40 YAZ_BEGIN_CDECL
41 YAZ_EXPORT void yaz_check_init1(int *argc, char ***argv);
42 YAZ_EXPORT void yaz_check_term1(void);
43 YAZ_EXPORT void yaz_check_print1(int type, const char *file, int line,
44                                  const char *expr);
45 YAZ_EXPORT void yaz_check_eq1(int type, const char *file, int line,
46                               const char *left, const char *right,
47                               int lval, int rval);
48
49 YAZ_END_CDECL
50
51 #endif
52 /*
53  * Local variables:
54  * c-basic-offset: 4
55  * indent-tabs-mode: nil
56  * End:
57  * vim: shiftwidth=4 tabstop=8 expandtab
58  */
59