Generate ax enums from idl.
[chromium-blink-merge.git] / content / browser / storage_partition_impl_map_unittest.cc
blob04127cce7cb5e6f3f439ad99c60e7590aaa1340b
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
3 // found in the LICENSE file.
5 #include "content/browser/storage_partition_impl_map.h"
6 #include "testing/gtest/include/gtest/gtest.h"
8 namespace content {
10 class StoragePartitionConfigTest : public testing::Test {
13 // Test that the Less comparison function is implemented properly to uniquely
14 // identify storage partitions used as keys in a std::map.
15 TEST_F(StoragePartitionConfigTest, OperatorLess) {
16 StoragePartitionImplMap::StoragePartitionConfig c1(
17 std::string(), std::string(), false);
18 StoragePartitionImplMap::StoragePartitionConfig c2(
19 std::string(), std::string(), false);
20 StoragePartitionImplMap::StoragePartitionConfig c3(
21 std::string(), std::string(), 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);
28 StoragePartitionImplMap::StoragePartitionConfig c8("a", "abc", false);
29 StoragePartitionImplMap::StoragePartitionConfig c9("a", "abc", true);
31 StoragePartitionImplMap::StoragePartitionConfigLess less;
33 // Let's ensure basic comparison works.
34 EXPECT_TRUE(less(c1, c3));
35 EXPECT_TRUE(less(c1, c4));
36 EXPECT_TRUE(less(c3, c4));
37 EXPECT_TRUE(less(c4, c5));
38 EXPECT_TRUE(less(c4, c8));
39 EXPECT_TRUE(less(c6, c4));
40 EXPECT_TRUE(less(c6, c7));
41 EXPECT_TRUE(less(c8, c9));
43 // Now, ensure antisymmetry for each pair we've tested.
44 EXPECT_FALSE(less(c3, c1));
45 EXPECT_FALSE(less(c4, c1));
46 EXPECT_FALSE(less(c4, c3));
47 EXPECT_FALSE(less(c5, c4));
48 EXPECT_FALSE(less(c8, c4));
49 EXPECT_FALSE(less(c4, c6));
50 EXPECT_FALSE(less(c7, c6));
51 EXPECT_FALSE(less(c9, c8));
53 // Check for irreflexivity.
54 EXPECT_FALSE(less(c1, c1));
56 // Check for transitivity.
57 EXPECT_TRUE(less(c1, c4));
59 // Let's enforce that two identical elements obey strict weak ordering.
60 EXPECT_TRUE(!less(c1, c2) && !less(c2, c1));
63 } // namespace content