Export of internal Abseil changes
-- 87cdfd6aa40941e116cd79ef70f9a7a8271db163 by Abseil Team <absl-team@google.com>: Fix a typo in random.h API documentation. PiperOrigin-RevId: 305176308 -- 8a38e1df49a18a954daca3ce617fd69045ff4c19 by Derek Mauro <dmauro@google.com>: Import GitHub #647: Allow external add_subdirectory for using GoogleTest PiperOrigin-RevId: 305156797 -- b1a2441536d4964fbe4e2329e74c322e6c41a4e6 by Gennadiy Rozental <rogeeff@google.com>: temporary roll back. PiperOrigin-RevId: 305149619 -- c78767577264348d2f881893f9407aadfe73ab75 by CJ Johnson <johnsoncj@google.com>: Rollback update to linux_clang-latest container while investigating a compiler bug. PiperOrigin-RevId: 304897689 -- 3c6fd38f53d2e982569fdba4043f75271c7b5de4 by Derek Mauro <dmauro@google.com>: Update linux_clang-latest container to one based on Ubuntu 18.04, which has libstdc++-8. PiperOrigin-RevId: 304885120 GitOrigin-RevId: 87cdfd6aa40941e116cd79ef70f9a7a8271db163 Change-Id: Iefa6efee93907ec0eecb8add804c5cc2f052b64d
This commit is contained in:
parent
c01b9916e7
commit
73ea9a9572
5 changed files with 173 additions and 351 deletions
|
|
@ -1403,53 +1403,6 @@ TEST(CordChunkIterator, Operations) {
|
|||
VerifyChunkIterator(subcords, 128);
|
||||
}
|
||||
|
||||
TEST(CordChunkIterator, MaxLengthFullTree) {
|
||||
// Start with a 1-byte cord, and then double its length in a loop. We should
|
||||
// be able to do this until the point where we would overflow size_t.
|
||||
|
||||
absl::Cord cord;
|
||||
size_t size = 1;
|
||||
AddExternalMemory("x", &cord);
|
||||
EXPECT_EQ(cord.size(), size);
|
||||
|
||||
const int kCordLengthDoublingLimit = std::numeric_limits<size_t>::digits - 1;
|
||||
for (int i = 0; i < kCordLengthDoublingLimit; ++i) {
|
||||
cord.Prepend(absl::Cord(cord));
|
||||
size <<= 1;
|
||||
|
||||
EXPECT_EQ(cord.size(), size);
|
||||
|
||||
auto chunk_it = cord.chunk_begin();
|
||||
EXPECT_EQ(*chunk_it, "x");
|
||||
}
|
||||
|
||||
EXPECT_DEATH_IF_SUPPORTED(
|
||||
(cord.Prepend(absl::Cord(cord)), *cord.chunk_begin()),
|
||||
"Cord is too long");
|
||||
}
|
||||
|
||||
TEST(CordChunkIterator, MaxDepth) {
|
||||
// By reusing nodes, it's possible in pathological cases to build a Cord that
|
||||
// exceeds both the maximum permissible length and depth. In this case, the
|
||||
// violation of the maximum depth is reported.
|
||||
absl::Cord left_child;
|
||||
AddExternalMemory("x", &left_child);
|
||||
absl::Cord root = left_child;
|
||||
|
||||
for (int i = 0; i < absl::cord_internal::MaxCordDepth() - 2; ++i) {
|
||||
size_t new_size = left_child.size() + root.size();
|
||||
root.Prepend(left_child);
|
||||
EXPECT_EQ(root.size(), new_size);
|
||||
|
||||
auto chunk_it = root.chunk_begin();
|
||||
EXPECT_EQ(*chunk_it, "x");
|
||||
|
||||
std::swap(left_child, root);
|
||||
}
|
||||
|
||||
EXPECT_DEATH_IF_SUPPORTED(root.Prepend(left_child), "Cord is too long");
|
||||
}
|
||||
|
||||
TEST(CordCharIterator, Traits) {
|
||||
static_assert(std::is_copy_constructible<absl::Cord::CharIterator>::value,
|
||||
"");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue