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/map.h" | 9 #include "mojo/public/cpp/bindings/map.h" |
10 #include "mojo/public/cpp/bindings/string.h" | 10 #include "mojo/public/cpp/bindings/string.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 Map<String, int> map; | 43 Map<String, int> map; |
44 for (size_t i = 0; i < kStringIntDataSize; ++i) | 44 for (size_t i = 0; i < kStringIntDataSize; ++i) |
45 map.insert(kStringIntData[i].string_data, kStringIntData[i].int_data); | 45 map.insert(kStringIntData[i].string_data, kStringIntData[i].int_data); |
46 | 46 |
47 for (size_t i = 0; i < kStringIntDataSize; ++i) { | 47 for (size_t i = 0; i < kStringIntDataSize; ++i) { |
48 EXPECT_EQ(kStringIntData[i].int_data, | 48 EXPECT_EQ(kStringIntData[i].int_data, |
49 map.at(kStringIntData[i].string_data)); | 49 map.at(kStringIntData[i].string_data)); |
50 } | 50 } |
51 } | 51 } |
52 | 52 |
53 TEST_F(MapTest, TestIndexOperator) { | |
54 Map<String, int> map; | |
55 for (size_t i = 0; i < kStringIntDataSize; ++i) | |
56 map[kStringIntData[i].string_data] = kStringIntData[i].int_data; | |
viettrungluu
2014/10/15 23:54:06
Two things:
- maybe test map[foo] when used strict
| |
57 | |
58 for (size_t i = 0; i < kStringIntDataSize; ++i) { | |
59 EXPECT_EQ(kStringIntData[i].int_data, | |
60 map.at(kStringIntData[i].string_data)); | |
61 } | |
62 } | |
63 | |
53 TEST_F(MapTest, ConstructedFromArray) { | 64 TEST_F(MapTest, ConstructedFromArray) { |
54 Array<String> keys(kStringIntDataSize); | 65 Array<String> keys(kStringIntDataSize); |
55 Array<int> values(kStringIntDataSize); | 66 Array<int> values(kStringIntDataSize); |
56 for (size_t i = 0; i < kStringIntDataSize; ++i) { | 67 for (size_t i = 0; i < kStringIntDataSize; ++i) { |
57 keys[i] = kStringIntData[i].string_data; | 68 keys[i] = kStringIntData[i].string_data; |
58 values[i] = kStringIntData[i].int_data; | 69 values[i] = kStringIntData[i].int_data; |
59 } | 70 } |
60 | 71 |
61 Map<String, int> map(keys.Pass(), values.Pass()); | 72 Map<String, int> map(keys.Pass(), values.Pass()); |
62 | 73 |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
329 | 340 |
330 ASSERT_EQ(1u, to_receive->second.size()); | 341 ASSERT_EQ(1u, to_receive->second.size()); |
331 ASSERT_EQ(1u, to_receive->second[0].size()); | 342 ASSERT_EQ(1u, to_receive->second[0].size()); |
332 ASSERT_FALSE(to_receive->second[0].at("hello world")[0]); | 343 ASSERT_FALSE(to_receive->second[0].at("hello world")[0]); |
333 ASSERT_TRUE(to_receive->second[0].at("hello world")[1]); | 344 ASSERT_TRUE(to_receive->second[0].at("hello world")[1]); |
334 } | 345 } |
335 | 346 |
336 } // namespace | 347 } // namespace |
337 } // namespace test | 348 } // namespace test |
338 } // namespace mojo | 349 } // namespace mojo |
OLD | NEW |