OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <string.h> | 5 #include <string.h> |
6 #include <type_traits> | 6 #include <type_traits> |
7 | 7 |
8 #include "mojo/public/cpp/bindings/lib/fixed_buffer.h" | 8 #include "mojo/public/cpp/bindings/lib/fixed_buffer.h" |
9 #include "mojo/public/cpp/bindings/lib/validation_errors.h" | 9 #include "mojo/public/cpp/bindings/lib/validation_errors.h" |
10 #include "mojo/public/cpp/environment/environment.h" | 10 #include "mojo/public/cpp/environment/environment.h" |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 MultiVersionStructV0Ptr expected_output(MultiVersionStructV0::New()); | 456 MultiVersionStructV0Ptr expected_output(MultiVersionStructV0::New()); |
457 expected_output->f_int32 = 123; | 457 expected_output->f_int32 = 123; |
458 | 458 |
459 MultiVersionStructV0Ptr output = | 459 MultiVersionStructV0Ptr output = |
460 SerializeAndDeserialize<MultiVersionStructV0Ptr>(input.Pass()); | 460 SerializeAndDeserialize<MultiVersionStructV0Ptr>(input.Pass()); |
461 EXPECT_TRUE(output); | 461 EXPECT_TRUE(output); |
462 EXPECT_TRUE(output->Equals(*expected_output)); | 462 EXPECT_TRUE(output->Equals(*expected_output)); |
463 } | 463 } |
464 } | 464 } |
465 | 465 |
| 466 static std::ostream& operator<<(std::ostream& os, const Rect& value) { |
| 467 return os << "{x=" << value.x << ", y=" << value.y |
| 468 << ", width=" << value.width << ", height=" << value.height << "}"; |
| 469 } |
| 470 |
| 471 static std::ostream& operator<<(std::ostream& os, const RectPair& value) { |
| 472 return os << "{first=" << value.first << ", second=" << value.second << "}"; |
| 473 } |
| 474 |
| 475 TEST_F(StructTest, OutputFormatting) { |
| 476 InlinedStructPtr<Rect> inlined_struct_ptr = MakeRect(1); |
| 477 InlinedStructPtr<Rect> null_inlined_struct_ptr; |
| 478 StructPtr<RectPair> struct_ptr = RectPair::New(); |
| 479 struct_ptr->first = MakeRect(2); |
| 480 StructPtr<RectPair> null_struct_ptr; |
| 481 |
| 482 std::ostringstream so; |
| 483 so << "inlined_struct_ptr=" << inlined_struct_ptr |
| 484 << ", null_inlined_struct_ptr=" << null_inlined_struct_ptr |
| 485 << ", struct_ptr=" << struct_ptr |
| 486 << ", null_struct_ptr=" << null_struct_ptr; |
| 487 EXPECT_EQ( |
| 488 "inlined_struct_ptr={x=1, y=2, width=10, height=20}, " |
| 489 "null_inlined_struct_ptr=null, " |
| 490 "struct_ptr={first={x=2, y=4, width=20, height=40}, second=null}, " |
| 491 "null_struct_ptr=null", |
| 492 so.str()); |
| 493 } |
| 494 |
466 } // namespace test | 495 } // namespace test |
467 } // namespace mojo | 496 } // namespace mojo |
OLD | NEW |