| 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..0372f7b2f322f7c9d7ea4e0266c824aeebbb6965
|
| --- /dev/null
|
| +++ b/content/browser/storage_partition_impl_unittest.cc
|
| @@ -0,0 +1,62 @@
|
| +// 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"
|
| +
|
| +namespace content {
|
| +
|
| +namespace {
|
| +
|
| +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);
|
| + 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.
|
| + 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.
|
| + EXPECT_FALSE(less(d1, d1));
|
| +
|
| + // Check for transitivity.
|
| + EXPECT_TRUE(less(d1, d4));
|
| +
|
| + // Let's enforce that two identical elements obey strict weak ordering.
|
| + EXPECT_TRUE(!less(d1, d2) && !less(d2, d1));
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| +} // namespace content
|
|
|