diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-07-02 17:51:09 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-07-02 17:51:09 +0200 |
commit | 4c9914227ed9e675d65ad16e0bb899e8107a0ee5 (patch) | |
tree | d4c542f51b5155eb3f3627c628686cfc0d648a2f /mfbt/tests/TestBufferList.cpp | |
parent | de01f1e7fce43d5919e6adcd73dfa617a9087520 (diff) | |
parent | aa6329b694a981dccd5b0fd124936c4b54fb94a4 (diff) | |
download | UXP-4c9914227ed9e675d65ad16e0bb899e8107a0ee5.tar UXP-4c9914227ed9e675d65ad16e0bb899e8107a0ee5.tar.gz UXP-4c9914227ed9e675d65ad16e0bb899e8107a0ee5.tar.lz UXP-4c9914227ed9e675d65ad16e0bb899e8107a0ee5.tar.xz UXP-4c9914227ed9e675d65ad16e0bb899e8107a0ee5.zip |
Merge branch 'ported-upstream'
Diffstat (limited to 'mfbt/tests/TestBufferList.cpp')
-rw-r--r-- | mfbt/tests/TestBufferList.cpp | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/mfbt/tests/TestBufferList.cpp b/mfbt/tests/TestBufferList.cpp index cccaac021..325f8a3aa 100644 --- a/mfbt/tests/TestBufferList.cpp +++ b/mfbt/tests/TestBufferList.cpp @@ -245,12 +245,51 @@ 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()); + + BufferList bl10(0, 0, 8); + bl10.WriteBytes("abcdefgh", 8); + bl10.WriteBytes("12345678", 8); + iter = bl10.Iter(); + BufferList bl11 = bl10.Extract(iter, 16, &success); + MOZ_RELEASE_ASSERT(success); + MOZ_RELEASE_ASSERT(bl11.Size() == 16); + MOZ_RELEASE_ASSERT(iter.Done()); + iter = bl11.Iter(); + MOZ_RELEASE_ASSERT(bl11.ReadBytes(iter, data, 16)); + MOZ_RELEASE_ASSERT(memcmp(data, "abcdefgh12345678", 16) == 0); + return 0; } |