From 25ad8d436c96190b257dc892bbbd773016a95f96 Mon Sep 17 00:00:00 2001 From: Paul Irwin Date: Tue, 19 Nov 2024 13:42:59 -0700 Subject: [PATCH] Split out span appendable test for CharBlockArray --- .../WriterCache/TestCharBlockArray.cs | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/Lucene.Net.Tests.Facet/Taxonomy/WriterCache/TestCharBlockArray.cs b/src/Lucene.Net.Tests.Facet/Taxonomy/WriterCache/TestCharBlockArray.cs index b30010a64c..295b01afce 100644 --- a/src/Lucene.Net.Tests.Facet/Taxonomy/WriterCache/TestCharBlockArray.cs +++ b/src/Lucene.Net.Tests.Facet/Taxonomy/WriterCache/TestCharBlockArray.cs @@ -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 overload - t = new CharBlockArray(); - t.Append("12345678".AsSpan()); - Assert.AreEqual("12345678", t.ToString()); } // LUCENENET: Borrowed this test from TestCharTermAttributeImpl @@ -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 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