YAZ  5.23.1
Macros | Functions
test.h File Reference

Unit Test for YAZ. More...

#include <yaz/yconfig.h>
#include <stdio.h>

Go to the source code of this file.

Macros

#define YAZ_TEST_TYPE_OK   1
 Test OK. More...
 
#define YAZ_TEST_TYPE_FAIL   2
 Test failed. More...
 
#define YAZ_CHECK(as)
 boolean test. as only evaluated once More...
 
#define YAZ_CHECK_TODO(as)
 a test we know will fail at this time. More...
 
#define YAZ_CHECK_EQ(left, right)
 equality test. left, right only evaluated once More...
 
#define YAZ_CHECK_INIT(argc, argv)   yaz_check_init1(&argc, &argv)
 Macro to initialize the system (in start of main typically) More...
 
#define YAZ_CHECK_TERM   yaz_check_term1(); return 0
 Macro to terminate the system (end of main, normally) More...
 
#define YAZ_CHECK_LOG()   yaz_check_init_log(argv[0])
 Macro to enable and initialize the yaz_log(start of main) More...
 

Functions

int yaz_test_get_verbosity (void)
 Get the verbosity level. More...
 
void yaz_check_init1 (int *argc, char ***argv)
 used by macro. Should not be called directly More...
 
void yaz_check_term1 (void)
 used by macro. Should not be called directly More...
 
void yaz_check_init_log (const char *argv0)
 used by macro. Should not be called directly More...
 
void yaz_check_print1 (int type, const char *file, int line, const char *expr)
 used by macro. Should not be called directly More...
 
void yaz_check_eq1 (int type, const char *file, int line, const char *left, const char *right, int lval, int rval)
 used by macro. Should not be called directly More...
 
void yaz_check_inc_todo (void)
 used by macro. Should not be called directly More...
 

Detailed Description

Unit Test for YAZ.

Definition in file test.h.

Macro Definition Documentation

#define YAZ_CHECK (   as)
Value:
{ \
if (as) { \
yaz_check_print1(YAZ_TEST_TYPE_OK, __FILE__, __LINE__, #as); \
} else { \
yaz_check_print1(YAZ_TEST_TYPE_FAIL, __FILE__, __LINE__, #as); \
} \
}
#define YAZ_TEST_TYPE_FAIL
Test failed.
Definition: test.h:44
#define YAZ_TEST_TYPE_OK
Test OK.
Definition: test.h:42
void yaz_check_print1(int type, const char *file, int line, const char *expr)
used by macro. Should not be called directly
Definition: test.c:179

boolean test. as only evaluated once

Definition at line 47 of file test.h.

#define YAZ_CHECK_EQ (   left,
  right 
)
Value:
{ \
int lval = left; \
int rval = right; \
if (lval == rval) { \
yaz_check_eq1(YAZ_TEST_TYPE_OK, __FILE__, __LINE__, \
#left, #right, lval, rval); \
} else { \
yaz_check_eq1(YAZ_TEST_TYPE_FAIL, __FILE__, __LINE__, \
#left, #right, lval, rval); \
} \
}
#define YAZ_TEST_TYPE_FAIL
Test failed.
Definition: test.h:44
#define YAZ_TEST_TYPE_OK
Test OK.
Definition: test.h:42
void yaz_check_eq1(int type, const char *file, int line, const char *left, const char *right, int lval, int rval)
used by macro. Should not be called directly
Definition: test.c:167

equality test. left, right only evaluated once

Definition at line 72 of file test.h.

#define YAZ_CHECK_INIT (   argc,
  argv 
)    yaz_check_init1(&argc, &argv)

Macro to initialize the system (in start of main typically)

Definition at line 85 of file test.h.

#define YAZ_CHECK_LOG ( )    yaz_check_init_log(argv[0])

Macro to enable and initialize the yaz_log(start of main)

Definition at line 90 of file test.h.

#define YAZ_CHECK_TERM   yaz_check_term1(); return 0

Macro to terminate the system (end of main, normally)

Definition at line 87 of file test.h.

#define YAZ_CHECK_TODO (   as)
Value:
{ \
if (!as) { \
yaz_check_print1(YAZ_TEST_TYPE_OK, __FILE__, __LINE__, "TODO: " #as); \
} else { \
yaz_check_print1(YAZ_TEST_TYPE_FAIL, __FILE__, __LINE__, "TODO: "#as); \
} \
}
#define YAZ_TEST_TYPE_FAIL
Test failed.
Definition: test.h:44
void yaz_check_inc_todo(void)
used by macro. Should not be called directly
Definition: test.c:127
#define YAZ_TEST_TYPE_OK
Test OK.
Definition: test.h:42
void yaz_check_print1(int type, const char *file, int line, const char *expr)
used by macro. Should not be called directly
Definition: test.c:179

a test we know will fail at this time.

Later, when the bug is fixed, this test will suddenly pass, which will be reported as an error, to remind you to go and fix your tests.

Definition at line 62 of file test.h.

#define YAZ_TEST_TYPE_FAIL   2

Test failed.

Definition at line 44 of file test.h.

Referenced by yaz_check_print1().

#define YAZ_TEST_TYPE_OK   1

Test OK.

Definition at line 42 of file test.h.

Referenced by yaz_check_eq1(), and yaz_check_print1().

Function Documentation

void yaz_check_eq1 ( int  type,
const char *  file,
int  line,
const char *  left,
const char *  right,
int  lval,
int  rval 
)

used by macro. Should not be called directly

Definition at line 167 of file test.c.

References yaz_check_print1(), and YAZ_TEST_TYPE_OK.

void yaz_check_inc_todo ( void  )

used by macro. Should not be called directly

Definition at line 127 of file test.c.

References test_todo.

void yaz_check_init1 ( int *  argc,
char ***  argv 
)

used by macro. Should not be called directly

Definition at line 51 of file test.c.

References progname(), test_fout, test_prog, test_stop, and test_verbose.

void yaz_check_init_log ( const char *  argv0)

used by macro. Should not be called directly

used by macro. Should not be called directly

Definition at line 117 of file test.c.

References log_tests, progname(), yaz_log_init_file(), and yaz_log_trunc().

void yaz_check_print1 ( int  type,
const char *  file,
int  line,
const char *  expr 
)

used by macro. Should not be called directly

Definition at line 179 of file test.c.

References get_file(), log_tests, test_failed, test_stop, test_total, test_verbose, yaz_log(), YAZ_TEST_TYPE_FAIL, YAZ_TEST_TYPE_OK, and YLOG_LOG.

Referenced by yaz_check_eq1().

void yaz_check_term1 ( void  )

used by macro. Should not be called directly

Definition at line 132 of file test.c.

References get_file(), test_failed, test_fout, test_prog, test_todo, test_total, test_verbose, and yaz_deinit_globals().

int yaz_test_get_verbosity ( void  )

Get the verbosity level.

Definition at line 217 of file test.c.

References test_verbose.