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