summaryrefslogtreecommitdiff
path: root/src/mongo/util/stringutils_test.cpp
diff options
context:
space:
mode:
authorApollon Oikonomopoulos <apoikos@debian.org>2016-01-14 00:10:06 +0200
committerApollon Oikonomopoulos <apollon@skroutz.gr>2016-01-14 00:10:06 +0200
commit374e1947abcd3e127a2a613aff73ecffdb9199ea (patch)
treed83973c3c9802450acd5b5e86fe0d4e8e60a3a1b /src/mongo/util/stringutils_test.cpp
parent65585c90b12d6523bea75a2aebaae2a2fdf9e641 (diff)
Imported Upstream version 2.6.11upstream/2.6.11
Diffstat (limited to 'src/mongo/util/stringutils_test.cpp')
-rw-r--r--src/mongo/util/stringutils_test.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/mongo/util/stringutils_test.cpp b/src/mongo/util/stringutils_test.cpp
index a17a66423f9..10f6f7491b5 100644
--- a/src/mongo/util/stringutils_test.cpp
+++ b/src/mongo/util/stringutils_test.cpp
@@ -19,6 +19,7 @@
#include "mongo/bson/util/misc.h"
#include "mongo/util/stringutils.h"
+#include "mongo/util/hex.h"
namespace mongo {
@@ -170,4 +171,18 @@ namespace mongo {
assertCmp( 0, StringData("0001", 3), StringData("0000", 3), false );
}
+
+ TEST( IntegerToHex, VariousConversions ) {
+ ASSERT_EQUALS(std::string("0"), integerToHex(0));
+ ASSERT_EQUALS(std::string("1"), integerToHex(1));
+ ASSERT_EQUALS(std::string("1337"), integerToHex(0x1337));
+ ASSERT_EQUALS(std::string("FFFFD499"), integerToHex(-11111));
+ ASSERT_EQUALS(std::string("F1FE60C4"), integerToHex(-234987324));
+ ASSERT_EQUALS(std::string("80000000"), integerToHex(std::numeric_limits<int>::min()));
+ ASSERT_EQUALS(std::string("7FFFFFFF"), integerToHex(std::numeric_limits<int>::max()));
+ ASSERT_EQUALS(std::string("7FFFFFFFFFFFFFFF"),
+ integerToHex(std::numeric_limits<long long>::max()));
+ ASSERT_EQUALS(std::string("8000000000000000"),
+ integerToHex(std::numeric_limits<long long>::min()));
+ }
}