Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,12 @@ public void LinkSuffix(BlobBuilder suffix)
// The value is not used, other than for calculating the value of Count property.
suffix._previousLengthOrFrozenSuffixLengthDelta = suffixPreviousLength + oldSuffixLength - suffix.Length;

if (!isEmpty)
if (isEmpty)
{
var suffixLast = suffix._nextOrPrevious;
_nextOrPrevious = (suffixLast != suffix) ? suffixLast : this;
}
else
{
// First and last chunks:
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,25 @@ public void LinkSuffix_Empty3()
Assert.Equal(16, builder2.Count);
}

[Fact]
public void LinkSuffix_EmptyDestination_SuffixAlreadyLinked()
Comment thread
MichalStrehovsky marked this conversation as resolved.
{
var emptyPrefix = new BlobBuilder(16);
var element = new BlobBuilder(16);
var tail = new BlobBuilder(16);

element.WriteByte(0x11);
tail.WriteByte(0x22);

element.LinkSuffix(tail);
emptyPrefix.LinkSuffix(element);

AssertEx.Equal(new byte[] { 0x11, 0x22 }, emptyPrefix.ToArray());
Assert.Equal(2, emptyPrefix.Count);
Assert.Equal(2, element.Count);
Assert.Equal(1, tail.Count);
}

[Fact]
public void LinkPrefix1()
{
Expand Down
Loading