From dd99301fb37356db0792e0e1cc8d35b28c94acb9 Mon Sep 17 00:00:00 2001 From: mike Date: Thu, 6 Apr 2006 13:08:14 +0000 Subject: [PATCH] New, back-formed from 28-charset.t --- t/18-charset.t | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 t/18-charset.t diff --git a/t/18-charset.t b/t/18-charset.t new file mode 100644 index 0000000..f4d02c1 --- /dev/null +++ b/t/18-charset.t @@ -0,0 +1,45 @@ +# $Id: 18-charset.t,v 1.1 2006-04-06 13:08:14 mike Exp $ + +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl 18-charset.t' + +use strict; +use warnings; +use Test::More tests => 9; + +BEGIN { use_ok('Net::Z3950::ZOOM') }; + +my($errcode, $errmsg, $addinfo) = (undef, "dummy", "dummy"); + +my $host = "z3950.loc.gov:7090/voyager"; +my $conn = Net::Z3950::ZOOM::connection_new($host, 0); +$errcode = Net::Z3950::ZOOM::connection_error($conn, $errmsg, $addinfo); +ok($errcode == 0, "connection to '$host'"); + +Net::Z3950::ZOOM::connection_option_set($conn, + preferredRecordSyntax => "usmarc"); + +my $qstr = '@attr 1=7 3879093520'; +my $rs = Net::Z3950::ZOOM::connection_search_pqf($conn, $qstr); +$errcode = Net::Z3950::ZOOM::connection_error($conn, $errmsg, $addinfo); +ok($errcode == 0, "search for '$qstr'"); + +my $n = Net::Z3950::ZOOM::resultset_size($rs); +ok($n == 1, "found $n records (expected 1)"); + +my $rec = Net::Z3950::ZOOM::resultset_record($rs, 0); +ok(defined $rec, "got first record"); + +my $len = 0; +my $xml = Net::Z3950::ZOOM::record_get($rec, "xml", $len); +ok(defined $xml, "got XML"); + +ok($xml =~ m(aus der .* f\350ur), + "got MARC pre-accented composed characters"); + +$xml = Net::Z3950::ZOOM::record_get($rec, "xml;charset=marc-8,utf-8", $len); +ok(defined $xml, "got XML in Unicode"); + +ok($xml =~ m(aus der .* für), + "got Unicode post-accented composed characters"); + -- 1.7.10.4