1 # $Id: 17-logging.t,v 1.1 2005-12-21 16:58:36 mike Exp $
3 # Before `make install' is performed this script should be runnable with
4 # `make test'. After `make install' it should work as `perl 17-logging.t'
8 use Test::More tests => 11;
10 BEGIN { use_ok('Net::Z3950::ZOOM') };
12 check_level("none", 0);
13 check_level("none,debug", 2);
14 check_level("none,warn", 4);
15 check_level("none,warn,debug", 6);
16 check_level("none,zoom", 8192);
17 check_level("none,-warn", 0);
18 check_level("", 2077);
19 check_level("-warn", 2073);
20 check_level("zoom", 10269);
21 check_level("none,zoom,fruit", 24576);
24 my($str, $expect) = @_;
25 my $level = Net::Z3950::ZOOM::yaz_log_mask_str($str);
26 ok($level == $expect, "log-level for '$str' ($level, expected $expect)");
29 # All the YAZ-logging functions other than yaz_log_mask_str() have
30 # side-effects, which makes them painful to write tests for. At the
31 # moment, I think we have better ways to spend the time, so these
32 # functions remain untested:
33 # void yaz_log_init(int level, const char *prefix, const char *name);
34 # void yaz_log_init_file(const char *fname);
35 # void yaz_log_init_level(int level);
36 # void yaz_log_init_prefix(const char *prefix);
37 # void yaz_log_time_format(const char *fmt);
38 # void yaz_log_init_max_size(int mx);
39 # void yaz_log(int level, const char *str);
40 # But if anyone feels strongly enough about this to want to fund the
41 # creation of a rigorous YAZ-logging test suite, please get in touch