File: table.t

package info (click to toggle)
libmarc-charset-perl 1.35-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 2,476 kB
  • sloc: xml: 99,038; perl: 774; makefile: 9
file content (38 lines) | stat: -rw-r--r-- 1,188 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use Test::More qw(no_plan);
use strict;
use warnings;

use_ok('MARC::Charset::Table');

# constructor
my $table = MARC::Charset::Table->new();
isa_ok($table, 'MARC::Charset::Table');

# underlying db
isa_ok($table->db(), 'HASH', 'db()');
like($table->db_path(), qr|MARC/Charset/Table|, 'db_path()');

# fake the table into thinking it's a hash don't want to change the 
# real db that was created when we ran Makefile.PL
$table->{db} = {};

# add a code
my $code = MARC::Charset::Code->new();
$code->name('UPPERCASE POLISH L');
$code->marc('A1');
$code->ucs('0141');
$code->charset('45');
$table->add_code($code);

# see if we can get it back
my $retrieved_code = $table->get_code($code->marc8_hash_code());
is($retrieved_code->to_string(), $code->to_string(), 'get_code() marc8');

$retrieved_code = $table->get_code($code->utf8_hash_code());
is($retrieved_code->to_string(), $code->to_string(), 'get_code() utf8');

$retrieved_code = $table->lookup_by_marc8(chr(0x45), chr(0xA1));
is($retrieved_code->to_string(), $code->to_string(), 'lookup_by_marc8()');

$retrieved_code = $table->lookup_by_utf8(chr(0x0141));
is($retrieved_code->to_string(), $code->to_string(), 'lookup_by_utf8()');