forked from drogonframework/drogon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOStringStreamUnitttest.cpp
62 lines (54 loc) · 1.22 KB
/
OStringStreamUnitttest.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <gtest/gtest.h>
#include <drogon/utils/OStringStream.h>
#include <string>
#include <iostream>
TEST(OStringStreamTest, interger)
{
drogon::OStringStream ss;
ss << 12;
ss << 345L;
EXPECT_EQ(ss.str(), "12345");
}
TEST(OStringStreamTest, float_number)
{
drogon::OStringStream ss;
ss << 3.14f;
ss << 3.1416;
EXPECT_EQ(ss.str(), "3.143.1416");
}
TEST(OStringStreamTest, literal_string)
{
drogon::OStringStream ss;
ss << "hello";
ss << " world";
EXPECT_EQ(ss.str(), "hello world");
}
TEST(OStringStreamTest, string_view)
{
drogon::OStringStream ss;
ss << drogon::string_view("hello");
ss << drogon::string_view(" world");
EXPECT_EQ(ss.str(), "hello world");
}
TEST(OStringStreamTest, std_string)
{
drogon::OStringStream ss;
ss << std::string("hello");
ss << std::string(" world");
EXPECT_EQ(ss.str(), "hello world");
}
TEST(OStringStreamTest, mix)
{
drogon::OStringStream ss;
ss << std::string("hello");
ss << drogon::string_view(" world");
ss << "!";
ss << 123;
ss << 3.14f;
EXPECT_EQ(ss.str(), "hello world!1233.14");
}
int main(int argc, char **argv)
{
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}