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

Side by Side Diff: mojo/public/cpp/bindings/tests/map_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 unified diff | Download patch
OLDNEW
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 "mojo/public/cpp/bindings/array.h" 5 #include "mojo/public/cpp/bindings/array.h"
6 #include "mojo/public/cpp/bindings/lib/array_serialization.h" 6 #include "mojo/public/cpp/bindings/lib/array_serialization.h"
7 #include "mojo/public/cpp/bindings/lib/bindings_internal.h" 7 #include "mojo/public/cpp/bindings/lib/bindings_internal.h"
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/map_serialization.h" 9 #include "mojo/public/cpp/bindings/lib/map_serialization.h"
10 #include "mojo/public/cpp/bindings/lib/validate_params.h" 10 #include "mojo/public/cpp/bindings/lib/validate_params.h"
(...skipping 13 matching lines...) Expand all
24 using mojo::internal::ArrayValidateParams; 24 using mojo::internal::ArrayValidateParams;
25 using mojo::internal::FixedBufferForTesting; 25 using mojo::internal::FixedBufferForTesting;
26 using mojo::internal::Map_Data; 26 using mojo::internal::Map_Data;
27 using mojo::internal::String_Data; 27 using mojo::internal::String_Data;
28 using mojo::internal::ValidationError; 28 using mojo::internal::ValidationError;
29 29
30 struct StringIntData { 30 struct StringIntData {
31 const char* string_data; 31 const char* string_data;
32 int int_data; 32 int int_data;
33 } kStringIntData[] = { 33 } kStringIntData[] = {
34 {"one", 1}, 34 {"one", 1},
35 {"two", 2}, 35 {"two", 2},
36 {"three", 3}, 36 {"three", 3},
37 {"four", 4}, 37 {"four", 4},
38 }; 38 };
39 39
40 const size_t kStringIntDataSize = 4; 40 const size_t kStringIntDataSize = 4;
41 41
42 class MapTest : public testing::Test { 42 class MapTest : public testing::Test {
43 public: 43 public:
44 ~MapTest() override {} 44 ~MapTest() override {}
45 45
46 private: 46 private:
47 Environment env_; 47 Environment env_;
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 EXPECT_EQ(2u, map2.size()); 426 EXPECT_EQ(2u, map2.size());
427 EXPECT_FALSE(map2.is_null()); 427 EXPECT_FALSE(map2.is_null());
428 EXPECT_TRUE(map2[0].is_null()); 428 EXPECT_TRUE(map2[0].is_null());
429 EXPECT_FALSE(map2[1].is_null()); 429 EXPECT_FALSE(map2[1].is_null());
430 EXPECT_EQ(1, map2[1]->x); 430 EXPECT_EQ(1, map2[1]->x);
431 EXPECT_EQ(2, map2[1]->y); 431 EXPECT_EQ(2, map2[1]->y);
432 EXPECT_EQ(3, map2[1]->width); 432 EXPECT_EQ(3, map2[1]->width);
433 EXPECT_EQ(4, map2[1]->height); 433 EXPECT_EQ(4, map2[1]->height);
434 } 434 }
435 435
436 TEST_F(MapTest, OutputFormatting) {
437 Map<int32_t, std::string> null_map;
438 Map<int32_t, std::string> empty_map;
439 empty_map.mark_non_null();
440 Map<int32_t, std::string> one_element_map;
441 one_element_map.insert(123, "abc");
442 Map<int32_t, std::string> three_element_map;
443 three_element_map.insert(4, "d");
444 three_element_map.insert(5, "e");
445 three_element_map.insert(6, "f");
446
447 std::ostringstream so;
448 so << "null_map=" << null_map << ", empty_map=" << empty_map
449 << ", one_element_map=" << one_element_map
450 << ", three_element_map=" << three_element_map;
451
452 EXPECT_EQ(
453 "null_map=null, "
454 "empty_map=[], "
455 "one_element_map=[{123: abc}], "
456 "three_element_map=[{4: d}, {5: e}, {6: f}]",
457 so.str());
458 }
459
436 } // namespace 460 } // namespace
437 } // namespace test 461 } // namespace test
438 } // namespace mojo 462 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/tests/array_unittest.cc ('k') | mojo/public/cpp/bindings/tests/string_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698