summaryrefslogtreecommitdiffstats
path: root/mfbt/tests/TestBufferList.cpp
diff options
context:
space:
mode:
authorAlex Gaynor <agaynor@mozilla.com>2018-05-18 18:59:00 -0400
committerwolfbeast <mcwerewolf@gmail.com>2018-06-29 07:58:16 +0200
commit8ed2f59cc5f07299dfedc658283eb0ea4b49e08c (patch)
treebc8ced666f86164ed47e84e2a0afc0577b2a51e1 /mfbt/tests/TestBufferList.cpp
parent9836c7e10440364f3516c9a29e351cba92237b61 (diff)
downloadUXP-8ed2f59cc5f07299dfedc658283eb0ea4b49e08c.tar
UXP-8ed2f59cc5f07299dfedc658283eb0ea4b49e08c.tar.gz
UXP-8ed2f59cc5f07299dfedc658283eb0ea4b49e08c.tar.lz
UXP-8ed2f59cc5f07299dfedc658283eb0ea4b49e08c.tar.xz
UXP-8ed2f59cc5f07299dfedc658283eb0ea4b49e08c.zip
Bug 1456189 - Simplify BufferList::Extract to make the lifetimes clearer. r=froydnj, a=RyanVM
Diffstat (limited to 'mfbt/tests/TestBufferList.cpp')
-rw-r--r--mfbt/tests/TestBufferList.cpp33
1 files changed, 30 insertions, 3 deletions
diff --git a/mfbt/tests/TestBufferList.cpp b/mfbt/tests/TestBufferList.cpp
index cccaac021..207fa106f 100644
--- a/mfbt/tests/TestBufferList.cpp
+++ b/mfbt/tests/TestBufferList.cpp
@@ -245,12 +245,39 @@ int main(void)
BufferList bl3 = bl.Extract(iter, kExtractOverSize, &success);
MOZ_RELEASE_ASSERT(!success);
- MOZ_RELEASE_ASSERT(iter.AdvanceAcrossSegments(bl, kSmallWrite * 3 - kExtractSize - kExtractStart));
- MOZ_RELEASE_ASSERT(iter.Done());
-
iter = bl2.Iter();
MOZ_RELEASE_ASSERT(iter.AdvanceAcrossSegments(bl2, kExtractSize));
MOZ_RELEASE_ASSERT(iter.Done());
+ BufferList bl4(8, 8, 8);
+ bl4.WriteBytes("abcd1234", 8);
+ iter = bl4.Iter();
+ iter.Advance(bl4, 8);
+
+ BufferList bl5 = bl4.Extract(iter, kExtractSize, &success);
+ MOZ_RELEASE_ASSERT(!success);
+
+ BufferList bl6(0, 0, 16);
+ bl6.WriteBytes("abcdefgh12345678", 16);
+ bl6.WriteBytes("ijklmnop87654321", 16);
+ iter = bl6.Iter();
+ iter.Advance(bl6, 8);
+ BufferList bl7 = bl6.Extract(iter, 16, &success);
+ MOZ_RELEASE_ASSERT(success);
+ char data[16];
+ MOZ_RELEASE_ASSERT(bl6.ReadBytes(iter, data, 8));
+ MOZ_RELEASE_ASSERT(memcmp(data, "87654321", 8) == 0);
+ iter = bl7.Iter();
+ MOZ_RELEASE_ASSERT(bl7.ReadBytes(iter, data, 16));
+ MOZ_RELEASE_ASSERT(memcmp(data, "12345678ijklmnop", 16) == 0);
+
+ BufferList bl8(0, 0, 16);
+ bl8.WriteBytes("abcdefgh12345678", 16);
+ iter = bl8.Iter();
+ BufferList bl9 = bl8.Extract(iter, 8, &success);
+ MOZ_RELEASE_ASSERT(success);
+ MOZ_RELEASE_ASSERT(bl9.Size() == 8);
+ MOZ_RELEASE_ASSERT(!iter.Done());
+
return 0;
}