From 3155b9de32d2a7c8231fb4599b9061362ee775f7 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Thu, 4 Feb 2010 17:10:14 +0000 Subject: [PATCH] added test and data for utf-8 encoding example git-svn-id: svn+ssh://llin/home/dpavlin/private/svn/MARC-Fast/trunk@32 49f9634a-d7ec-0310-8e6b-ec35c6cc8804 --- t/002_marc-utf8.t | 34 ++++++++++++++++++++++++++++++++++ t/utf8.marc | 1 + 2 files changed, 35 insertions(+) create mode 100755 t/002_marc-utf8.t create mode 100644 t/utf8.marc diff --git a/t/002_marc-utf8.t b/t/002_marc-utf8.t new file mode 100755 index 0000000..fd50291 --- /dev/null +++ b/t/002_marc-utf8.t @@ -0,0 +1,34 @@ +#!/usr/bin/perl -w + +use strict; +use blib; + +use Test::More tests => 7; +use Data::Dump qw/dump/; + +BEGIN { + use_ok( 'MARC::Fast' ); + use_ok( 'Encode' ); +} + +my $debug = shift @ARGV; + +my $marc_file = 't/utf8.marc'; + +ok(my $marc = MARC::Fast->new( + marcdb => 't/utf8.marc', + hash_filter => sub { + Encode::decode( 'utf-8', $_[0] ); + }, +), "new"); + +cmp_ok($marc->count, '==', 1, 'count' ); + +ok(my $rec = $marc->fetch(1), "fetch 1"); +diag dump $rec if $debug; + +ok(my $hash = $marc->to_hash(1), "to_hash 1"); +diag dump $hash if $debug; + +ok( $hash->{260}->[0]->{'b'} eq "\x{160}kolska knjiga,", 'utf-8 flag' ); + diff --git a/t/utf8.marc b/t/utf8.marc new file mode 100644 index 0000000..70873c3 --- /dev/null +++ b/t/utf8.marc @@ -0,0 +1 @@ +01545nam a2200361ui 4500008004100000035001900041040003300060080001500093080000800108100002000116245010300136250002500239260003800264300004600302504003200348504001100380653001700391653001600408653002500424942007800449952012500527952012500652952010600777952010500883952010600988991001401094991001301108991001401121991001301135991001301148992001101161999001101172020118s1988 ||| |||||||||| ||hrv|d aHR-ZaFF iznL41 aHR-ZaFFbhrvcHR-ZaFFeppiak a519.21:007 a0071 aPauše, Željko10aVjerojatnost :binformacija, stohastički procesi : pojmovi - metode - primjene /cŽeljko Pauše. a4. promijenjeno izd. aZagreb :bŠkolska knjiga,c1988. aXVI, 263 str. : bgraf. prikazi ; c24 cm aStr. 259-250: Bibliografija aKazalo avjerojatnost ainformacija astohastički procesi bLIBcKNJdIZN | 519.21 | PAU | v | 519.21D | PAU | vhBBiPAU v6BB_PAU_V w2008-10-15p1301000051r2008-10-1540006BB_PAU_V951bFFZG10oBB PAU vd2008-10-15iizn91/788IZN70cOPBByKNJaFFZG w2008-10-15p1301000050r2008-10-1540006BB_PAU_V950bFFZG10oBB PAU vd2008-10-15iizn91/778IZN70cOPBByKNJaFFZG w2008-10-15p1301000049r2008-10-154000949bFFZG10d2008-10-15iizn90/36D8IZN70cZSPOyKNJaFFZG w2008-10-15p1301000048r2008-10-154000948bFFZG10d2008-10-15iizn90/358IZN70cZSPOyKNJaFFZG w2008-10-15p1301000047r2008-10-154000947bFFZG10d2008-10-15iizn90/34D8IZN70cZSPOyKNJaFFZG aizn90/34D aizn90/35 aizn90/36D aizn91/77 aizn91/78 aIZbAP c45d45 -- 2.20.1