From 5f4bcf6b14eb45da408e19295332d2a8486d70df Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Mon, 13 Oct 2014 14:15:19 -0400 Subject: [PATCH] boost: drop boost dependency in version.cpp. Also add a test to verify. --- src/test/util_tests.cpp | 12 ++++++++++++ src/version.cpp | 10 +++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp index 6378bd09418..61daa0a3fe7 100644 --- a/src/test/util_tests.cpp +++ b/src/test/util_tests.cpp @@ -9,6 +9,7 @@ #include "sync.h" #include "utilstrencodings.h" #include "utilmoneystr.h" +#include "version.h" #include #include @@ -341,4 +342,15 @@ BOOST_AUTO_TEST_CASE(test_FormatParagraph) BOOST_CHECK_EQUAL(FormatParagraph("test test", 4, 4), "test\n test"); } +BOOST_AUTO_TEST_CASE(test_FormatSubVersion) +{ + std::vector comments; + comments.push_back(std::string("comment1")); + std::vector comments2; + comments2.push_back(std::string("comment1")); + comments2.push_back(std::string("comment2")); + BOOST_CHECK_EQUAL(FormatSubVersion("Test", 99900, std::vector()),std::string("/Test:0.9.99/")); + BOOST_CHECK_EQUAL(FormatSubVersion("Test", 99900, comments),std::string("/Test:0.9.99(comment1)/")); + BOOST_CHECK_EQUAL(FormatSubVersion("Test", 99900, comments2),std::string("/Test:0.9.99(comment1; comment2)/")); +} BOOST_AUTO_TEST_SUITE_END() diff --git a/src/version.cpp b/src/version.cpp index 95632fdab70..d12b681e5c3 100644 --- a/src/version.cpp +++ b/src/version.cpp @@ -8,8 +8,6 @@ #include -#include - // Name of client reported in the 'version' message. Report the same name // for both bitcoind and bitcoin-qt, to make it harder for attackers to // target servers or GUI users specifically. @@ -94,7 +92,13 @@ std::string FormatSubVersion(const std::string& name, int nClientVersion, const ss << "/"; ss << name << ":" << FormatVersion(nClientVersion); if (!comments.empty()) - ss << "(" << boost::algorithm::join(comments, "; ") << ")"; + { + std::vector::const_iterator it(comments.begin()); + ss << "(" << *it; + for(++it; it != comments.end(); ++it) + ss << "; " << *it; + ss << ")"; + } ss << "/"; return ss.str(); }