Chromium Code Reviews| Index: content/browser/storage_partition_impl_unittest.cc |
| diff --git a/content/browser/storage_partition_impl_unittest.cc b/content/browser/storage_partition_impl_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4962a3af3b98c40928f51d33b02a217dfc6d3a21 |
| --- /dev/null |
| +++ b/content/browser/storage_partition_impl_unittest.cc |
| @@ -0,0 +1,56 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "content/browser/storage_partition_impl.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +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.
|
| + |
| +class StoragePartitionDescriptorTest : public testing::Test { |
| +}; |
| + |
| +// Test that the Less comparison function is implemented properly to uniquely |
| +// identify storage partitions used as keys in a std::map. |
| +TEST_F(StoragePartitionDescriptorTest, OperatorLess) { |
| + 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
|
| + StoragePartitionImpl::StoragePartitionDescriptor d2("", "", false); |
| + StoragePartitionImpl::StoragePartitionDescriptor d3("", "", true); |
| + StoragePartitionImpl::StoragePartitionDescriptor d4("a", "", true); |
| + StoragePartitionImpl::StoragePartitionDescriptor d5("b", "", true); |
| + StoragePartitionImpl::StoragePartitionDescriptor d6("", "abc", false); |
| + StoragePartitionImpl::StoragePartitionDescriptor d7("", "abc", true); |
| + StoragePartitionImpl::StoragePartitionDescriptor d8("a", "abc", false); |
| + StoragePartitionImpl::StoragePartitionDescriptor d9("a", "abc", true); |
| + |
| + StoragePartitionImpl::StoragePartitionDescriptorLess less; |
| + |
| + // 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.
|
| + EXPECT_TRUE(less(d1, d3)); |
| + EXPECT_TRUE(less(d1, d4)); |
| + EXPECT_TRUE(less(d3, d4)); |
| + EXPECT_TRUE(less(d4, d5)); |
| + EXPECT_TRUE(less(d4, d8)); |
| + EXPECT_TRUE(less(d6, d4)); |
| + EXPECT_TRUE(less(d6, d7)); |
| + EXPECT_TRUE(less(d8, d9)); |
| + |
| + // Now, ensure antisymmetry for each pair we've tested. |
| + EXPECT_FALSE(less(d3, d1)); |
| + EXPECT_FALSE(less(d4, d1)); |
| + EXPECT_FALSE(less(d4, d3)); |
| + EXPECT_FALSE(less(d5, d4)); |
| + EXPECT_FALSE(less(d8, d4)); |
| + EXPECT_FALSE(less(d4, d6)); |
| + EXPECT_FALSE(less(d7, d6)); |
| + EXPECT_FALSE(less(d9, d8)); |
| + |
| + // Check for irreflexivity |
|
awong
2012/11/02 21:56:13
.
nasko
2012/11/03 00:36:24
Done.
|
| + EXPECT_FALSE(less(d1, d1)); |
| + |
| + // Check for transitivity |
|
awong
2012/11/02 21:56:13
.
nasko
2012/11/03 00:36:24
Done.
|
| + EXPECT_TRUE(less(d1, d4)); |
| + |
| + // Let's enforce that two identical elements obey strict weak ordering. |
| + EXPECT_TRUE(!less(d1, d2) && !less(d2, d1)); |
| +} |