40using ::testing::Message;
45TEST(MessageTest, DefaultConstructor) {
51TEST(MessageTest, CopyConstructor) {
52 const Message msg1(
"Hello");
53 const Message msg2(msg1);
58TEST(MessageTest, ConstructsFromCString) {
64TEST(MessageTest, StreamsFloat) {
65 const std::string
s = (Message() << 1.23456F <<
" " << 2.34567F).GetString();
72TEST(MessageTest, StreamsDouble) {
73 const std::string
s = (Message() << 1260570880.4555497 <<
" "
74 << 1260572265.1954534).GetString();
81TEST(MessageTest, StreamsPointer) {
84 EXPECT_NE(
"(null)", (Message() <<
p).GetString());
88TEST(MessageTest, StreamsNullPointer) {
90 EXPECT_EQ(
"(null)", (Message() <<
p).GetString());
94TEST(MessageTest, StreamsCString) {
95 EXPECT_EQ(
"Foo", (Message() <<
"Foo").GetString());
99TEST(MessageTest, StreamsNullCString) {
101 EXPECT_EQ(
"(null)", (Message() <<
p).GetString());
105TEST(MessageTest, StreamsString) {
106 const ::std::string
str(
"Hello");
107 EXPECT_EQ(
"Hello", (Message() << str).GetString());
111TEST(MessageTest, StreamsStringWithEmbeddedNUL) {
112 const char char_array_with_nul[] =
113 "Here's a NUL\0 and some more string";
114 const ::std::string string_with_nul(char_array_with_nul,
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());
121TEST(MessageTest, StreamsNULChar) {
122 EXPECT_EQ(
"\\0", (Message() <<
'\0').GetString());
126TEST(MessageTest, StreamsInt) {
127 EXPECT_EQ(
"123", (Message() << 123).GetString());
132TEST(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());
140TEST(MessageTest, GetString) {
147TEST(MessageTest, StreamsToOStream) {
148 Message msg(
"Hello");
149 ::std::stringstream
ss;
155TEST(MessageTest, DoesNotTakeUpMuchStackSpace) {
#define EXPECT_EQ(val1, val2)
#define EXPECT_NE(val1, val2)
#define TEST(test_case_name, test_name)
#define EXPECT_LE(val1, val2)
#define EXPECT_PRED_FORMAT2(pred_format, v1, v2)
static const Segment ss(Segment::ss)
GTEST_API_ std::string StringStreamToString(::std::stringstream *stream)
GTEST_API_ AssertionResult IsSubstring(const char *needle_expr, const char *haystack_expr, const char *needle, const char *haystack)