From ba279d40ce06c9b7b2181bd3327e91c226375cf3 Mon Sep 17 00:00:00 2001 From: mike Date: Wed, 21 Dec 2005 16:58:36 +0000 Subject: [PATCH] New --- t/17-logging.t | 42 ++++++++++++++++++++++++++++++++++++++++++ t/27-logging.t | 30 ++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 t/17-logging.t create mode 100644 t/27-logging.t diff --git a/t/17-logging.t b/t/17-logging.t new file mode 100644 index 0000000..143a63b --- /dev/null +++ b/t/17-logging.t @@ -0,0 +1,42 @@ +# $Id: 17-logging.t,v 1.1 2005-12-21 16:58:36 mike Exp $ + +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl 17-logging.t' + +use strict; +use warnings; +use Test::More tests => 11; + +BEGIN { use_ok('Net::Z3950::ZOOM') }; + +check_level("none", 0); +check_level("none,debug", 2); +check_level("none,warn", 4); +check_level("none,warn,debug", 6); +check_level("none,zoom", 8192); +check_level("none,-warn", 0); +check_level("", 2077); +check_level("-warn", 2073); +check_level("zoom", 10269); +check_level("none,zoom,fruit", 24576); + +sub check_level { + my($str, $expect) = @_; + my $level = Net::Z3950::ZOOM::yaz_log_mask_str($str); + ok($level == $expect, "log-level for '$str' ($level, expected $expect)"); +} + +# All the YAZ-logging functions other than yaz_log_mask_str() have +# side-effects, which makes them painful to write tests for. At the +# moment, I think we have better ways to spend the time, so these +# functions remain untested: +# void yaz_log_init(int level, const char *prefix, const char *name); +# void yaz_log_init_file(const char *fname); +# void yaz_log_init_level(int level); +# void yaz_log_init_prefix(const char *prefix); +# void yaz_log_time_format(const char *fmt); +# void yaz_log_init_max_size(int mx); +# void yaz_log(int level, const char *str); +# But if anyone feels strongly enough about this to want to fund the +# creation of a rigorous YAZ-logging test suite, please get in touch +# :-) diff --git a/t/27-logging.t b/t/27-logging.t new file mode 100644 index 0000000..cbc9b6a --- /dev/null +++ b/t/27-logging.t @@ -0,0 +1,30 @@ +# $Id: 27-logging.t,v 1.1 2005-12-21 16:58:36 mike Exp $ + +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl 27-logging.t' + +use strict; +use warnings; +use Test::More tests => 11; + +BEGIN { use_ok('ZOOM') }; + +check_level("none", 0); +check_level("none,debug", 2); +check_level("none,warn", 4); +check_level("none,warn,debug", 6); +check_level("none,zoom", 8192); +check_level("none,-warn", 0); +check_level("", 2077); +check_level("-warn", 2073); +check_level("zoom", 10269); +check_level("none,zoom,fruit", 24576); + +sub check_level { + my($str, $expect) = @_; + my $level = ZOOM::Log::mask_str($str); + ok($level == $expect, "log-level for '$str' ($level, expected $expect)"); +} + +# See comment in "17-logging.t" on incompleteness of test-suite. + -- 1.7.10.4