From fcfdeac1c76f749ea88d72b139e20db0e0549fe5 Mon Sep 17 00:00:00 2001 From: Max Kellermann <max@musicpd.org> Date: Wed, 24 Jan 2018 13:32:39 +0100 Subject: [PATCH] test/test_translate_song: use std::to_string() --- test/test_translate_song.cxx | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/test/test_translate_song.cxx b/test/test_translate_song.cxx index e958552ba..4a78af867 100644 --- a/test/test_translate_song.cxx +++ b/test/test_translate_song.cxx @@ -157,11 +157,8 @@ ToString(const Tag &tag) { std::string result; - if (!tag.duration.IsNegative()) { - char buffer[64]; - sprintf(buffer, "%d", tag.duration.ToMS()); - result.append(buffer); - } + if (!tag.duration.IsNegative()) + result.append(std::to_string(tag.duration.ToMS())); for (const auto &item : tag) { result.push_back('|'); @@ -179,27 +176,18 @@ ToString(const DetachedSong &song) std::string result = song.GetURI(); result.push_back('|'); - char buffer[64]; - - if (!IsNegative(song.GetLastModified())) { - sprintf(buffer, "%lu", - (unsigned long)std::chrono::system_clock::to_time_t(song.GetLastModified())); - result.append(buffer); - } + if (!IsNegative(song.GetLastModified())) + result.append(std::to_string(std::chrono::system_clock::to_time_t(song.GetLastModified()))); result.push_back('|'); - if (song.GetStartTime().IsPositive()) { - sprintf(buffer, "%u", song.GetStartTime().ToMS()); - result.append(buffer); - } + if (song.GetStartTime().IsPositive()) + result.append(std::to_string(song.GetStartTime().ToMS())); result.push_back('-'); - if (song.GetEndTime().IsPositive()) { - sprintf(buffer, "%u", song.GetEndTime().ToMS()); - result.append(buffer); - } + if (song.GetEndTime().IsPositive()) + result.append(std::to_string(song.GetEndTime().ToMS())); result.push_back('|');