From 76c4f78b5cfd786b90069f7256252229444fdecd Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sat, 22 Jan 2022 17:33:53 -0500 Subject: Add QUtil::make_shared_cstr Replace most of the calls to QUtil::copy_string with this instead. --- libtests/qutil.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'libtests/qutil.cc') 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 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() -- cgit v1.2.3-54-g00ecf