From a51ae10b8ddada900c1abacd6284d35f6e65aa08 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Thu, 28 Feb 2013 16:20:45 -0500 Subject: Remove all calls to sprintf --- libtests/qutil.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'libtests/qutil.cc') diff --git a/libtests/qutil.cc b/libtests/qutil.cc index 8d9c2383..dedd73d1 100644 --- a/libtests/qutil.cc +++ b/libtests/qutil.cc @@ -23,7 +23,10 @@ void string_conversion_test() << QUtil::double_to_string(.1234, 5) << std::endl << QUtil::double_to_string(.0001234, 5) << std::endl << QUtil::double_to_string(.123456, 5) << std::endl - << QUtil::double_to_string(.000123456, 5) << std::endl; + << QUtil::double_to_string(.000123456, 5) << std::endl + << QUtil::int_to_string_base(16059, 10) << std::endl + << QUtil::int_to_string_base(16059, 8) << std::endl + << QUtil::int_to_string_base(16059, 16) << std::endl; std::string embedded_null = "one"; embedded_null += '\0'; @@ -86,10 +89,8 @@ void getenv_test() static void print_utf8(unsigned long val) { - char t[20]; - sprintf(t, "%lx", val); // XXXX std::string result = QUtil::toUTF8(val); - std::cout << "0x" << t << " ->"; + std::cout << "0x" << QUtil::int_to_string_base(val, 16) << " ->"; if (val < 0xfffe) { std::cout << " " << result; @@ -102,9 +103,8 @@ static void print_utf8(unsigned long val) for (std::string::iterator iter = result.begin(); iter != result.end(); ++iter) { - char t[3]; - sprintf(t, "%02x", static_cast(*iter)); // XXXX - std::cout << " " << t; + std::cout << " " << QUtil::int_to_string_base( + static_cast(static_cast(*iter)), 16, 2); } } std::cout << std::endl; -- cgit v1.2.3-54-g00ecf