From 2bd59adc7c456ce6f377feac8bc838e8011ebfc8 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 5 Jun 2015 21:49:04 +0300 Subject: Fix code style. --- src/utils/files_unittest.cc | 2 +- src/utils/stringutils.cpp | 15 ++++++++------- src/utils/stringutils.h | 5 ++--- src/utils/stringutils_unittest.cc | 6 +++--- 4 files changed, 14 insertions(+), 14 deletions(-) (limited to 'src/utils') diff --git a/src/utils/files_unittest.cc b/src/utils/files_unittest.cc index 4adfea8c9..5d227834e 100644 --- a/src/utils/files_unittest.cc +++ b/src/utils/files_unittest.cc @@ -34,7 +34,7 @@ TEST_CASE("Files renameFile", "files") PHYSFS_init("manaplus"); dirSeparator = "/"; logger = new Logger(); - ResourceManager *resman = ResourceManager::getInstance(); + const ResourceManager *const resman = ResourceManager::getInstance(); resman->addToSearchPath("data", false); resman->addToSearchPath("../data", false); diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index c53d33884..7ad144331 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -23,6 +23,7 @@ #include "utils/stringutils.h" #include +#include #ifdef WIN32 #include @@ -716,7 +717,7 @@ std::string toString(unsigned int num) size_t idx = 28; do buf[idx--] = static_cast((num % 10) + '0'); - while(num /= 10); + while (num /= 10); return buf + idx + 1; } @@ -727,7 +728,7 @@ std::string toString(unsigned long num) size_t idx = 98; do buf[idx--] = static_cast((num % 10) + '0'); - while(num /= 10); + while (num /= 10); return buf + idx + 1; } @@ -738,7 +739,7 @@ std::string toString(uint16_t num) size_t idx = 8; do buf[idx--] = static_cast((num % 10) + '0'); - while(num /= 10); + while (num /= 10); return buf + idx + 1; } @@ -749,7 +750,7 @@ std::string toString(unsigned char num) size_t idx = 3; do buf[idx--] = static_cast((num % 10) + '0'); - while(num /= 10); + while (num /= 10); return buf + idx + 1; } @@ -767,18 +768,18 @@ std::string toString(int num) } do buf[idx--] = static_cast((num % 10) + '0'); - while(num /= 10); + while (num /= 10); if (useSign) buf[idx--] = '-'; return buf + idx + 1; } -std::string toString(float num) +std::string toString(const float num) { return strprintf("%f", num); } -std::string toString(double num) +std::string toString(const double num) { return strprintf("%f", static_cast(num)); } diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h index 738b56cb8..3307d6e73 100644 --- a/src/utils/stringutils.h +++ b/src/utils/stringutils.h @@ -25,7 +25,6 @@ #include "utils/stringvector.h" -#include #include #include @@ -80,9 +79,9 @@ std::string toString(int num); std::string toString(uint16_t num); -std::string toString(float num); +std::string toString(const float num); -std::string toString(double num); +std::string toString(const double num); std::string toStringPrint(const unsigned int val); diff --git a/src/utils/stringutils_unittest.cc b/src/utils/stringutils_unittest.cc index 4dca829d7..a2c30bb76 100644 --- a/src/utils/stringutils_unittest.cc +++ b/src/utils/stringutils_unittest.cc @@ -102,13 +102,13 @@ TEST_CASE("stringuntils atox 1") atox(str); str = ""; - int k = atox(str); + REQUIRE(0 == atox(str)); str = "0"; - k = atox(str); + REQUIRE(0 == atox(str)); str = "0x"; - k = atox(str); + REQUIRE(0 == atox(str)); } TEST_CASE("stringuntils ipToString 1") -- cgit v1.2.3-70-g09d2