This is an automated email from the ASF dual-hosted git repository.
paulirwin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git
The following commit(s) were added to refs/heads/master by this push:
new 013f962c2 Fix TestBufferedCharFilter.Test_Ready failing test, #1102
(#1104)
013f962c2 is described below
commit 013f962c247a8d296bedb781889693034527a9e4
Author: Paul Irwin <[email protected]>
AuthorDate: Mon Jan 20 08:17:33 2025 -0700
Fix TestBufferedCharFilter.Test_Ready failing test, #1102 (#1104)
---
.../Analysis/Util/TestBufferedCharFilter.cs | 28 ++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git
a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestBufferedCharFilter.cs
b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestBufferedCharFilter.cs
index 739781047..030ef8646 100644
---
a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestBufferedCharFilter.cs
+++
b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestBufferedCharFilter.cs
@@ -714,13 +714,13 @@ public void Test_ReadLine()
* @tests java.io.BufferedReader#ready()
*/
[Test, LuceneNetSpecific]
- [AwaitsFix(BugUrl =
"https://github.com/apache/lucenenet/issues/1102")] // LUCENENET TODO: fix test
public void Test_Ready()
{
// Test for method boolean java.io.BufferedReader.ready()
try
{
- br = new BufferedCharFilter(new StringReader(testString));
+ // LUCENENET specific: use TestStringReaderCharFilterAdapter
to adapt StringReader to be IsReady-aware.
+ br = new BufferedCharFilter(new
TestStringReaderCharFilterAdapter(new StringReader(testString)));
assertTrue("IsReady returned false", br.IsReady);
}
catch (Exception e) when (e.IsIOException())
@@ -729,6 +729,30 @@ public void Test_Ready()
}
}
+ /// <summary>
+ /// LUCENENET specific class for <see
cref="TestBufferedCharFilter.Test_Ready"/> to test that
+ /// <see cref="BufferedCharFilter.IsReady"/> cascades its call to the
underlying
+ /// <see cref="CharFilter.IsReady"/>. Rationale: IsReady indicates
that a call to
+ /// <see cref="TextReader.Read()"/> is guaranteed not to block. <see
cref="StringReader"/> does not block,
+ /// because there is no I/O. Therefore, if the underlying reader is a
<see cref="StringReader"/>, then
+ /// <see cref="CharFilter.IsReady"/> must return true.
+ /// </summary>
+ private class TestStringReaderCharFilterAdapter : CharFilter
+ {
+ public TestStringReaderCharFilterAdapter(StringReader input) //
Enforces the input reader is a StringReader
+ : base(input)
+ {
+ }
+
+ protected override int Correct(int currentOff)
+ => throw new NotImplementedException();
+
+ public override int Read(char[] buffer, int index, int count)
+ => m_input.Read(buffer, index, count);
+
+ public override bool IsReady => true; // StringReaders do not block
+ }
+
/**
* @tests java.io.BufferedReader#reset()
*/