From 0a8e62839cdae8dc135244ec53dd20393999f2d6 Mon Sep 17 00:00:00 2001 From: m-holger Date: Thu, 15 Aug 2024 00:52:59 +0100 Subject: [PATCH] Add new object stream test case Exercise stream containing objects with no white-space between them. --- qpdf/qtest/object-stream.test | 10 +++++++++- qpdf/qtest/qpdf/no-space-compressed-object.out | 5 +++++ qpdf/qtest/qpdf/no-space-compressed-object.pdf | Bin 0 -> 1391 bytes qpdf/test_driver.cc | 12 +++++++++++- 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 qpdf/qtest/qpdf/no-space-compressed-object.out create mode 100644 qpdf/qtest/qpdf/no-space-compressed-object.pdf diff --git a/qpdf/qtest/object-stream.test b/qpdf/qtest/object-stream.test index bed3fefa..891f74aa 100644 --- a/qpdf/qtest/object-stream.test +++ b/qpdf/qtest/object-stream.test @@ -16,7 +16,7 @@ cleanup(); 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; for (my $n = 16; $n <= 19; ++$n) @@ -117,6 +117,14 @@ $td->runtest("check file", {$td->FILE => "a.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(); $td->report(calc_ntests($n_tests, $n_compare_pdfs)); diff --git a/qpdf/qtest/qpdf/no-space-compressed-object.out b/qpdf/qtest/qpdf/no-space-compressed-object.out new file mode 100644 index 00000000..a557db56 --- /dev/null +++ b/qpdf/qtest/qpdf/no-space-compressed-object.out @@ -0,0 +1,5 @@ +1234 +5678 +(orig-3) +(orig-4) +test 99 done diff --git a/qpdf/qtest/qpdf/no-space-compressed-object.pdf b/qpdf/qtest/qpdf/no-space-compressed-object.pdf new file mode 100644 index 0000000000000000000000000000000000000000..098809f6ba80ee0d04a3a178c4bf74db9addaa9d GIT binary patch literal 1391 zcmaJ>+iuf95KUWd+CSiJULv&;#oqPq+D26*dWk?l8xo@;Ref;mZE)4vmAyrQ&*4Y- zCEj>L%&hGciKeTJ_clA{%q_#o;dqz7RBZV3_m4kpxZ4iKIQUS_FWKH61Mre>HwL_u z`Q^-B)Be3F7xoK8p`hI{#59eIy0H+&Y&2qxtxbB(1o$if9{5ax5P~U?QZWrG3Rnm_ zh*$(#3Kl~sBF23PL&=6iKqQk{Xsx^=BD57RpeS>*M58UONxCo%1W0vC1U@DP37p{) zAnXnSqSY#1tq`ewb58GC?+#L%UR4WXzm`GJGvFPAgX*@lz{$$HB5yiy`M-5X^+DUR zw=D>t^wDnX=Rs9kQ`!bNrN#OB!Q@4{UoAUC-#OiWHK(j#2x6L@hm*9%_ji$+nx?v~ zGYp;spyVM$zo9J$wTc!-gzR~fy2@t8g6?kIc^5t6`=EQOcQ5Fi+D{wfP`x+i>Z`Fu zmLiOIRAyCPlnd}qi}H2Z6#W5R9;eq>hhrD-+3noAvZVC6lQxfJ^Fb!MXCfKZiia&g zQ(~5uov+V**gsQ@i$E$JM(dTMURhJ*+*q$1_sSvLuIgg38| z4p-E+^nO(}7gY^6Z9TaHB89fFx<2OEr&v~ZeY>AfM6d{igyaI(p}?OHNsjC7No7-8 z?LczLj*@$@ojC%Ll5QOzPF;Ej+@|XD)R6K1??h?ZoWdC(Fp4YPX;oq8cNOQ&itpGK zlJwpl!r5Lnk8~`#@|DVjig_M$!2_Z6T!*V@(ATI$`h2QD9<*we&OjSlwxpC5E`4-c3Go?oQoLq Jada|fe*tEsUXTC) literal 0 HcmV?d00001 diff --git a/qpdf/test_driver.cc b/qpdf/test_driver.cc index fd50cbce..60759996 100644 --- a/qpdf/test_driver.cc +++ b/qpdf/test_driver.cc @@ -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 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}, {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}, - {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); if (fn == test_functions.end()) {