summaryrefslogtreecommitdiff
path: root/src/utils/stringutils_unittest.cc
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-06-05 02:20:12 +0300
committerAndrei Karas <akaras@inbox.ru>2015-06-05 02:20:12 +0300
commit54fd7526e6a1d2d161fda10bccd609ec078b8fa9 (patch)
treeb2ef7a31891a0351f1053f6804a8abe4ff1ea895 /src/utils/stringutils_unittest.cc
parentbc4957b24e6939f4e681e9412f9bbdd483a6bc35 (diff)
downloadplus-54fd7526e6a1d2d161fda10bccd609ec078b8fa9.tar.gz
plus-54fd7526e6a1d2d161fda10bccd609ec078b8fa9.tar.bz2
plus-54fd7526e6a1d2d161fda10bccd609ec078b8fa9.tar.xz
plus-54fd7526e6a1d2d161fda10bccd609ec078b8fa9.zip
Add fast versions for function toString for different types.
Diffstat (limited to 'src/utils/stringutils_unittest.cc')
-rw-r--r--src/utils/stringutils_unittest.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/utils/stringutils_unittest.cc b/src/utils/stringutils_unittest.cc
index f984167a6..4dca829d7 100644
--- a/src/utils/stringutils_unittest.cc
+++ b/src/utils/stringutils_unittest.cc
@@ -117,6 +117,26 @@ TEST_CASE("stringuntils ipToString 1")
REQUIRE("219.255.210.73" == std::string(ipToString(1238564827)));
}
+TEST_CASE("stringuntils toString 1")
+{
+ REQUIRE(strprintf("%d", 0) == toString(0));
+ REQUIRE(strprintf("%d", -1) == toString(-1));
+ REQUIRE(strprintf("%d", 30000000) == toString(30000000));
+ REQUIRE(strprintf("%d", -10000000) == toString(-10000000));
+ REQUIRE(strprintf("%d", 30000000) == toString(
+ static_cast<signed int>(30000000)));
+ REQUIRE(strprintf("%d", 3000) == toString(static_cast<uint16_t>(3000)));
+ REQUIRE(strprintf("%d", 123) == toString(static_cast<unsigned char>(123)));
+}
+
+TEST_CASE("stringuntils toString 2")
+{
+ for (int f = 0; f < 10000000; f += 123)
+ {
+ REQUIRE(strprintf("%d", f) == toString(f));
+ }
+}
+
TEST_CASE("stringuntils removeColors 1")
{
REQUIRE("" == removeColors(""));