mirror of
https://github.com/qpdf/qpdf.git
synced 2024-10-31 19:02:30 +00:00
Add boundary condition test for getUniqueResourceName
This commit is contained in:
parent
2d1db06042
commit
c2ae35540e
@ -1032,12 +1032,19 @@ $td->runtest("detect foreign object in write",
|
||||
show_ntests();
|
||||
# ----------
|
||||
$td->notify("--- Merge Dictionary ---");
|
||||
$n_tests += 1;
|
||||
$n_tests += 3;
|
||||
|
||||
$td->runtest("merge dictionary",
|
||||
{$td->COMMAND => "test_driver 50 merge-dict.pdf"},
|
||||
{$td->FILE => "merge-dict.out", $td->EXIT_STATUS => 0},
|
||||
$td->NORMALIZE_NEWLINES);
|
||||
$td->runtest("unique resource name",
|
||||
{$td->COMMAND => "test_driver 60 minimal.pdf"},
|
||||
{$td->STRING => "test 60 done\n", $td->EXIT_STATUS => 0},
|
||||
$td->NORMALIZE_NEWLINES);
|
||||
$td->runtest("check output",
|
||||
{$td->FILE => "a.pdf"},
|
||||
{$td->FILE => "unique-resources.pdf"});
|
||||
|
||||
show_ntests();
|
||||
# ----------
|
||||
|
BIN
qpdf/qtest/qpdf/unique-resources.pdf
Normal file
BIN
qpdf/qtest/qpdf/unique-resources.pdf
Normal file
Binary file not shown.
@ -2016,6 +2016,23 @@ void runtest(int n, char const* filename1, char const* arg2)
|
||||
w.setStaticID(true);
|
||||
w.write();
|
||||
}
|
||||
else if (n == 60)
|
||||
{
|
||||
// Boundary condition testing for getUniqueResourceName
|
||||
QPDFObjectHandle r1 = QPDFObjectHandle::newDictionary();
|
||||
int min_suffix = 1;
|
||||
for (int i = 1; i < 3; ++i)
|
||||
{
|
||||
std::string name = r1.getUniqueResourceName("/Quack", min_suffix);
|
||||
r1.mergeResources(QPDFObjectHandle::parse("<< /Z << >> >>"));
|
||||
r1.getKey("/Z").replaceKey(
|
||||
name, QPDFObjectHandle::newString("moo"));
|
||||
}
|
||||
pdf.getTrailer().replaceKey("/QTest", r1);
|
||||
QPDFWriter w(pdf, "a.pdf");
|
||||
w.setStaticID(true);
|
||||
w.write();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error(std::string("invalid test ") +
|
||||
|
Loading…
Reference in New Issue
Block a user