aboutsummaryrefslogtreecommitdiffstats
path: root/libtests
diff options
context:
space:
mode:
authorm-holger <m-holger@kubitscheck.org>2023-05-25 15:10:47 +0200
committerm-holger <m-holger@kubitscheck.org>2023-06-17 18:18:31 +0200
commit0f2ef5e85bce0d64683e8071151711f21fa3e052 (patch)
tree5aee7e0f1c37f1acca3f4d4f7a390d5e409b2b81 /libtests
parentacd0acf16931ce92bc908e4960c5a1e43d53b550 (diff)
downloadqpdf-0f2ef5e85bce0d64683e8071151711f21fa3e052.tar.zst
Add new Buffer method copy and deprecate copy constructor / assignment operator
Also fix accidental Buffer copy in Pl_LZWDecoder::addToTable.
Diffstat (limited to 'libtests')
-rw-r--r--libtests/buffer.cc32
1 files changed, 31 insertions, 1 deletions
diff --git a/libtests/buffer.cc b/libtests/buffer.cc
index 86a52899..e62a37ca 100644
--- a/libtests/buffer.cc
+++ b/libtests/buffer.cc
@@ -19,7 +19,34 @@ int
main()
{
{
- // Test that buffers can be copied by value.
+ // Test that buffers can be copied by value using Buffer::copy.
+ Buffer bc1(2);
+ unsigned char* bc1p = bc1.getBuffer();
+ bc1p[0] = 'Q';
+ bc1p[1] = 'W';
+ Buffer bc2(bc1.copy());
+ bc1p[0] = 'R';
+ unsigned char* bc2p = bc2.getBuffer();
+ assert(bc2p != bc1p);
+ assert(bc2p[0] == 'Q');
+ assert(bc2p[1] == 'W');
+ bc2 = bc1.copy();
+ bc2p = bc2.getBuffer();
+ assert(bc2p != bc1p);
+ assert(bc2p[0] == 'R');
+ assert(bc2p[1] == 'W');
+ }
+
+#ifdef _MSC_VER
+# pragma warning(disable : 4996)
+#endif
+#if (defined(__GNUC__) || defined(__clang__))
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
+ {
+ // Test that buffers can be copied by value using copy construction / assignment.
+ Buffer::setTestMode();
Buffer bc1(2);
unsigned char* bc1p = bc1.getBuffer();
bc1p[0] = 'Q';
@@ -36,6 +63,9 @@ main()
assert(bc2p[0] == 'R');
assert(bc2p[1] == 'W');
}
+#if (defined(__GNUC__) || defined(__clang__))
+# pragma GCC diagnostic pop
+#endif
{
// Test that buffers can be moved.