Skip to content

Commit

Permalink
Split out span appendable test for CharBlockArray
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirwin committed Nov 19, 2024
1 parent 1a8b783 commit 25ad8d4
Showing 1 changed file with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,6 @@ public virtual void TestAppendableInterface()
expected = t.ToString();
t.Append((char[])null); // No-op
Assert.AreEqual(expected, t.ToString());

// LUCENENET specific - test ReadOnlySpan<char> overload
t = new CharBlockArray();
t.Append("12345678".AsSpan());
Assert.AreEqual("12345678", t.ToString());
}

// LUCENENET: Borrowed this test from TestCharTermAttributeImpl
Expand Down Expand Up @@ -290,11 +285,30 @@ public virtual void TestAppendableInterfaceWithLongSequences()
const string longTestString = "012345678901234567890123456789";
t.Append(new CharSequenceAnonymousClass(longTestString));
Assert.AreEqual("4567890123456" + longTestString, t.ToString());
}

// LUCENENET specific - test ReadOnlySpan<char> overload
[Test]
[LuceneNetSpecific]
public virtual void TestSpanAppendableInterface()
{
CharBlockArray t = new CharBlockArray();

// Test with a span
t.Append("12345678".AsSpan());
Assert.AreEqual("12345678", t.ToString());

// test with a span slice
t.Append("0123456789".AsSpan(3, 5 - 3));
Assert.AreEqual("1234567834", t.ToString());

// test with a long span
t = new CharBlockArray();
t.Append("01234567890123456789012345678901234567890123456789".AsSpan());
Assert.AreEqual("01234567890123456789012345678901234567890123456789", t.ToString());

// test with a long span slice
t.Append("01234567890123456789012345678901234567890123456789".AsSpan(3, 50 - 3));
Assert.AreEqual("0123456789012345678901234567890123456789012345678934567890123456789012345678901234567890123456789", t.ToString());
}

private sealed class CharSequenceAnonymousClass : ICharSequence
Expand Down

0 comments on commit 25ad8d4

Please sign in to comment.