change "z3950.loc.gov:7090" in documentation and examples, ZOOM-23
[ZOOM-Perl-moved-to-github.git] / t / 28-charset.t
1 # Before `make install' is performed this script should be runnable with
2 # `make test'. After `make install' it should work as `perl 28-charset.t'
3
4 use strict;
5 use warnings;
6 use Test::More tests => 9;
7
8 BEGIN { use_ok('ZOOM') };
9
10 my $host = "lx2.loc.gov:210/LCDB";
11 my $conn;
12 eval { $conn = new ZOOM::Connection($host) };
13 ok(!$@, "connection to '$host'");
14
15 $conn->option(preferredRecordSyntax => 'usmarc');
16
17 my $qstr = '@attr 1=7 3879093520';
18 my $rs;
19 eval { $rs = $conn->search_pqf($qstr) };
20 ok(!$@, "search for '$qstr'");
21
22 my $n = $rs->size();
23 ok($n == 1, "found $n records (expected 1)");
24
25 my $rec = $rs->record(0);
26 ok(defined $rec, "got first record");
27
28 my $xml = $rec->get('xml');
29 ok(defined $xml, "got XML");
30
31 ok($xml =~ m(<subfield code="b">aus der .* f\350ur),
32    "got MARC pre-accented composed characters");
33
34 $xml = $rec->get('xml', 'charset=marc-8,utf-8');
35 ok(defined $xml, "got XML in Unicode");
36
37 ok($xml =~ m(<subfield code="b">aus der .* für),
38    "got Unicode post-accented composed characters");
39