File Coverage

File:t/Circulation_barcodedecode.t
Coverage:93.5%

linestmtbrancondsubtimecode
1#!/usr/bin/perl
2#
3
4
1
1
1
1.33283521173069e+15
8
25
use strict;
5
1
1
1
4
1
33
use warnings;
6
7
1
1
1
233
19390
27
use Test::More tests => 24;
8
1
1068434
C4::Context->_new_userenv(123456);
9
1
9
C4::Context->set_userenv(1,'kmkale' , 1, 'kk1' , 'IMS', 0, 'kmkale@anantcorp.com');
10
11BEGIN {
12
1
1297
    use_ok('C4::Circulation');
13}
14
15
1
17
our %inputs = (
16    cuecat => ["26002315", '.C3nZC3nZC3nYD3b6ENnZCNnY.fHmc.C3D1Dxr2C3nZE3n7.', ".C3nZC3nZC3nYD3b6ENnZCNnY.fHmc.C3D1Dxr2C3nZE3n7.\r\n",
17                    'q.C3nZC3nZC3nWDNzYDxf2CNnY.fHmc.C3DWC3nZCNjXD3nW.', '.C3nZC3nZC3nWCxjWE3D1C3nX.cGf2.ENr7C3v7D3T3ENj3C3zYDNnZ.' ],
18    whitespace => [" 26002315", "26002315 ", "\n\t26002315\n"],
19    'T-prefix' => [qw(T0031472 T32)],
20    'libsuite8' => ['b000126', 'b12', 'B0126', 'IMS-B-126', 'ims-b-126','CD0000024','00123','11998'],
21    other => [qw(26002315 T0031472 T32 Alphanum123), "Alpha Num 345"],
22);
23
1
14
our %outputs = (
24    cuecat => ["26002315", "046675000808", "046675000808", "043000112403", "978068484914051500"],
25    whitespace => [qw(26002315 26002315 26002315)],
26    'T-prefix' => [qw(T0031472 T0000002 )],
27    'libsuite8' => ['IMS-b-126', 'IMS-b-12', 'IMS-B-126', 'IMS-B-126', 'ims-b-126','IMS-CD-24','IMS-b-123','IMS-b-11998'],
28    other => [qw(26002315 T0031472 T32 Alphanum123), "Alpha Num 345"],
29);
30
31
1
8
my @filters = sort keys %inputs;
32
1
2
foreach my $filter (@filters) {
33
5
5
9
11
    foreach my $datum (@{$inputs{$filter}}) {
34
23
23
66
85
        my $expect = shift @{$outputs{$filter}} or die "Internal Test Error: missing expected output for filter '$filter' on input '$datum'";
35
23
168
        my $output = C4::Circulation::barcodedecode($datum, $filter);
36
23
237
        ok($output eq $expect, sprintf("%12s: %20s => %15s", $filter, "'$datum'", "'$expect'"));
37
23
11288
        ($output eq $expect) or diag "Bad output: '$output'";
38    }
39}
40