More Doxygen stuff; for auto-generated code too
[yaz-moved-to-github.git] / include / yaz / test.h
1 /*
2  * Copyright (C) 1995-2006, Index Data ApS
3  * See the file LICENSE for details.
4  *
5  * $Id: test.h,v 1.5 2006-04-20 20:50:51 adam Exp $
6  */
7
8 /** \file test.h
9     \brief Unit Test for YAZ
10 */
11
12 #ifndef YAZ_TEST_H
13 #define YAZ_TEST_H
14
15 #include <yaz/yconfig.h>
16 #include <stdio.h>
17
18 /** \brief Test OK */
19 #define YAZ_TEST_TYPE_OK 1
20 /** \brief Test failed */
21 #define YAZ_TEST_TYPE_FAIL 2
22
23 /** \brief boolean test. as only evaluated once */
24 #define YAZ_CHECK(as) { \
25   if (as) { \
26     yaz_check_print1(YAZ_TEST_TYPE_OK, __FILE__, __LINE__, #as); \
27   } else { \
28     yaz_check_print1(YAZ_TEST_TYPE_FAIL, __FILE__, __LINE__, #as); \
29   } \
30 }
31
32 /** \brief equality test. left, right only evaluated once */
33 #define YAZ_CHECK_EQ(left, right) { \
34   int lval = left; \
35   int rval = right; \
36   if (lval == rval) { \
37     yaz_check_eq1(YAZ_TEST_TYPE_OK, __FILE__, __LINE__, \
38      #left, #right, lval, rval); \
39   } else { \
40     yaz_check_eq1(YAZ_TEST_TYPE_FAIL, __FILE__, __LINE__, \
41      #left, #right, lval, rval); \
42   } \
43 }
44
45 /** \brief Macro to initialize the system (in start of main typically) */
46 #define YAZ_CHECK_INIT(argc, argv) yaz_check_init1(&argc, &argv)
47 /** \brief Macro to terminate the system (end of main, normally) */
48 #define YAZ_CHECK_TERM yaz_check_term1(); return 0
49
50 YAZ_BEGIN_CDECL
51 /** \brief used by macro. Should not be called directly */
52 YAZ_EXPORT void yaz_check_init1(int *argc, char ***argv);
53 /** \brief used by macro. Should not be called directly */
54 YAZ_EXPORT void yaz_check_term1(void);
55 /** \brief used by macro. Should not be called directly */
56 YAZ_EXPORT void yaz_check_print1(int type, const char *file, int line,
57                                  const char *expr);
58 /** \brief used by macro. Should not be called directly */
59 YAZ_EXPORT void yaz_check_eq1(int type, const char *file, int line,
60                               const char *left, const char *right,
61                               int lval, int rval);
62 YAZ_END_CDECL
63
64 #endif
65 /*
66  * Local variables:
67  * c-basic-offset: 4
68  * indent-tabs-mode: nil
69  * End:
70  * vim: shiftwidth=4 tabstop=8 expandtab
71  */
72