summaryrefslogtreecommitdiff
path: root/test/util/string.test.cpp
blob: f694702e697b917bd85333a77ae050a7a8a427d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <mbgl/test/util.hpp>

#include <mbgl/util/string.hpp>

#include <cstdint>

using namespace mbgl;

TEST(ToString, FloatingPoint) {
    EXPECT_EQ("0", util::toString(0.0));
    EXPECT_EQ("0.0", util::toString(0.0, true));
    EXPECT_EQ("1.33", util::toString(1.33));
    EXPECT_EQ("1.33", util::toString(1.33, true));
    EXPECT_EQ("-1", util::toString(-1.0));
    EXPECT_EQ("-1.0", util::toString(-1.0, true));
    EXPECT_EQ("12340000000", util::toString(12340000000.0));
    EXPECT_EQ("12340000000.0", util::toString(12340000000.0, true));
    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((uint32_t)0xa715b247));
#elif INTPTR_MAX == INT64_MAX
    EXPECT_EQ("a715b247df38cc29", util::toHex((uint64_t)0xa715b247df38cc29));
#endif

}