aboutsummaryrefslogtreecommitdiffstats
path: root/libtests/qutil.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-01-22 23:33:53 +0100
committerJay Berkenbilt <ejb@ql.org>2022-01-30 19:11:03 +0100
commit76c4f78b5cfd786b90069f7256252229444fdecd (patch)
treeb84a4a401b26fc84846343f28c28a91c35e9fa87 /libtests/qutil.cc
parent67f9d0b7d5857a73c974f5a54cd1abbe65231fce (diff)
downloadqpdf-76c4f78b5cfd786b90069f7256252229444fdecd.tar.zst
Add QUtil::make_shared_cstr
Replace most of the calls to QUtil::copy_string with this instead.
Diffstat (limited to 'libtests/qutil.cc')
-rw-r--r--libtests/qutil.cc14
1 files changed, 12 insertions, 2 deletions
diff --git a/libtests/qutil.cc b/libtests/qutil.cc
index cd2b7796..f59b564d 100644
--- a/libtests/qutil.cc
+++ b/libtests/qutil.cc
@@ -150,6 +150,16 @@ void string_conversion_test()
std::cout << "compare failed" << std::endl;
}
delete [] tmp;
+ // Also test with make_shared_cstr
+ auto tmp2 = QUtil::make_shared_cstr(embedded_null);
+ if (memcmp(tmp2.get(), embedded_null.c_str(), 7) == 0)
+ {
+ std::cout << "compare okay" << std::endl;
+ }
+ else
+ {
+ std::cout << "compare failed" << std::endl;
+ }
std::string int_max_str = QUtil::int_to_string(INT_MAX);
std::string int_min_str = QUtil::int_to_string(INT_MIN);
@@ -407,8 +417,8 @@ void transcoding_test()
void print_whoami(char const* str)
{
- PointerHolder<char> dup(true, QUtil::copy_string(str));
- std::cout << QUtil::getWhoami(dup.getPointer()) << std::endl;
+ auto dup = QUtil::make_shared_cstr(str);
+ std::cout << QUtil::getWhoami(dup.get()) << std::endl;
}
void get_whoami_test()