-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathteststring_util.cpp
37 lines (34 loc) · 1.25 KB
/
teststring_util.cpp
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
30
31
32
33
34
35
36
37
#include <gtest/gtest.h>
#include <stdint.h>
#include "string_util.hpp"
TEST(string_util, Zero)
{
EXPECT_EQ(toStr(static_cast<int8_t>(0.)), "0");
EXPECT_EQ(toStr(static_cast<uint8_t>(0.)), "0");
EXPECT_EQ(toStr(static_cast<int16_t>(0.)), "0");
EXPECT_EQ(toStr(static_cast<uint16_t>(0.)), "0");
EXPECT_EQ(toStr(static_cast<int32_t>(0.)), "0");
EXPECT_EQ(toStr(static_cast<uint32_t>(0.)), "0");
EXPECT_EQ(toStr(static_cast<int64_t>(0.)), "0");
EXPECT_EQ(toStr(static_cast<uint64_t>(0.)), "0");
EXPECT_EQ(toStr(static_cast<float>(0.)), "0");
EXPECT_EQ(toStr(static_cast<double>(0.)), "0");
}
TEST(string_util, One)
{
EXPECT_EQ(toStr(static_cast<int8_t>(1.)), "1");
EXPECT_EQ(toStr(static_cast<uint8_t>(1.)), "1");
EXPECT_EQ(toStr(static_cast<int16_t>(1.)), "1");
EXPECT_EQ(toStr(static_cast<uint16_t>(1.)), "1");
EXPECT_EQ(toStr(static_cast<int32_t>(1.)), "1");
EXPECT_EQ(toStr(static_cast<uint32_t>(1.)), "1");
EXPECT_EQ(toStr(static_cast<int64_t>(1.)), "1");
EXPECT_EQ(toStr(static_cast<uint64_t>(1.)), "1");
EXPECT_EQ(toStr(static_cast<float>(1.)), "1");
EXPECT_EQ(toStr(static_cast<double>(1.)), "1");
}
TEST(string_util, Point_Five)
{
EXPECT_EQ(toStr(static_cast<float>(.5)), "0.5");
EXPECT_EQ(toStr(static_cast<double>(.5)), "0.5");
}