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'
6 use Test::More tests => 11;
8 BEGIN { use_ok('Net::Z3950::ZOOM') };
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);
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)");
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