Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 #include "content/browser/storage_partition_impl.h" | |
| 6 #include "testing/gtest/include/gtest/gtest.h" | |
| 7 | |
| 8 using namespace content; | |
|
awong
2012/11/02 21:56:13
using namespace is disallowed.
Usually I stuff th
nasko
2012/11/03 00:36:24
Done.
| |
| 9 | |
| 10 class StoragePartitionDescriptorTest : public testing::Test { | |
| 11 }; | |
| 12 | |
| 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(StoragePartitionDescriptorTest, OperatorLess) { | |
| 16 StoragePartitionImpl::StoragePartitionDescriptor d1("", "", false); | |
|
awong
2012/11/02 21:56:13
Wow...this is a very complete test. :)
FYI, it's
nasko
2012/11/03 00:36:24
After chasing bugs in the previous CL due to bugs
| |
| 17 StoragePartitionImpl::StoragePartitionDescriptor d2("", "", false); | |
| 18 StoragePartitionImpl::StoragePartitionDescriptor d3("", "", true); | |
| 19 StoragePartitionImpl::StoragePartitionDescriptor d4("a", "", true); | |
| 20 StoragePartitionImpl::StoragePartitionDescriptor d5("b", "", true); | |
| 21 StoragePartitionImpl::StoragePartitionDescriptor d6("", "abc", false); | |
| 22 StoragePartitionImpl::StoragePartitionDescriptor d7("", "abc", true); | |
| 23 StoragePartitionImpl::StoragePartitionDescriptor d8("a", "abc", false); | |
| 24 StoragePartitionImpl::StoragePartitionDescriptor d9("a", "abc", true); | |
| 25 | |
| 26 StoragePartitionImpl::StoragePartitionDescriptorLess less; | |
| 27 | |
| 28 // Let's ensure basic comparison works | |
|
awong
2012/11/02 21:56:13
period at the end of the sentence.
nasko
2012/11/03 00:36:24
Done.
| |
| 29 EXPECT_TRUE(less(d1, d3)); | |
| 30 EXPECT_TRUE(less(d1, d4)); | |
| 31 EXPECT_TRUE(less(d3, d4)); | |
| 32 EXPECT_TRUE(less(d4, d5)); | |
| 33 EXPECT_TRUE(less(d4, d8)); | |
| 34 EXPECT_TRUE(less(d6, d4)); | |
| 35 EXPECT_TRUE(less(d6, d7)); | |
| 36 EXPECT_TRUE(less(d8, d9)); | |
| 37 | |
| 38 // Now, ensure antisymmetry for each pair we've tested. | |
| 39 EXPECT_FALSE(less(d3, d1)); | |
| 40 EXPECT_FALSE(less(d4, d1)); | |
| 41 EXPECT_FALSE(less(d4, d3)); | |
| 42 EXPECT_FALSE(less(d5, d4)); | |
| 43 EXPECT_FALSE(less(d8, d4)); | |
| 44 EXPECT_FALSE(less(d4, d6)); | |
| 45 EXPECT_FALSE(less(d7, d6)); | |
| 46 EXPECT_FALSE(less(d9, d8)); | |
| 47 | |
| 48 // Check for irreflexivity | |
|
awong
2012/11/02 21:56:13
.
nasko
2012/11/03 00:36:24
Done.
| |
| 49 EXPECT_FALSE(less(d1, d1)); | |
| 50 | |
| 51 // Check for transitivity | |
|
awong
2012/11/02 21:56:13
.
nasko
2012/11/03 00:36:24
Done.
| |
| 52 EXPECT_TRUE(less(d1, d4)); | |
| 53 | |
| 54 // Let's enforce that two identical elements obey strict weak ordering. | |
| 55 EXPECT_TRUE(!less(d1, d2) && !less(d2, d1)); | |
| 56 } | |
| OLD | NEW |