2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-05-29 16:30:53 +00:00
qpdf/qpdf/qtest/qpdf_json.test
Jay Berkenbilt 6f43bf8de3 Major rework -- see long comments
* Replace --create-from-json=file with --json-input, which causes the
  regular input to be treated as json.
* Eliminate --to-json
* In --json=2, bring back "objects" and eliminate "objectinfo". Stream
  data is never present.
* In --json-output=2, write "qpdf-v2" with "objects" and include
  stream data.
2022-05-20 09:16:25 -04:00

51 lines
987 B
Perl

#!/usr/bin/env perl
require 5.008;
use warnings;
use strict;
unshift(@INC, '.');
require qpdf_test_helpers;
chdir("qpdf") or die "chdir testdir failed: $!\n";
require TestDriver;
cleanup();
my $td = new TestDriver('qpdf-json');
my $n_tests = 0;
my @badfiles = (
'no-qpdf-object',
'no-pdf-version',
'top-level-scalar',
'bad-pdf-version1',
'bad-pdf-version2',
'top-level-array',
'objects-not-dict',
'bad-object-key',
'object-not-dict',
'stream-not-dict',
'stream-dict-not-dict',
'trailer-not-dict',
'trailer-stream',
'missing-trailer',
'missing-objects',
'obj-key-errors',
);
$n_tests += scalar(@badfiles);
foreach my $f (@badfiles)
{
$td->runtest("bad: $f",
{$td->COMMAND =>
"qpdf --json-input qjson-$f.json a.pdf"},
{$td->FILE => "qjson-$f.out", $td->EXIT_STATUS => 2},
$td->NORMALIZE_NEWLINES);
}
cleanup();
$td->report($n_tests);