Added a few simple test framework macros (to be used in YAZ tests).
[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.1 2006-01-27 17:30:44 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_CHECK_INIT(thename) \
15 static char *yaz_unit_test_name = #thename;
16 static FILE *yaz_unit_file = 0; \
17 static int yaz_unit_test_number = 0; \
18
19 #define YAZ_CHECK(as) \
20 yaz_unit_test_number++; \
21 if (!yaz_unit_file) yaz_unit_file = stderr; \
22 if (!as) { \
23    fprintf(yaz_unit_file, "%s:%d test failed: %s\n", __FILE__, __LINE__, #as); \
24 }
25
26 #endif
27 /*
28  * Local variables:
29  * c-basic-offset: 4
30  * indent-tabs-mode: nil
31  * End:
32  * vim: shiftwidth=4 tabstop=8 expandtab
33  */
34