| Index: net/disk_cache/simple/simple_index_unittest.cc
|
| diff --git a/net/disk_cache/simple/simple_index_unittest.cc b/net/disk_cache/simple/simple_index_unittest.cc
|
| index d763d7f55e1ff0858c3863922fb346408cb11ec9..1b0aee75235b6ca7a94db2955eb3e45d585c783c 100644
|
| --- a/net/disk_cache/simple/simple_index_unittest.cc
|
| +++ b/net/disk_cache/simple/simple_index_unittest.cc
|
| @@ -34,8 +34,7 @@ const uint64_t kTestEntrySize = 789;
|
|
|
| } // namespace
|
|
|
| -
|
| -class EntryMetadataTest : public testing::Test {
|
| +class EntryMetadataTest : public testing::Test {
|
| public:
|
| EntryMetadata NewEntryMetadataWithValues() {
|
| return EntryMetadata(kTestLastUsedTime, kTestEntrySize);
|
| @@ -186,6 +185,25 @@ TEST_F(EntryMetadataTest, Basics) {
|
| entry_metadata.GetLastUsedTime());
|
| }
|
|
|
| +// Tests that setting an unusually small/large last used time results in
|
| +// truncation (rather than crashing).
|
| +TEST_F(EntryMetadataTest, SaturatedLastUsedTime) {
|
| + EntryMetadata entry_metadata;
|
| +
|
| + // Set a time that is too large to be represented internally as 32-bit unix
|
| + // timestamp. Will saturate to a large timestamp (in year 2106).
|
| + entry_metadata.SetLastUsedTime(base::Time::Max());
|
| + EXPECT_EQ(INT64_C(15939440895000000),
|
| + entry_metadata.GetLastUsedTime().ToInternalValue());
|
| +
|
| + // Set a time that is too small to be represented by a unix timestamp (before
|
| + // 1970).
|
| + entry_metadata.SetLastUsedTime(
|
| + base::Time::FromInternalValue(7u)); // This is a date in 1601.
|
| + EXPECT_EQ(base::Time::UnixEpoch() + base::TimeDelta::FromSeconds(1),
|
| + entry_metadata.GetLastUsedTime());
|
| +}
|
| +
|
| TEST_F(EntryMetadataTest, Serialize) {
|
| EntryMetadata entry_metadata = NewEntryMetadataWithValues();
|
|
|
|
|