40 using ::testing::Message;
45 TEST(MessageTest, DefaultConstructor) {
51 TEST(MessageTest, CopyConstructor) {
52 const Message msg1(
"Hello");
53 const Message msg2(msg1);
58 TEST(MessageTest, ConstructsFromCString) {
64 TEST(MessageTest, StreamsFloat) {
65 const std::string s = (Message() << 1.23456F <<
" " << 2.34567F).GetString();
72 TEST(MessageTest, StreamsDouble) {
73 const std::string s = (Message() << 1260570880.4555497 <<
" "
74 << 1260572265.1954534).GetString();
81 TEST(MessageTest, StreamsPointer) {
84 EXPECT_NE(
"(null)", (Message() << p).GetString());
88 TEST(MessageTest, StreamsNullPointer) {
90 EXPECT_EQ(
"(null)", (Message() << p).GetString());
94 TEST(MessageTest, StreamsCString) {
95 EXPECT_EQ(
"Foo", (Message() <<
"Foo").GetString());
99 TEST(MessageTest, StreamsNullCString) {
101 EXPECT_EQ(
"(null)", (Message() << p).GetString());
105 TEST(MessageTest, StreamsString) {
111 TEST(MessageTest, StreamsStringWithEmbeddedNUL) {
112 const char char_array_with_nul[] =
113 "Here's a NUL\0 and some more string";
115 sizeof(char_array_with_nul) - 1);
116 EXPECT_EQ(
"Here's a NUL\\0 and some more string",
117 (Message() << string_with_nul).GetString());
121 TEST(MessageTest, StreamsNULChar) {
122 EXPECT_EQ(
"\\0", (Message() <<
'\0').GetString());
126 TEST(MessageTest, StreamsInt) {
127 EXPECT_EQ(
"123", (Message() << 123).GetString());
132 TEST(MessageTest, StreamsBasicIoManip) {
133 EXPECT_EQ(
"Line 1.\nA NUL char \\0 in line 2.",
134 (Message() <<
"Line 1." << std::endl
136 <<
" in line 2.").GetString());
140 TEST(MessageTest, GetString) {
147 TEST(MessageTest, StreamsToOStream) {
148 Message
msg(
"Hello");
149 ::std::stringstream ss;
155 TEST(MessageTest, DoesNotTakeUpMuchStackSpace) {