File: rt120397.t

package info (click to toggle)
libpdf-api2-perl 2.047-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 20,228 kB
  • sloc: perl: 42,227; makefile: 11
file content (87 lines) | stat: -rw-r--r-- 3,174 bytes parent folder | download | duplicates (4)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
use Test::More;

use PDF::API2::Basic::PDF::File;

my ($result, $remainder);

sub readval {
    my ($read, $unread, %options) = @_;
    open my $fh, '<', \$unread;
    my $parser = { ' INFILE' => $fh };
    bless $parser, 'PDF::API2::Basic::PDF::File';
    my ($result, $remainder) = $parser->readval($read, %options);
    close $fh;
    return ($result, $remainder);
}

($result, $remainder) = readval('1 0 R', '');
is(ref($result), 'PDF::API2::Basic::PDF::Objind',
   q{Basic indirect reference});

($result, $remainder) = readval('1 0 obj << >> endobj', '');
is(ref($result), 'PDF::API2::Basic::PDF::Dict',
   q{Basic indirect object});

($result, $remainder) = readval('1', '');
is(ref($result), 'PDF::API2::Basic::PDF::Number',
   q{Basic number});

($result, $remainder) = readval("1\n0 R", '');
is(ref($result), 'PDF::API2::Basic::PDF::Objind',
   q{Indirect reference on multiple already-read lines});

($result, $remainder) = readval("1\n0 obj << >> endobj", '');
is(ref($result), 'PDF::API2::Basic::PDF::Dict',
   q{Indirect object on multiple already-read lines});

($result, $remainder) = readval("1 %comment\n0 R", '');
is(ref($result), 'PDF::API2::Basic::PDF::Objind',
   q{Indirect reference with embedded comment 1/2});

($result, $remainder) = readval("1 0 %comment\nR", '');
is(ref($result), 'PDF::API2::Basic::PDF::Objind',
   q{Indirect reference with embedded comment 2/2});

($result, $remainder) = readval("1 %comment\n0 obj << >> endobj", '');
is(ref($result), 'PDF::API2::Basic::PDF::Dict',
   q{Indirect object with embedded comment 1/3});

($result, $remainder) = readval("1 0 %comment\nobj << >> endobj", '');
is(ref($result), 'PDF::API2::Basic::PDF::Dict',
   q{Indirect object with embedded comment 2/3});

($result, $remainder) = readval("1 0 obj %comment\n<< >> endobj", '');
is(ref($result), 'PDF::API2::Basic::PDF::Dict',
   q{Indirect object with embedded comment 3/3});

($result, $remainder) = readval('1', ' 0 R');
is(ref($result), 'PDF::API2::Basic::PDF::Objind',
   q{Indirect reference on partially-read line});

($result, $remainder) = readval('1', ' 0 obj << >> endobj');
is(ref($result), 'PDF::API2::Basic::PDF::Dict',
   q{Indirect object on partially-read line});

($result, $remainder) = readval("1\n", '0 R');
is(ref($result), 'PDF::API2::Basic::PDF::Objind',
   q{Indirect reference on multiple lines with only the first line read 1/3});

($result, $remainder) = readval("1 0\n", 'R');
is(ref($result), 'PDF::API2::Basic::PDF::Objind',
   q{Indirect reference on multiple lines with only the first line read 2/3});

($result, $remainder) = readval("1 0%comment\n", 'R');
is(ref($result), 'PDF::API2::Basic::PDF::Objind',
   q{Indirect reference on multiple lines with only the first line read 3/3});

($result, $remainder) = readval("1\n", '0 obj << >> endobj');
is(ref($result), 'PDF::API2::Basic::PDF::Dict',
   q{Indirect object on multiple lines with only the first line read});

($result, $remainder) = readval("1\n", '(string)');
is(ref($result), 'PDF::API2::Basic::PDF::Number',
   q{Number on a line by itself followed by a non-number});
is($remainder, '(string)',
   q{Remainder doesn't get lost});

done_testing();