OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 1499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1510 } | 1510 } |
1511 EXPECT_LT(31ul, vector_.Capacity()); | 1511 EXPECT_LT(31ul, vector_.Capacity()); |
1512 | 1512 |
1513 for (int i = 0; i < 32; ++i) { | 1513 for (int i = 0; i < 32; ++i) { |
1514 map_.insert(i + 1, new IntWrapper(i + 1)); | 1514 map_.insert(i + 1, new IntWrapper(i + 1)); |
1515 } | 1515 } |
1516 EXPECT_LT(31ul, map_.Capacity()); | 1516 EXPECT_LT(31ul, map_.Capacity()); |
1517 } | 1517 } |
1518 | 1518 |
1519 void Dispose() { | 1519 void Dispose() { |
1520 // Remove elemets so that vector_ will try to shrink. | 1520 // Remove all elemets except one so that vector_ will try to shrink. |
1521 for (int i = 0; i < 32; ++i) { | 1521 for (int i = 1; i < 32; ++i) { |
1522 vector_.pop_back(); | 1522 vector_.pop_back(); |
1523 } | 1523 } |
1524 // Check that vector_ hasn't shrunk. | 1524 // Check that vector_ hasn't shrunk. |
1525 EXPECT_LT(31ul, map_.Capacity()); | 1525 EXPECT_LT(31ul, vector_.Capacity()); |
| 1526 // Just releasing the backing is allowed. |
| 1527 vector_.Clear(); |
| 1528 EXPECT_EQ(0ul, vector_.Capacity()); |
1526 | 1529 |
1527 // Remove elemets so that map_ will try to shrink. | 1530 // Remove elemets so that map_ will try to shrink. |
1528 for (int i = 0; i < 32; ++i) { | 1531 for (int i = 0; i < 32; ++i) { |
1529 map_.erase(i + 1); | 1532 map_.erase(i + 1); |
1530 } | 1533 } |
1531 // Check that map_ hasn't shrunk. | 1534 // Check that map_ hasn't shrunk. |
1532 EXPECT_LT(31ul, map_.Capacity()); | 1535 EXPECT_LT(31ul, map_.Capacity()); |
1533 // Just releasing the backing is allowed. | 1536 // Just releasing the backing is allowed. |
1534 map_.Clear(); | 1537 map_.Clear(); |
1535 EXPECT_EQ(0ul, map_.Capacity()); | 1538 EXPECT_EQ(0ul, map_.Capacity()); |
(...skipping 5143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6679 map.insert(key, IntWrapper::Create(i)); | 6682 map.insert(key, IntWrapper::Create(i)); |
6680 } | 6683 } |
6681 | 6684 |
6682 EXPECT_FALSE(string.Impl()->HasOneRef()); | 6685 EXPECT_FALSE(string.Impl()->HasOneRef()); |
6683 map.Clear(); | 6686 map.Clear(); |
6684 | 6687 |
6685 EXPECT_TRUE(string.Impl()->HasOneRef()); | 6688 EXPECT_TRUE(string.Impl()->HasOneRef()); |
6686 } | 6689 } |
6687 | 6690 |
6688 } // namespace blink | 6691 } // namespace blink |
OLD | NEW |