2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-22 19:08:59 +00:00

Add new object stream test case

Exercise stream containing objects with no white-space between them.
This commit is contained in:
m-holger 2024-08-15 00:52:59 +01:00
parent 6aa6c01303
commit 0a8e62839c
4 changed files with 25 additions and 2 deletions

View File

@ -16,7 +16,7 @@ cleanup();
my $td = new TestDriver('object-stream'); my $td = new TestDriver('object-stream');
my $n_tests = 9 + (36 * 4) + (12 * 2); my $n_tests = 10 + (36 * 4) + (12 * 2);
my $n_compare_pdfs = 36; my $n_compare_pdfs = 36;
for (my $n = 16; $n <= 19; ++$n) for (my $n = 16; $n <= 19; ++$n)
@ -117,6 +117,14 @@ $td->runtest("check file",
{$td->FILE => "a.pdf"}, {$td->FILE => "a.pdf"},
{$td->FILE => "object-stream-self-ref.out.pdf"}); {$td->FILE => "object-stream-self-ref.out.pdf"});
# The file no-space-compressed-object.pdf contains an object stream containing two
# integer objects that are not separated by any white space. The test case exercises
# that all objects in the stream have the correct value.
$td->runtest("adjacent compressed objects",
{$td->COMMAND => "test_driver 99 no-space-compressed-object.pdf"},
{$td->FILE => "no-space-compressed-object.out",
$td->EXIT_STATUS => 0},
$td->EXPECT_FAILURE);
cleanup(); cleanup();
$td->report(calc_ntests($n_tests, $n_compare_pdfs)); $td->report(calc_ntests($n_tests, $n_compare_pdfs));

View File

@ -0,0 +1,5 @@
1234
5678
(orig-3)
(orig-4)
test 99 done

Binary file not shown.

View File

@ -3453,6 +3453,16 @@ test_98(QPDF& pdf, char const* arg2)
"}"); "}");
} }
static void
test_99(QPDF& pdf, char const* arg2)
{
// Designed for no-space-compressed-object.pdf
QPDFObjectHandle qtest = pdf.getRoot().getKey("/QTest");
for (int i = 0; i < qtest.getArrayNItems(); ++i) {
std::cout << qtest.getArrayItem(i).unparseResolved() << std::endl;
}
}
void void
runtest(int n, char const* filename1, char const* arg2) runtest(int n, char const* filename1, char const* arg2)
{ {
@ -3554,7 +3564,7 @@ runtest(int n, char const* filename1, char const* arg2)
{78, test_78}, {79, test_79}, {80, test_80}, {81, test_81}, {82, test_82}, {83, test_83}, {78, test_78}, {79, test_79}, {80, test_80}, {81, test_81}, {82, test_82}, {83, test_83},
{84, test_84}, {85, test_85}, {86, test_86}, {87, test_87}, {88, test_88}, {89, test_89}, {84, test_84}, {85, test_85}, {86, test_86}, {87, test_87}, {88, test_88}, {89, test_89},
{90, test_90}, {91, test_91}, {92, test_92}, {93, test_93}, {94, test_94}, {95, test_95}, {90, test_90}, {91, test_91}, {92, test_92}, {93, test_93}, {94, test_94}, {95, test_95},
{96, test_96}, {97, test_97}, {98, test_98}}; {96, test_96}, {97, test_97}, {98, test_98}, {99, test_99}};
auto fn = test_functions.find(n); auto fn = test_functions.find(n);
if (fn == test_functions.end()) { if (fn == test_functions.end()) {