34 #include "gtest/gtest-message.h" 36 #include "gtest/gtest.h" 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) {
107 EXPECT_EQ(
"Hello", (Message() << str).GetString());
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
135 <<
"A NUL char " << std::ends << std::flush
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) {
#define EXPECT_LE(val1, val2)
#define EXPECT_PRED_FORMAT2(pred_format, v1, v2)
#define TEST(test_case_name, test_name)
#define EXPECT_EQ(val1, val2)
GTEST_API_ AssertionResult IsSubstring(const char *needle_expr, const char *haystack_expr, const char *needle, const char *haystack)
#define EXPECT_NE(val1, val2)
GTEST_API_ std::string StringStreamToString(::std::stringstream *stream)