8e717fec657369a36a2b1e7f19354b22c7eb38c3
[ZOOM-Perl-moved-to-github.git] / t / 28-charset.t
1 # $Id: 28-charset.t,v 1.2 2006-04-06 08:15:43 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 28-charset.t'
5
6 use strict;
7 use warnings;
8 use Test::More tests => 9;
9
10 BEGIN { use_ok('ZOOM') };
11
12 my $host = "z3950.loc.gov:7090/voyager";
13 my $conn;
14 eval { $conn = new ZOOM::Connection($host) };
15 ok(!$@, "connection to '$host'");
16
17 $conn->option(preferredRecordSyntax => 'usmarc');
18
19 my $qstr = '@attr 1=7 3879093520';
20 my $rs;
21 eval { $rs = $conn->search_pqf($qstr) };
22 ok(!$@, "search for '$qstr'");
23
24 my $n = $rs->size();
25 ok($n == 1, "found $n records (expected 1)");
26
27 my $rec = $rs->record(0);
28 ok(defined $rec, "got first record");
29
30 my $xml = $rec->get('xml');
31 ok(defined $xml, "got XML");
32
33 ok($xml =~ m(<subfield code="b">aus der .* f\350ur),
34    "got MARC pre-accented composed characters");
35
36 $xml = $rec->get('xml', 'charset=marc-8,utf-8');
37 ok(defined $xml, "got XML in Unicode");
38
39 ok($xml =~ m(<subfield code="b">aus der .* für),
40    "got Unicode post-accented composed characters");
41