summaryrefslogtreecommitdiff
path: root/absl/log/log_format_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'absl/log/log_format_test.cc')
-rw-r--r--absl/log/log_format_test.cc680
1 files changed, 331 insertions, 349 deletions
diff --git a/absl/log/log_format_test.cc b/absl/log/log_format_test.cc
index dbad5d97..beee966d 100644
--- a/absl/log/log_format_test.cc
+++ b/absl/log/log_format_test.cc
@@ -78,7 +78,7 @@ TEST(LogFormatTest, NoMessage) {
TextPrefix(AsString(EndsWith(absl::StrCat(
" log_format_test.cc:", log_line, "] ")))),
TextMessage(IsEmpty()),
- ENCODED_MESSAGE(EqualsProto(R"pb()pb")))));
+ ENCODED_MESSAGE(HasValues(IsEmpty())))));
test_sink.StartCapturingLogs();
do_log();
@@ -96,11 +96,11 @@ TYPED_TEST(CharLogFormatTest, Printable) {
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("x")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value { str: "x" })pb")))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("x")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "x")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -113,12 +113,11 @@ TYPED_TEST(CharLogFormatTest, Unprintable) {
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink, Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("\xee")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value {
- str: "\xee"
- })pb")))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("\xee")),
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "\xee")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -137,11 +136,11 @@ TYPED_TEST(UnsignedIntLogFormatTest, Positive) {
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("224")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value { str: "224" })pb")))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("224")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "224")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -156,11 +155,11 @@ TYPED_TEST(UnsignedIntLogFormatTest, BitfieldPositive) {
auto comparison_stream = ComparisonStream();
comparison_stream << value.bits;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("42")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value { str: "42" })pb")))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("42")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "42")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value.bits;
@@ -179,11 +178,11 @@ TYPED_TEST(SignedIntLogFormatTest, Positive) {
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("224")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value { str: "224" })pb")))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("224")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "224")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -196,12 +195,11 @@ TYPED_TEST(SignedIntLogFormatTest, Negative) {
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink, Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("-112")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value {
- str: "-112"
- })pb")))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("-112")),
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "-112")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -216,11 +214,11 @@ TYPED_TEST(SignedIntLogFormatTest, BitfieldPositive) {
auto comparison_stream = ComparisonStream();
comparison_stream << value.bits;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("21")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value { str: "21" })pb")))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("21")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "21")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value.bits;
@@ -235,11 +233,11 @@ TYPED_TEST(SignedIntLogFormatTest, BitfieldNegative) {
auto comparison_stream = ComparisonStream();
comparison_stream << value.bits;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("-21")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value { str: "-21" })pb")))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("-21")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "-21")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value.bits;
@@ -276,11 +274,11 @@ TYPED_TEST(UnsignedEnumLogFormatTest, Positive) {
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("224")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value { str: "224" })pb")))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("224")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "224")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -295,11 +293,11 @@ TYPED_TEST(UnsignedEnumLogFormatTest, BitfieldPositive) {
auto comparison_stream = ComparisonStream();
comparison_stream << value.bits;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("42")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value { str: "42" })pb")))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("42")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "42")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value.bits;
@@ -335,11 +333,11 @@ TYPED_TEST(SignedEnumLogFormatTest, Positive) {
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("224")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value { str: "224" })pb")))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("224")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "224")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -352,12 +350,11 @@ TYPED_TEST(SignedEnumLogFormatTest, Negative) {
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink, Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("-112")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value {
- str: "-112"
- })pb")))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("-112")),
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "-112")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -372,11 +369,11 @@ TYPED_TEST(SignedEnumLogFormatTest, BitfieldPositive) {
auto comparison_stream = ComparisonStream();
comparison_stream << value.bits;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("21")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value { str: "21" })pb")))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("21")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "21")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value.bits;
@@ -391,11 +388,11 @@ TYPED_TEST(SignedEnumLogFormatTest, BitfieldNegative) {
auto comparison_stream = ComparisonStream();
comparison_stream << value.bits;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("-21")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value { str: "-21" })pb")))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("-21")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "-21")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value.bits;
@@ -412,9 +409,8 @@ TEST(FloatLogFormatTest, Positive) {
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq("6.02e+23")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value {
- str: "6.02e+23"
- })pb")))));
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "6.02e+23")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -430,9 +426,8 @@ TEST(FloatLogFormatTest, Negative) {
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq("-6.02e+23")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value {
- str: "-6.02e+23"
- })pb")))));
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "-6.02e+23")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -448,9 +443,8 @@ TEST(FloatLogFormatTest, NegativeExponent) {
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq("6.02e-23")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value {
- str: "6.02e-23"
- })pb")))));
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "6.02e-23")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -466,9 +460,8 @@ TEST(DoubleLogFormatTest, Positive) {
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq("6.02e+23")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value {
- str: "6.02e+23"
- })pb")))));
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "6.02e+23")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -484,9 +477,8 @@ TEST(DoubleLogFormatTest, Negative) {
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq("-6.02e+23")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value {
- str: "-6.02e+23"
- })pb")))));
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "-6.02e+23")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -502,9 +494,8 @@ TEST(DoubleLogFormatTest, NegativeExponent) {
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq("6.02e-23")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value {
- str: "6.02e-23"
- })pb")))));
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "6.02e-23")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -522,11 +513,11 @@ TYPED_TEST(FloatingPointLogFormatTest, Zero) {
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("0")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value { str: "0" })pb")))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("0")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "0")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -539,11 +530,11 @@ TYPED_TEST(FloatingPointLogFormatTest, Integer) {
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("1")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value { str: "1" })pb")))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("1")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "1")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -556,11 +547,11 @@ TYPED_TEST(FloatingPointLogFormatTest, Infinity) {
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(AnyOf(Eq("inf"), Eq("Inf"))),
- ENCODED_MESSAGE(EqualsProto(R"pb(value { str: "inf" })pb")))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(AnyOf(Eq("inf"), Eq("Inf"))),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "inf")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -573,12 +564,11 @@ TYPED_TEST(FloatingPointLogFormatTest, NegativeInfinity) {
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink, Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(AnyOf(Eq("-inf"), Eq("-Inf"))),
- ENCODED_MESSAGE(EqualsProto(R"pb(value {
- str: "-inf"
- })pb")))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(AnyOf(Eq("-inf"), Eq("-Inf"))),
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "-inf")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -591,11 +581,11 @@ TYPED_TEST(FloatingPointLogFormatTest, NaN) {
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(AnyOf(Eq("nan"), Eq("NaN"))),
- ENCODED_MESSAGE(EqualsProto(R"pb(value { str: "nan" })pb")))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(AnyOf(Eq("nan"), Eq("NaN"))),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "nan")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
}
@@ -608,15 +598,29 @@ TYPED_TEST(FloatingPointLogFormatTest, NegativeNaN) {
auto comparison_stream = ComparisonStream();
comparison_stream << value;
+ // On RISC-V, don't expect that formatting -NaN produces the same string as
+ // streaming it. #ifdefing out just the relevant line breaks the MSVC build,
+ // so duplicate the entire EXPECT_CALL.
+#ifdef __riscv
+ EXPECT_CALL(
+ test_sink,
+ Send(AllOf(
+ TextMessage(AnyOf(Eq("-nan"), Eq("nan"), Eq("NaN"), Eq("-nan(ind)"))),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(AnyOf(EqualsProto(R"pb(str: "-nan")pb"),
+ EqualsProto(R"pb(str: "nan")pb"),
+ EqualsProto(R"pb(str: "-nan(ind)")pb"))))))));
+#else
EXPECT_CALL(
test_sink,
Send(AllOf(
TextMessage(MatchesOstream(comparison_stream)),
TextMessage(AnyOf(Eq("-nan"), Eq("nan"), Eq("NaN"), Eq("-nan(ind)"))),
- ENCODED_MESSAGE(
- AnyOf(EqualsProto(R"pb(value { str: "-nan" })pb"),
- EqualsProto(R"pb(value { str: "nan" })pb"),
- EqualsProto(R"pb(value { str: "-nan(ind)" })pb"))))));
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(AnyOf(EqualsProto(R"pb(str: "-nan")pb"),
+ EqualsProto(R"pb(str: "nan")pb"),
+ EqualsProto(R"pb(str: "-nan(ind)")pb"))))))));
+#endif
test_sink.StartCapturingLogs();
LOG(INFO) << value;
}
@@ -652,13 +656,12 @@ TYPED_TEST(VoidPtrLogFormatTest, NonNull) {
EXPECT_CALL(
test_sink,
- Send(AllOf(
- TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(
- AnyOf(Eq("0xdeadbeef"), Eq("DEADBEEF"), Eq("00000000DEADBEEF"))),
- ENCODED_MESSAGE(AnyOf(
- EqualsProto(R"pb(value { str: "0xdeadbeef" })pb"),
- EqualsProto(R"pb(value { str: "00000000DEADBEEF" })pb"))))));
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(AnyOf(Eq("0xdeadbeef"), Eq("DEADBEEF"),
+ Eq("00000000DEADBEEF"))),
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ AnyOf(EqualsProto(R"pb(str: "0xdeadbeef")pb"),
+ EqualsProto(R"pb(str: "00000000DEADBEEF")pb"))))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -680,12 +683,11 @@ TYPED_TEST(VolatilePtrLogFormatTest, Null) {
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink, Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("false")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value {
- str: "false"
- })pb")))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("false")),
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "false")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -698,12 +700,11 @@ TYPED_TEST(VolatilePtrLogFormatTest, NonNull) {
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink, Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("true")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value {
- str: "true"
- })pb")))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("true")),
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "true")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -729,7 +730,8 @@ TYPED_TEST(CharPtrLogFormatTest, Null) {
Send(AllOf(
// `MatchesOstream` deliberately omitted since we deliberately differ.
TextMessage(Eq("(null)")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value { str: "(null)" })pb")))));
+ ENCODED_MESSAGE(
+ HasValues(ElementsAre(EqualsProto(R"pb(str: "(null)")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -743,12 +745,11 @@ TYPED_TEST(CharPtrLogFormatTest, NonNull) {
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink, Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("value")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value {
- str: "value"
- })pb")))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("value")),
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "value")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -761,12 +762,11 @@ TEST(BoolLogFormatTest, True) {
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink, Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("true")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value {
- str: "true"
- })pb")))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("true")),
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "true")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -779,12 +779,11 @@ TEST(BoolLogFormatTest, False) {
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink, Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("false")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value {
- str: "false"
- })pb")))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("false")),
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "false")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -799,9 +798,8 @@ TEST(LogFormatTest, StringLiteral) {
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq("value")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value {
- literal: "value"
- })pb")))));
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(literal: "value")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << "value";
@@ -814,12 +812,11 @@ TEST(LogFormatTest, CharArray) {
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink, Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("value")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value {
- str: "value"
- })pb")))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("value")),
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "value")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -840,9 +837,8 @@ TEST(LogFormatTest, Custom) {
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq("CustomClass{}")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value {
- str: "CustomClass{}"
- })pb")))));
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "CustomClass{}")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
}
@@ -864,12 +860,11 @@ TEST(LogFormatTest, CustomNonCopyable) {
auto comparison_stream = ComparisonStream();
comparison_stream << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("CustomClassNonCopyable{}")),
- ENCODED_MESSAGE(EqualsProto(
- R"pb(value { str: "CustomClassNonCopyable{}" })pb")))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("CustomClassNonCopyable{}")),
+ ENCODED_MESSAGE(HasValues(ElementsAre(EqualsProto(
+ R"pb(str: "CustomClassNonCopyable{}")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value;
@@ -892,9 +887,9 @@ TEST(LogFormatTest, AbslStringifyExample) {
EXPECT_CALL(
test_sink,
- Send(AllOf(
- TextMessage(Eq("(10, 20)")), TextMessage(Eq(absl::StrCat(p))),
- ENCODED_MESSAGE(EqualsProto(R"pb(value { str: "(10, 20)" })pb")))));
+ Send(AllOf(TextMessage(Eq("(10, 20)")), TextMessage(Eq(absl::StrCat(p))),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "(10, 20)")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << p;
@@ -923,9 +918,9 @@ TEST(LogFormatTest, CustomWithAbslStringifyAndOstream) {
EXPECT_CALL(
test_sink,
- Send(AllOf(
- TextMessage(Eq("(10, 20)")), TextMessage(Eq(absl::StrCat(p))),
- ENCODED_MESSAGE(EqualsProto(R"pb(value { str: "(10, 20)" })pb")))));
+ Send(AllOf(TextMessage(Eq("(10, 20)")), TextMessage(Eq(absl::StrCat(p))),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "(10, 20)")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << p;
@@ -944,10 +939,10 @@ TEST(LogFormatTest, AbslStringifyStreamsNothing) {
PointStreamsNothing p;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(TextMessage(Eq("77")), TextMessage(Eq(absl::StrCat(p, 77))),
- ENCODED_MESSAGE(EqualsProto(R"pb(value { str: "77" })pb")))));
+ EXPECT_CALL(test_sink, Send(AllOf(TextMessage(Eq("77")),
+ TextMessage(Eq(absl::StrCat(p, 77))),
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "77")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << p << 77;
@@ -971,10 +966,10 @@ TEST(LogFormatTest, AbslStringifyMultipleAppend) {
EXPECT_CALL(
test_sink,
- Send(AllOf(
- TextMessage(Eq("(10, 20)")), TextMessage(Eq(absl::StrCat(p))),
- ENCODED_MESSAGE(EqualsProto(R"pb(value { str: "(" }
- value { str: "10, 20)" })pb")))));
+ Send(AllOf(TextMessage(Eq("(10, 20)")), TextMessage(Eq(absl::StrCat(p))),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "(")pb"),
+ EqualsProto(R"pb(str: "10, 20)")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << p;
@@ -992,12 +987,12 @@ TEST(ManipulatorLogFormatTest, BoolAlphaTrue) {
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq("1 true 1")),
- ENCODED_MESSAGE(EqualsProto(
- R"pb(value { str: "1" }
- value { literal: " " }
- value { str: "true" }
- value { literal: " " }
- value { str: "1" })pb")))));
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "1")pb"),
+ EqualsProto(R"pb(literal: " ")pb"),
+ EqualsProto(R"pb(str: "true")pb"),
+ EqualsProto(R"pb(literal: " ")pb"),
+ EqualsProto(R"pb(str: "1")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::noboolalpha << value << " " //
@@ -1017,12 +1012,12 @@ TEST(ManipulatorLogFormatTest, BoolAlphaFalse) {
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq("0 false 0")),
- ENCODED_MESSAGE(EqualsProto(
- R"pb(value { str: "0" }
- value { literal: " " }
- value { str: "false" }
- value { literal: " " }
- value { str: "0" })pb")))));
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "0")pb"),
+ EqualsProto(R"pb(literal: " ")pb"),
+ EqualsProto(R"pb(str: "false")pb"),
+ EqualsProto(R"pb(literal: " ")pb"),
+ EqualsProto(R"pb(str: "0")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::noboolalpha << value << " " //
@@ -1039,15 +1034,15 @@ TEST(ManipulatorLogFormatTest, ShowPoint) {
<< std::showpoint << value << " " //
<< std::noshowpoint << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("77 77.0000 77")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value { str: "77" }
- value { literal: " " }
- value { str: "77.0000" }
- value { literal: " " }
- value { str: "77" })pb")))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("77 77.0000 77")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "77")pb"),
+ EqualsProto(R"pb(literal: " ")pb"),
+ EqualsProto(R"pb(str: "77.0000")pb"),
+ EqualsProto(R"pb(literal: " ")pb"),
+ EqualsProto(R"pb(str: "77")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::noshowpoint << value << " " //
@@ -1064,15 +1059,15 @@ TEST(ManipulatorLogFormatTest, ShowPos) {
<< std::showpos << value << " " //
<< std::noshowpos << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("77 +77 77")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value { str: "77" }
- value { literal: " " }
- value { str: "+77" }
- value { literal: " " }
- value { str: "77" })pb")))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("77 +77 77")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "77")pb"),
+ EqualsProto(R"pb(literal: " ")pb"),
+ EqualsProto(R"pb(str: "+77")pb"),
+ EqualsProto(R"pb(literal: " ")pb"),
+ EqualsProto(R"pb(str: "77")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::noshowpos << value << " " //
@@ -1092,12 +1087,12 @@ TEST(ManipulatorLogFormatTest, UppercaseFloat) {
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq("7.7e+07 7.7E+07 7.7e+07")),
- ENCODED_MESSAGE(EqualsProto(
- R"pb(value { str: "7.7e+07" }
- value { literal: " " }
- value { str: "7.7E+07" }
- value { literal: " " }
- value { str: "7.7e+07" })pb")))));
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "7.7e+07")pb"),
+ EqualsProto(R"pb(literal: " ")pb"),
+ EqualsProto(R"pb(str: "7.7E+07")pb"),
+ EqualsProto(R"pb(literal: " ")pb"),
+ EqualsProto(R"pb(str: "7.7e+07")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::nouppercase << value << " " //
@@ -1112,12 +1107,11 @@ TEST(ManipulatorLogFormatTest, Hex) {
auto comparison_stream = ComparisonStream();
comparison_stream << std::hex << value;
- EXPECT_CALL(
- test_sink, Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("0x77")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value {
- str: "0x77"
- })pb")))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("0x77")),
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "0x77")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::hex << value;
}
@@ -1129,11 +1123,11 @@ TEST(ManipulatorLogFormatTest, Oct) {
auto comparison_stream = ComparisonStream();
comparison_stream << std::oct << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("077")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value { str: "077" })pb")))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("077")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "077")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::oct << value;
@@ -1146,11 +1140,11 @@ TEST(ManipulatorLogFormatTest, Dec) {
auto comparison_stream = ComparisonStream();
comparison_stream << std::hex << std::dec << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("77")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value { str: "77" })pb")))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("77")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "77")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::hex << std::dec << value;
@@ -1166,15 +1160,15 @@ TEST(ManipulatorLogFormatTest, ShowbaseHex) {
<< std::showbase << value << " " //
<< std::noshowbase << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("77 0x77 77")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value { str: "77" }
- value { literal: " " }
- value { str: "0x77" }
- value { literal: " " }
- value { str: "77" })pb")))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("77 0x77 77")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "77")pb"),
+ EqualsProto(R"pb(literal: " ")pb"),
+ EqualsProto(R"pb(str: "0x77")pb"),
+ EqualsProto(R"pb(literal: " ")pb"),
+ EqualsProto(R"pb(str: "77")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::hex //
@@ -1193,15 +1187,15 @@ TEST(ManipulatorLogFormatTest, ShowbaseOct) {
<< std::showbase << value << " " //
<< std::noshowbase << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("77 077 77")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value { str: "77" }
- value { literal: " " }
- value { str: "077" }
- value { literal: " " }
- value { str: "77" })pb")))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("77 077 77")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "77")pb"),
+ EqualsProto(R"pb(literal: " ")pb"),
+ EqualsProto(R"pb(str: "077")pb"),
+ EqualsProto(R"pb(literal: " ")pb"),
+ EqualsProto(R"pb(str: "77")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::oct //
@@ -1224,12 +1218,12 @@ TEST(ManipulatorLogFormatTest, UppercaseHex) {
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq("0xbeef 0XBEEF 0xbeef")),
- ENCODED_MESSAGE(EqualsProto(
- R"pb(value { str: "0xbeef" }
- value { literal: " " }
- value { str: "0XBEEF" }
- value { literal: " " }
- value { str: "0xbeef" })pb")))));
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "0xbeef")pb"),
+ EqualsProto(R"pb(literal: " ")pb"),
+ EqualsProto(R"pb(str: "0XBEEF")pb"),
+ EqualsProto(R"pb(literal: " ")pb"),
+ EqualsProto(R"pb(str: "0xbeef")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::hex //
@@ -1245,13 +1239,11 @@ TEST(ManipulatorLogFormatTest, FixedFloat) {
auto comparison_stream = ComparisonStream();
comparison_stream << std::fixed << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("77000000.000000")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value {
- str: "77000000.000000"
- })pb")))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("77000000.000000")),
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "77000000.000000")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::fixed << value;
@@ -1267,9 +1259,8 @@ TEST(ManipulatorLogFormatTest, ScientificFloat) {
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq("7.700000e+07")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value {
- str: "7.700000e+07"
- })pb")))));
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "7.700000e+07")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::scientific << value;
@@ -1295,11 +1286,9 @@ TEST(ManipulatorLogFormatTest, FixedAndScientificFloat) {
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(AnyOf(Eq("0x1.25bb50p+26"), Eq("0x1.25bb5p+26"),
Eq("0x1.25bb500000000p+26"))),
- ENCODED_MESSAGE(
- AnyOf(EqualsProto(R"pb(value { str: "0x1.25bb5p+26" })pb"),
- EqualsProto(R"pb(value {
- str: "0x1.25bb500000000p+26"
- })pb"))))));
+ ENCODED_MESSAGE(HasValues(ElementsAre(AnyOf(
+ EqualsProto(R"pb(str: "0x1.25bb5p+26")pb"),
+ EqualsProto(R"pb(str: "0x1.25bb500000000p+26")pb"))))))));
test_sink.StartCapturingLogs();
@@ -1328,11 +1317,9 @@ TEST(ManipulatorLogFormatTest, HexfloatFloat) {
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(AnyOf(Eq("0x1.25bb50p+26"), Eq("0x1.25bb5p+26"),
Eq("0x1.25bb500000000p+26"))),
- ENCODED_MESSAGE(
- AnyOf(EqualsProto(R"pb(value { str: "0x1.25bb5p+26" })pb"),
- EqualsProto(R"pb(value {
- str: "0x1.25bb500000000p+26"
- })pb"))))));
+ ENCODED_MESSAGE(HasValues(ElementsAre(AnyOf(
+ EqualsProto(R"pb(str: "0x1.25bb5p+26")pb"),
+ EqualsProto(R"pb(str: "0x1.25bb500000000p+26")pb"))))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::hexfloat << value;
@@ -1349,9 +1336,8 @@ TEST(ManipulatorLogFormatTest, DefaultFloatFloat) {
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq("7.7e+07")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value {
- str: "7.7e+07"
- })pb")))));
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "7.7e+07")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::hexfloat << std::defaultfloat << value;
@@ -1363,11 +1349,11 @@ TEST(ManipulatorLogFormatTest, Ends) {
auto comparison_stream = ComparisonStream();
comparison_stream << std::ends;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq(absl::string_view("\0", 1))),
- ENCODED_MESSAGE(EqualsProto(R"pb(value { str: "\0" })pb")))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq(absl::string_view("\0", 1))),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "\0")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::ends;
@@ -1384,7 +1370,8 @@ TEST(ManipulatorLogFormatTest, Endl) {
Send(AllOf(
TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq("\n")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value { str: "\n" })pb")))));
+ ENCODED_MESSAGE(HasValues(ElementsAre(EqualsProto(R"pb(str:
+ "\n")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::endl;
@@ -1408,10 +1395,10 @@ TEST(ManipulatorLogFormatTest, SetIosFlags) {
// `std::setiosflags` and `std::resetiosflags` aren't manipulators.
// We're unable to distinguish their return type(s) from arbitrary
// user-defined types and thus don't suppress the empty str value.
- ENCODED_MESSAGE(EqualsProto(R"pb(value { str: "0x77" }
- value { literal: " " }
- value { str: "119" }
- )pb")))));
+ ENCODED_MESSAGE(
+ HasValues(ElementsAre(EqualsProto(R"pb(str: "0x77")pb"),
+ EqualsProto(R"pb(literal: " ")pb"),
+ EqualsProto(R"pb(str: "119")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::resetiosflags(std::ios_base::basefield)
@@ -1435,10 +1422,10 @@ TEST(ManipulatorLogFormatTest, SetBase) {
// `std::setbase` isn't a manipulator. We're unable to
// distinguish its return type from arbitrary user-defined
// types and thus don't suppress the empty str value.
- ENCODED_MESSAGE(EqualsProto(
- R"pb(value { str: "0x77" }
- value { literal: " " }
- value { str: "119" })pb")))));
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "0x77")pb"),
+ EqualsProto(R"pb(literal: " ")pb"),
+ EqualsProto(R"pb(str: "119")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::setbase(16) << value << " " //
@@ -1454,13 +1441,13 @@ TEST(ManipulatorLogFormatTest, SetPrecision) {
EXPECT_CALL(
test_sink,
- Send(AllOf(
- TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("6.022e+23")),
- // `std::setprecision` isn't a manipulator. We're unable to
- // distinguish its return type from arbitrary user-defined
- // types and thus don't suppress the empty str value.
- ENCODED_MESSAGE(EqualsProto(R"pb(value { str: "6.022e+23" })pb")))));
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("6.022e+23")),
+ // `std::setprecision` isn't a manipulator. We're unable to
+ // distinguish its return type from arbitrary user-defined
+ // types and thus don't suppress the empty str value.
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "6.022e+23")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::setprecision(4) << value;
@@ -1473,12 +1460,11 @@ TEST(ManipulatorLogFormatTest, SetPrecisionOverflow) {
auto comparison_stream = ComparisonStream();
comparison_stream << std::setprecision(200) << value;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("602214085700000015187968")),
- ENCODED_MESSAGE(EqualsProto(
- R"pb(value { str: "602214085700000015187968" })pb")))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("602214085700000015187968")),
+ ENCODED_MESSAGE(HasValues(ElementsAre(EqualsProto(
+ R"pb(str: "602214085700000015187968")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::setprecision(200) << value;
@@ -1493,13 +1479,13 @@ TEST(ManipulatorLogFormatTest, SetW) {
EXPECT_CALL(
test_sink,
- Send(AllOf(
- TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq(" 77")),
- // `std::setw` isn't a manipulator. We're unable to
- // distinguish its return type from arbitrary user-defined
- // types and thus don't suppress the empty str value.
- ENCODED_MESSAGE(EqualsProto(R"pb(value { str: " 77" })pb")))));
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq(" 77")),
+ // `std::setw` isn't a manipulator. We're unable to
+ // distinguish its return type from arbitrary user-defined
+ // types and thus don't suppress the empty str value.
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: " 77")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::setw(8) << value;
@@ -1515,9 +1501,8 @@ TEST(ManipulatorLogFormatTest, Left) {
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq("-77 ")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value {
- str: "-77 "
- })pb")))));
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "-77 ")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::left << std::setw(8) << value;
@@ -1533,9 +1518,8 @@ TEST(ManipulatorLogFormatTest, Right) {
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq(" -77")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value {
- str: " -77"
- })pb")))));
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: " -77")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::right << std::setw(8) << value;
@@ -1551,9 +1535,8 @@ TEST(ManipulatorLogFormatTest, Internal) {
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq("- 77")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value {
- str: "- 77"
- })pb")))));
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "- 77")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::internal << std::setw(8) << value;
@@ -1573,9 +1556,8 @@ TEST(ManipulatorLogFormatTest, SetFill) {
// unable to distinguish its return
// type from arbitrary user-defined types and
// thus don't suppress the empty str value.
- ENCODED_MESSAGE(EqualsProto(R"pb(value {
- str: "00000077"
- })pb")))));
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "00000077")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::setfill('0') << std::setw(8) << value;
@@ -1596,10 +1578,10 @@ TEST(ManipulatorLogFormatTest, FromCustom) {
EXPECT_CALL(test_sink,
Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
TextMessage(Eq("FromCustomClass{} 0x77")),
- ENCODED_MESSAGE(EqualsProto(
- R"pb(value { str: "FromCustomClass{}" }
- value { literal: " " }
- value { str: "0x77" })pb")))));
+ ENCODED_MESSAGE(HasValues(ElementsAre(
+ EqualsProto(R"pb(str: "FromCustomClass{}")pb"),
+ EqualsProto(R"pb(literal: " ")pb"),
+ EqualsProto(R"pb(str: "0x77")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value << " " << 0x77;
@@ -1615,11 +1597,11 @@ TEST(ManipulatorLogFormatTest, CustomClassStreamsNothing) {
auto comparison_stream = ComparisonStream();
comparison_stream << value << 77;
- EXPECT_CALL(
- test_sink,
- Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
- TextMessage(Eq("77")),
- ENCODED_MESSAGE(EqualsProto(R"pb(value { str: "77" })pb")))));
+ EXPECT_CALL(test_sink,
+ Send(AllOf(TextMessage(MatchesOstream(comparison_stream)),
+ TextMessage(Eq("77")),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "77")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << value << 77;
@@ -1642,9 +1624,9 @@ TEST(ManipulatorLogFormatTest, IOManipsDoNotAffectAbslStringify) {
EXPECT_CALL(
test_sink,
- Send(AllOf(
- TextMessage(Eq("(10, 20)")), TextMessage(Eq(absl::StrCat(p))),
- ENCODED_MESSAGE(EqualsProto(R"pb(value { str: "(10, 20)" })pb")))));
+ Send(AllOf(TextMessage(Eq("(10, 20)")), TextMessage(Eq(absl::StrCat(p))),
+ ENCODED_MESSAGE(HasValues(
+ ElementsAre(EqualsProto(R"pb(str: "(10, 20)")pb")))))));
test_sink.StartCapturingLogs();
LOG(INFO) << std::hex << p;