File: fdfparser_round.t

package info (click to toggle)
libpdf-fdf-simple-perl 0.21-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,004 kB
  • sloc: perl: 15,109; makefile: 7
file content (68 lines) | stat: -rw-r--r-- 1,813 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
### -*- mode: perl; -*-

use Test::More;
use PDF::FDF::Simple;

use Data::Dumper;
use strict;
use warnings;

plan tests => 10;

################## tests ##################

my $readonly_testfile = './t/fdfparser_standard.fdf';
my $writeto_testfile  = './t/fdfparser_output.fdf';

#first parser reads and parses a given fdf file
#and stores a newly created fdf file with Dot-notation
my $parser = new PDF::FDF::Simple ({
                                    filename => $readonly_testfile,
                                   });
ok ($parser, "setting up 1");

my $fdf_content_ptr = $parser->load;
ok ((scalar keys %$fdf_content_ptr == 18),
    "parsing 1");

$parser->filename ($writeto_testfile);
my $successfull_save = $parser->save;
ok ($successfull_save,
    "saving 1");

#second parser parses the created fdf file
my $parser2 = new PDF::FDF::Simple ({
                                     filename => $writeto_testfile,
                                    });
ok ($parser2,
    "setting up 2");

my $new_fdf_content = $parser2->load;
ok ((scalar keys %$new_fdf_content),
    "parsing 1");

#print STDERR "1: ".(scalar keys %$new_fdf_content)."\n";
#print STDERR "2: ".(scalar keys %$fdf_content_ptr)."\n";
ok ((scalar keys %$new_fdf_content == scalar keys %$fdf_content_ptr),
    "compare size");

my $compare_success = 1;

foreach my $key (keys %$new_fdf_content) {
  if ( $new_fdf_content->{$key} ne $fdf_content_ptr->{$key} ) {
    $compare_success = 0;
    print "error\n";
    last;
  }
}
ok ($compare_success,
    "compare");

is( $parser->attribute_file,  $parser2->attribute_file,  "compare file" );
is( $parser->attribute_ufile, $parser2->attribute_ufile, "compare ufile" );

is_deeply( [ sort @{$parser->attribute_id}  ],
           [ sort @{$parser2->attribute_id} ],
           "compare ids" );