[core] add the ability to stringy numbers as hex

This commit is contained in:
Konstantin Käfer
2018-10-17 15:56:55 +02:00
parent 43687b4781
commit eb828dfd29
3 changed files with 32 additions and 0 deletions

View File

@@ -2,6 +2,8 @@
#include <mbgl/util/string.hpp>
#include <cstdint>
using namespace mbgl;
TEST(ToString, FloatingPoint) {
@@ -16,3 +18,12 @@ TEST(ToString, FloatingPoint) {
EXPECT_EQ("12340000000", util::toString(12340000000.0));
EXPECT_EQ("12340000000.0", util::toString(12340000000.0, true));
}
TEST(ToHex, SIZE_T) {
#if INTPTR_MAX == INT32_MAX
EXPECT_EQ("a715b247", util::toHex((size_t)0xa715b247));
#elif INTPTR_MAX == INT64_MAX
EXPECT_EQ("a715b247df38cc29", util::toHex((size_t)0xa715b247df38cc29));
#endif
}