b6477bd9cef4077271dee0b564be5de28cb1f689
[ZOOM-Perl-moved-to-github.git] / t / 17-logging.t
1 # $Id: 17-logging.t,v 1.4 2005-12-22 12:52:45 mike Exp $
2
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'
5
6 use strict;
7 use warnings;
8 use Test::More tests => 11;
9
10 BEGIN { use_ok('Net::Z3950::ZOOM') };
11
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);
22
23 sub check_level {
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)");
27 }
28
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 #       int yaz_log_module_level(const char *name);
34 #       void yaz_log_init(int level, const char *prefix, const char *name);
35 #       void yaz_log_init_file(const char *fname);
36 #       void yaz_log_init_level(int level);
37 #       void yaz_log_init_prefix(const char *prefix);
38 #       void yaz_log_time_format(const char *fmt);
39 #       void yaz_log_init_max_size(int mx);
40 #       void yaz_log(int level, const char *str);
41 # But if anyone feels strongly enough about this to want to fund the
42 # creation of a rigorous YAZ-logging test suite, please get in touch
43 # :-)