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

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

Issue 1532993002: Add output formatters for more mojom types. (Closed) Base URL: git@github.com:domokit/mojo.git@moz-9
Patch Set: rebase Created 4 years, 11 months 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
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..5ea4c6ca5c2fa16a70cb2b3835f16dc37920b246 100644
--- a/mojo/public/cpp/bindings/tests/struct_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/struct_unittest.cc
@@ -5,6 +5,7 @@
#include <string.h>
#include <type_traits>
+#include "mojo/public/cpp/bindings/formatting.h"
#include "mojo/public/cpp/bindings/lib/fixed_buffer.h"
#include "mojo/public/cpp/bindings/lib/validation_errors.h"
#include "mojo/public/cpp/environment/environment.h"
@@ -463,5 +464,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

Powered by Google App Engine
This is Rietveld 408576698