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 "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/validate_params.h" | 9 #include "mojo/public/cpp/bindings/lib/validate_params.h" |
10 #include "mojo/public/cpp/bindings/map.h" | 10 #include "mojo/public/cpp/bindings/map.h" |
11 #include "mojo/public/cpp/bindings/string.h" | 11 #include "mojo/public/cpp/bindings/string.h" |
12 #include "mojo/public/cpp/bindings/tests/container_test_util.h" | 12 #include "mojo/public/cpp/bindings/tests/container_test_util.h" |
| 13 #include "mojo/public/cpp/environment/environment.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
14 | 15 |
15 namespace mojo { | 16 namespace mojo { |
16 namespace test { | 17 namespace test { |
17 | 18 |
18 namespace { | 19 namespace { |
19 | 20 |
20 using mojo::internal::Array_Data; | 21 using mojo::internal::Array_Data; |
21 using mojo::internal::ArrayValidateParams; | 22 using mojo::internal::ArrayValidateParams; |
22 using mojo::internal::FixedBufferForTesting; | 23 using mojo::internal::FixedBufferForTesting; |
23 using mojo::internal::Map_Data; | 24 using mojo::internal::Map_Data; |
24 using mojo::internal::String_Data; | 25 using mojo::internal::String_Data; |
25 | 26 |
26 struct StringIntData { | 27 struct StringIntData { |
27 const char* string_data; | 28 const char* string_data; |
28 int int_data; | 29 int int_data; |
29 } kStringIntData[] = { | 30 } kStringIntData[] = { |
30 {"one", 1}, | 31 {"one", 1}, |
31 {"two", 2}, | 32 {"two", 2}, |
32 {"three", 3}, | 33 {"three", 3}, |
33 {"four", 4}, | 34 {"four", 4}, |
34 }; | 35 }; |
35 | 36 |
36 const size_t kStringIntDataSize = 4; | 37 const size_t kStringIntDataSize = 4; |
37 | 38 |
38 using MapTest = testing::Test; | 39 class MapTest : public testing::Test { |
| 40 public: |
| 41 ~MapTest() override {} |
| 42 |
| 43 private: |
| 44 Environment env_; |
| 45 }; |
39 | 46 |
40 // Tests that basic Map operations work. | 47 // Tests that basic Map operations work. |
41 TEST_F(MapTest, InsertWorks) { | 48 TEST_F(MapTest, InsertWorks) { |
42 Map<String, int> map; | 49 Map<String, int> map; |
43 for (size_t i = 0; i < kStringIntDataSize; ++i) | 50 for (size_t i = 0; i < kStringIntDataSize; ++i) |
44 map.insert(kStringIntData[i].string_data, kStringIntData[i].int_data); | 51 map.insert(kStringIntData[i].string_data, kStringIntData[i].int_data); |
45 | 52 |
46 for (size_t i = 0; i < kStringIntDataSize; ++i) { | 53 for (size_t i = 0; i < kStringIntDataSize; ++i) { |
47 EXPECT_EQ(kStringIntData[i].int_data, | 54 EXPECT_EQ(kStringIntData[i].int_data, |
48 map.at(kStringIntData[i].string_data)); | 55 map.at(kStringIntData[i].string_data)); |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 ASSERT_EQ(1u, deserialized_array.size()); | 314 ASSERT_EQ(1u, deserialized_array.size()); |
308 ASSERT_EQ(1u, deserialized_array[0].size()); | 315 ASSERT_EQ(1u, deserialized_array[0].size()); |
309 ASSERT_FALSE(deserialized_array[0].at("hello world")[0]); | 316 ASSERT_FALSE(deserialized_array[0].at("hello world")[0]); |
310 ASSERT_TRUE(deserialized_array[0].at("hello world")[1]); | 317 ASSERT_TRUE(deserialized_array[0].at("hello world")[1]); |
311 } | 318 } |
312 } | 319 } |
313 | 320 |
314 } // namespace | 321 } // namespace |
315 } // namespace test | 322 } // namespace test |
316 } // namespace mojo | 323 } // namespace mojo |
OLD | NEW |