summaryrefslogtreecommitdiffstats
path: root/qpdf/test_driver.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-04-10 15:29:11 +0200
committerJay Berkenbilt <ejb@ql.org>2022-04-10 22:52:57 +0200
commit5525c9312420cf002aef78fa1d52219724d3fc20 (patch)
tree4a3436dc380081500cd58a8f041e20cecec9ff6f /qpdf/test_driver.cc
parent90cfe80bacdd0d398631afce76c4182e08cc78b9 (diff)
downloadqpdf-5525c9312420cf002aef78fa1d52219724d3fc20.tar.zst
Use QPDF_DLL_CLASS with Pipeline and InputSource subclasses
This enables RTTI so we can use dynamic_cast on them across the shared object boundary.
Diffstat (limited to 'qpdf/test_driver.cc')
-rw-r--r--qpdf/test_driver.cc17
1 files changed, 15 insertions, 2 deletions
diff --git a/qpdf/test_driver.cc b/qpdf/test_driver.cc
index 8a93721f..6e48bb35 100644
--- a/qpdf/test_driver.cc
+++ b/qpdf/test_driver.cc
@@ -3,6 +3,7 @@
#include <qpdf/QPDF.hh>
+#include <qpdf/BufferInputSource.hh>
#include <qpdf/Pl_Buffer.hh>
#include <qpdf/Pl_Discard.hh>
#include <qpdf/Pl_Flate.hh>
@@ -2314,8 +2315,9 @@ test_60(QPDF& pdf, char const* arg2)
static void
test_61(QPDF& pdf, char const* arg2)
{
- // Test to make sure exceptions can be caught properly across
- // shared library boundaries.
+ // Test to make sure type information is passed across shared
+ // library boundaries. This includes exception handling, dynamic
+ // cast, and subclassing.
pdf.setAttemptRecovery(false);
pdf.setSuppressWarnings(true);
try {
@@ -2338,6 +2340,17 @@ test_61(QPDF& pdf, char const* arg2)
} catch (std::runtime_error const&) {
std::cout << "Caught runtime_error as expected" << std::endl;
}
+
+ // Spot check RTTI for dynamic cast. We intend to have pipelines
+ // and input sources be testable, but adding comprehensive tests
+ // for everything doesn't add value as it wouldn't catch
+ // forgetting QPDF_DLL_CLASS on a new subclass.
+ BufferInputSource b("x", "y");
+ InputSource* is = &b;
+ assert(dynamic_cast<BufferInputSource*>(is) != nullptr);
+ Pl_Discard pd;
+ Pipeline* p = &pd;
+ assert(dynamic_cast<Pl_Discard*>(p) != nullptr);
}
static void