Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Commit 7aa85ae

Browse files
committed
Unit test for the IsEnd fix in the previous commit
1 parent 6f506ba commit 7aa85ae

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/Microsoft.AspNet.Server.KestrelTests/MemoryPoolBlock2Tests.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,30 @@ public void CopyToCorrectlyTraversesBlocks()
152152
}
153153
}
154154

155+
[Fact]
156+
public void IsEndCorrectlyTraversesBlocks()
157+
{
158+
using (var pool = new MemoryPool2())
159+
{
160+
var block1 = pool.Lease(128);
161+
var block2 = block1.Next = pool.Lease(128);
162+
var block3 = block2.Next = pool.Lease(128);
163+
var block4 = block3.Next = pool.Lease(128);
164+
165+
// There is no data in block2 or block4, so IsEnd should be true after 256 bytes are read.
166+
block1.End += 128;
167+
block3.End += 128;
168+
169+
var iterStart = block1.GetIterator();
170+
var iterMid = iterStart.Add(128);
171+
var iterEnd = iterMid.Add(128);
172+
173+
Assert.False(iterStart.IsEnd);
174+
Assert.False(iterMid.IsEnd);
175+
Assert.True(iterEnd.IsEnd);
176+
}
177+
}
178+
155179
private void AssertIterator(MemoryPoolIterator2 iter, MemoryPoolBlock2 block, int index)
156180
{
157181
Assert.Same(block, iter.Block);

0 commit comments

Comments
 (0)