From 91d175452d851776c98ca1ac46fec423a6926389 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Wed, 20 Jun 2012 08:20:51 -0400 Subject: Add testing for new array mutators --- qpdf/qtest/qpdf/test4-1.qdf | 25 ++++++++++++++----------- qpdf/qtest/qpdf/test4-4.pdf | 16 ++++++++-------- qpdf/qtest/qpdf/test4-4.qdf | 30 +++++++++++++++--------------- qpdf/test_driver.cc | 24 ++++++++++++++++++++++-- 4 files changed, 59 insertions(+), 36 deletions(-) diff --git a/qpdf/qtest/qpdf/test4-1.qdf b/qpdf/qtest/qpdf/test4-1.qdf index 916a9cc3..b22fd6f7 100644 --- a/qpdf/qtest/qpdf/test4-1.qdf +++ b/qpdf/qtest/qpdf/test4-1.qdf @@ -14,9 +14,12 @@ endobj 2 0 obj << /A [ + 9 1 5 - 3 + 10 + 12 + 6 ] /Author (Mr. Potato Head) /B << @@ -134,15 +137,15 @@ xref 0000000000 65535 f 0000000052 00000 n 0000000134 00000 n -0000000333 00000 n -0000000455 00000 n -0000000555 00000 n -0000000615 00000 n -0000000694 00000 n -0000000938 00000 n -0000001037 00000 n -0000001083 00000 n -0000001229 00000 n +0000000353 00000 n +0000000475 00000 n +0000000575 00000 n +0000000635 00000 n +0000000714 00000 n +0000000958 00000 n +0000001057 00000 n +0000001103 00000 n +0000001249 00000 n trailer << /Info 2 0 R /QTest 3 0 R @@ -151,5 +154,5 @@ trailer << /ID [<31415926535897932384626433832795>] >> startxref -1265 +1285 %%EOF diff --git a/qpdf/qtest/qpdf/test4-4.pdf b/qpdf/qtest/qpdf/test4-4.pdf index e0856e3b..5b910200 100644 --- a/qpdf/qtest/qpdf/test4-4.pdf +++ b/qpdf/qtest/qpdf/test4-4.pdf @@ -30,7 +30,7 @@ endobj 4 0 obj [ - 1 + 100 2 3 ] @@ -106,12 +106,12 @@ xref 0000000079 00000 n 0000000174 00000 n 0000000246 00000 n -0000000278 00000 n -0000000330 00000 n -0000000546 00000 n -0000000645 00000 n -0000000664 00000 n -0000000782 00000 n +0000000280 00000 n +0000000332 00000 n +0000000548 00000 n +0000000647 00000 n +0000000666 00000 n +0000000784 00000 n trailer << /QTest 2 0 R /Root 1 0 R @@ -119,5 +119,5 @@ trailer << /ID [] >> startxref -818 +820 %%EOF diff --git a/qpdf/qtest/qpdf/test4-4.qdf b/qpdf/qtest/qpdf/test4-4.qdf index 838ccbe3..930bf431 100644 --- a/qpdf/qtest/qpdf/test4-4.qdf +++ b/qpdf/qtest/qpdf/test4-4.qdf @@ -14,14 +14,14 @@ endobj 2 0 obj << /A [ - 1 - 5 - 3 + 14 + 15 + 9 ] /Author (Mr. Potato Head) /B << /A [ - 1 + 100 2 3 ] @@ -55,7 +55,7 @@ endobj %% Original object ID: 4 0 5 0 obj [ - 1 + 100 2 3 ] @@ -134,15 +134,15 @@ xref 0000000000 65535 f 0000000052 00000 n 0000000134 00000 n -0000000333 00000 n -0000000455 00000 n -0000000554 00000 n -0000000613 00000 n -0000000692 00000 n -0000000936 00000 n -0000001035 00000 n -0000001081 00000 n -0000001228 00000 n +0000000337 00000 n +0000000459 00000 n +0000000558 00000 n +0000000619 00000 n +0000000698 00000 n +0000000942 00000 n +0000001041 00000 n +0000001087 00000 n +0000001234 00000 n trailer << /Info 2 0 R /QTest 3 0 R @@ -151,5 +151,5 @@ trailer << /ID [<31415926535897932384626433832795>] >> startxref -1264 +1270 %%EOF diff --git a/qpdf/test_driver.cc b/qpdf/test_driver.cc index a4d1023d..ca2fc698 100644 --- a/qpdf/test_driver.cc +++ b/qpdf/test_driver.cc @@ -284,8 +284,28 @@ void runtest(int n, char const* filename) QPDFObjectHandle::newString("Mr. Potato Head")); // qtest.A and qtest.B.A were originally the same object. // They no longer are after makeDirect(). Mutate one of them - // and ensure the other is not changed. - qtest.getKey("/A").setArrayItem(1, QPDFObjectHandle::newInteger(5)); + // and ensure the other is not changed. These test cases are + // crafted around a specific set of input files. + QPDFObjectHandle A = qtest.getKey("/A"); + if (A.getArrayItem(0).getIntValue() == 1) + { + // Test mutators + A.setArrayItem(1, QPDFObjectHandle::newInteger(5)); // 1 5 3 + A.insertItem(2, QPDFObjectHandle::newInteger(10)); // 1 5 10 3 + A.appendItem(QPDFObjectHandle::newInteger(12)); // 1 5 10 3 12 + A.eraseItem(3); // 1 5 10 12 + A.insertItem(4, QPDFObjectHandle::newInteger(6)); // 1 5 10 12 6 + A.insertItem(0, QPDFObjectHandle::newInteger(9)); // 9 1 5 10 12 6 + } + else + { + std::vector items; + items.push_back(QPDFObjectHandle::newInteger(14)); + items.push_back(QPDFObjectHandle::newInteger(15)); + items.push_back(QPDFObjectHandle::newInteger(9)); + A.setArrayFromVector(items); + } + trailer.replaceKey("/Info", pdf.makeIndirectObject(qtest)); QPDFWriter w(pdf, 0); w.setQDFMode(true); -- cgit v1.2.3-54-g00ecf