Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1438)

Unified Diff: mojo/public/cpp/bindings/tests/struct_unittest.cc

Issue 1519673002: Add helpers for logging mojom objects. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: rebase Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/cpp/bindings/tests/string_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/tests/struct_unittest.cc
diff --git a/mojo/public/cpp/bindings/tests/struct_unittest.cc b/mojo/public/cpp/bindings/tests/struct_unittest.cc
index 1c98a5e7600292d8cc64cdbdb14ac1ecea92ab33..4af050c4ec3824650ec3d014eb2ddca8c52ac59f 100644
--- a/mojo/public/cpp/bindings/tests/struct_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/struct_unittest.cc
@@ -463,5 +463,34 @@ TEST_F(StructTest, Versioning_NewToOld) {
}
}
+static std::ostream& operator<<(std::ostream& os, const Rect& value) {
+ return os << "{x=" << value.x << ", y=" << value.y
+ << ", width=" << value.width << ", height=" << value.height << "}";
+}
+
+static std::ostream& operator<<(std::ostream& os, const RectPair& value) {
+ return os << "{first=" << value.first << ", second=" << value.second << "}";
+}
+
+TEST_F(StructTest, OutputFormatting) {
+ InlinedStructPtr<Rect> inlined_struct_ptr = MakeRect(1);
+ InlinedStructPtr<Rect> null_inlined_struct_ptr;
+ StructPtr<RectPair> struct_ptr = RectPair::New();
+ struct_ptr->first = MakeRect(2);
+ StructPtr<RectPair> null_struct_ptr;
+
+ std::ostringstream so;
+ so << "inlined_struct_ptr=" << inlined_struct_ptr
+ << ", null_inlined_struct_ptr=" << null_inlined_struct_ptr
+ << ", struct_ptr=" << struct_ptr
+ << ", null_struct_ptr=" << null_struct_ptr;
+ EXPECT_EQ(
+ "inlined_struct_ptr={x=1, y=2, width=10, height=20}, "
+ "null_inlined_struct_ptr=null, "
+ "struct_ptr={first={x=2, y=4, width=20, height=40}, second=null}, "
+ "null_struct_ptr=null",
+ so.str());
+}
+
} // namespace test
} // namespace mojo
« no previous file with comments | « mojo/public/cpp/bindings/tests/string_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698