aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2012-06-20 14:20:51 +0200
committerJay Berkenbilt <ejb@ql.org>2012-06-20 21:29:44 +0200
commit91d175452d851776c98ca1ac46fec423a6926389 (patch)
treeb260452c6110829959baa79b11c737ff8ef3b320
parentdb7474e0facd82577edfc1cc4883bce3fa588584 (diff)
downloadqpdf-91d175452d851776c98ca1ac46fec423a6926389.tar.zst
Add testing for new array mutators
-rw-r--r--qpdf/qtest/qpdf/test4-1.qdf25
-rw-r--r--qpdf/qtest/qpdf/test4-4.pdf16
-rw-r--r--qpdf/qtest/qpdf/test4-4.qdf30
-rw-r--r--qpdf/test_driver.cc24
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 [<c61bd35bada064f61e0a56aa9588064e><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 [<c61bd35bada064f61e0a56aa9588064e><c893e7330be149468080ad6518819868>]
>>
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 [<c61bd35bada064f61e0a56aa9588064e><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<QPDFObjectHandle> 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);