From 54fd7526e6a1d2d161fda10bccd609ec078b8fa9 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 5 Jun 2015 02:20:12 +0300 Subject: Add fast versions for function toString for different types. --- src/utils/stringutils_unittest.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/utils/stringutils_unittest.cc') 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(30000000))); + REQUIRE(strprintf("%d", 3000) == toString(static_cast(3000))); + REQUIRE(strprintf("%d", 123) == toString(static_cast(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("")); -- cgit v1.2.3-70-g09d2