OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/storage_partition_impl_map.h" | 5 #include "content/browser/storage_partition_impl_map.h" |
6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
7 | 7 |
8 namespace content { | 8 namespace content { |
9 | 9 |
10 class StoragePartitionConfigTest : public testing::Test { | 10 class StoragePartitionConfigTest : public testing::Test { |
11 }; | 11 }; |
12 | 12 |
13 // Test that the Less comparison function is implemented properly to uniquely | 13 // Test that the Less comparison function is implemented properly to uniquely |
14 // identify storage partitions used as keys in a std::map. | 14 // identify storage partitions used as keys in a std::map. |
15 TEST_F(StoragePartitionConfigTest, OperatorLess) { | 15 TEST_F(StoragePartitionConfigTest, OperatorLess) { |
16 StoragePartitionImplMap::StoragePartitionConfig c1("", "", false); | 16 StoragePartitionImplMap::StoragePartitionConfig c1( |
17 StoragePartitionImplMap::StoragePartitionConfig c2("", "", false); | 17 std::string(), std::string(), false); |
18 StoragePartitionImplMap::StoragePartitionConfig c3("", "", true); | 18 StoragePartitionImplMap::StoragePartitionConfig c2( |
19 StoragePartitionImplMap::StoragePartitionConfig c4("a", "", true); | 19 std::string(), std::string(), false); |
20 StoragePartitionImplMap::StoragePartitionConfig c5("b", "", true); | 20 StoragePartitionImplMap::StoragePartitionConfig c3( |
21 StoragePartitionImplMap::StoragePartitionConfig c6("", "abc", false); | 21 std::string(), std::string(), true); |
22 StoragePartitionImplMap::StoragePartitionConfig c7("", "abc", true); | 22 StoragePartitionImplMap::StoragePartitionConfig c4("a", std::string(), true); |
| 23 StoragePartitionImplMap::StoragePartitionConfig c5("b", std::string(), true); |
| 24 StoragePartitionImplMap::StoragePartitionConfig c6( |
| 25 std::string(), "abc", false); |
| 26 StoragePartitionImplMap::StoragePartitionConfig c7( |
| 27 std::string(), "abc", true); |
23 StoragePartitionImplMap::StoragePartitionConfig c8("a", "abc", false); | 28 StoragePartitionImplMap::StoragePartitionConfig c8("a", "abc", false); |
24 StoragePartitionImplMap::StoragePartitionConfig c9("a", "abc", true); | 29 StoragePartitionImplMap::StoragePartitionConfig c9("a", "abc", true); |
25 | 30 |
26 StoragePartitionImplMap::StoragePartitionConfigLess less; | 31 StoragePartitionImplMap::StoragePartitionConfigLess less; |
27 | 32 |
28 // Let's ensure basic comparison works. | 33 // Let's ensure basic comparison works. |
29 EXPECT_TRUE(less(c1, c3)); | 34 EXPECT_TRUE(less(c1, c3)); |
30 EXPECT_TRUE(less(c1, c4)); | 35 EXPECT_TRUE(less(c1, c4)); |
31 EXPECT_TRUE(less(c3, c4)); | 36 EXPECT_TRUE(less(c3, c4)); |
32 EXPECT_TRUE(less(c4, c5)); | 37 EXPECT_TRUE(less(c4, c5)); |
(...skipping 16 matching lines...) Expand all Loading... |
49 EXPECT_FALSE(less(c1, c1)); | 54 EXPECT_FALSE(less(c1, c1)); |
50 | 55 |
51 // Check for transitivity. | 56 // Check for transitivity. |
52 EXPECT_TRUE(less(c1, c4)); | 57 EXPECT_TRUE(less(c1, c4)); |
53 | 58 |
54 // Let's enforce that two identical elements obey strict weak ordering. | 59 // Let's enforce that two identical elements obey strict weak ordering. |
55 EXPECT_TRUE(!less(c1, c2) && !less(c2, c1)); | 60 EXPECT_TRUE(!less(c1, c2) && !less(c2, c1)); |
56 } | 61 } |
57 | 62 |
58 } // namespace content | 63 } // namespace content |
OLD | NEW |