Skip to content

Commit

Permalink
Finish test review E-I
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirwin committed Nov 10, 2024
1 parent e71ce81 commit 54553bb
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 112 deletions.
6 changes: 3 additions & 3 deletions src/Lucene.Net.TestFramework/Support/TestFramework/Assert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@ public static void IsTrue(bool condition)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void NotNull(object anObject)
{
if (!(anObject is null))
if (anObject is not null)
_NUnit.Assert.NotNull(anObject);
}
//
Expand Down Expand Up @@ -973,7 +973,7 @@ public static void NotNull(object anObject, string message, params object[] args
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Null(object anObject, string message, params object[] args)
{
if (!(anObject is null))
if (anObject is not null)
_NUnit.Assert.Null(anObject, message, args);
}
//
Expand All @@ -988,7 +988,7 @@ public static void Null(object anObject, string message, params object[] args)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Null(object anObject)
{
if (!(anObject is null))
if (anObject is not null)
_NUnit.Assert.Null(anObject);
}

Expand Down
3 changes: 3 additions & 0 deletions src/Lucene.Net.Tests/Index/TestDuelingCodecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
using NUnit.Framework;
using System;
using System.Text.RegularExpressions;
#if !FEATURE_RANDOM_NEXTINT64_NEXTSINGLE
using RandomizedTesting.Generators;
#endif

namespace Lucene.Net.Index
{
Expand Down
6 changes: 3 additions & 3 deletions src/Lucene.Net.Tests/Index/TestFieldInfos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public virtual FieldInfos ReadFieldInfos(Directory dir, string filename)
[Test]
public virtual void Test()
{
string name = "testFile";
const string name = "testFile";
Directory dir = NewDirectory();
FieldInfos fieldInfos = CreateAndWriteFieldInfos(dir, name);

Expand Down Expand Up @@ -104,7 +104,7 @@ public virtual void Test()
[Test]
public virtual void TestReadOnly()
{
string name = "testFile";
const string name = "testFile";
Directory dir = NewDirectory();
FieldInfos fieldInfos = CreateAndWriteFieldInfos(dir, name);
FieldInfos readOnly = ReadFieldInfos(dir, name);
Expand All @@ -122,4 +122,4 @@ private void AssertReadOnly(FieldInfos readOnly, FieldInfos modifiable)
}
}
}
}
}
6 changes: 1 addition & 5 deletions src/Lucene.Net.Tests/Index/TestFieldsReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ public class TestFieldsReader : LuceneTestCase
private static Document testDoc;
private static FieldInfos.Builder fieldInfos = null;

/// <summary>
/// LUCENENET specific
/// Is non-static because NewIndexWriterConfig is no longer static.
/// </summary>
[OneTimeSetUp]
public override void BeforeClass()
{
Expand Down Expand Up @@ -283,4 +279,4 @@ public virtual void TestExceptions()
}
}
}
}
}
14 changes: 9 additions & 5 deletions src/Lucene.Net.Tests/Index/TestFlex.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,16 @@ public virtual void TestNonFlex()

const int DOC_COUNT = 177;

IndexWriter w = new IndexWriter(d, (new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random))).SetMaxBufferedDocs(7).SetMergePolicy(NewLogMergePolicy()));
IndexWriter w = new IndexWriter(d,
new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random))
.SetMaxBufferedDocs(7)
.SetMergePolicy(NewLogMergePolicy()));

for (int iter = 0; iter < 2; iter++)
{
if (iter == 0)
{
Documents.Document doc = new Documents.Document();
Document doc = new Document();
doc.Add(NewTextField("field1", "this is field1", Field.Store.NO));
doc.Add(NewTextField("field2", "this is field2", Field.Store.NO));
doc.Add(NewTextField("field3", "aaa", Field.Store.NO));
Expand Down Expand Up @@ -75,8 +78,9 @@ public virtual void TestNonFlex()
public virtual void TestTermOrd()
{
Directory d = NewDirectory();
IndexWriter w = new IndexWriter(d, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random)).SetCodec(TestUtil.AlwaysPostingsFormat(new Lucene41PostingsFormat())));
Documents.Document doc = new Documents.Document();
IndexWriter w = new IndexWriter(d, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random))
.SetCodec(TestUtil.AlwaysPostingsFormat(new Lucene41PostingsFormat())));
Document doc = new Document();
doc.Add(NewTextField("f", "a b c", Field.Store.NO));
w.AddDocument(doc);
w.ForceMerge(1);
Expand All @@ -96,4 +100,4 @@ public virtual void TestTermOrd()
d.Dispose();
}
}
}
}
11 changes: 6 additions & 5 deletions src/Lucene.Net.Tests/Index/TestFlushByRamOrCountsPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ namespace Lucene.Net.Index
// LUCENENET specific - Specify to unzip the line file docs
[UseTempLineDocsFile]
[Timeout(900_000)] // 15 minutes
public class TestFlushByRamOrCountsPolicy : LuceneTestCase
public class TestFlushByRamOrCountsPolicy : LuceneTestCase
{

private static LineFileDocs lineDocFile;

[OneTimeSetUp]
Expand Down Expand Up @@ -95,7 +94,8 @@ protected internal virtual void RunFlushByRam(int numThreads, double maxRamMB, b
MockAnalyzer analyzer = new MockAnalyzer(Random);
analyzer.MaxTokenLength = TestUtil.NextInt32(Random, 1, IndexWriter.MAX_TERM_LENGTH);

IndexWriterConfig iwc = NewIndexWriterConfig(TEST_VERSION_CURRENT, analyzer).SetFlushPolicy(flushPolicy);
IndexWriterConfig iwc = NewIndexWriterConfig(TEST_VERSION_CURRENT, analyzer)
.SetFlushPolicy(flushPolicy);
int numDWPT = 1 + AtLeast(2);
DocumentsWriterPerThreadPool threadPool = new DocumentsWriterPerThreadPool(numDWPT);
iwc.SetIndexerThreadPool(threadPool);
Expand Down Expand Up @@ -156,7 +156,8 @@ public virtual void TestFlushDocCount()
AtomicInt32 numDocs = new AtomicInt32(numDocumentsToIndex);
Directory dir = NewDirectory();
MockDefaultFlushPolicy flushPolicy = new MockDefaultFlushPolicy();
IndexWriterConfig iwc = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random)).SetFlushPolicy(flushPolicy);
IndexWriterConfig iwc = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random))
.SetFlushPolicy(flushPolicy);

int numDWPT = 1 + AtLeast(2);
DocumentsWriterPerThreadPool threadPool = new DocumentsWriterPerThreadPool(numDWPT);
Expand Down Expand Up @@ -500,4 +501,4 @@ internal static void FindPending(DocumentsWriterFlushControl flushControl, IList
}
}

}
}
6 changes: 4 additions & 2 deletions src/Lucene.Net.Tests/Index/TestForTooMuchCloning.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ public virtual void Test()
MockDirectoryWrapper dir = NewMockDirectory();
TieredMergePolicy tmp = new TieredMergePolicy();
tmp.MaxMergeAtOnce = 2;
RandomIndexWriter w = new RandomIndexWriter(Random, dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random)).SetMaxBufferedDocs(2).SetMergePolicy(tmp));
RandomIndexWriter w = new RandomIndexWriter(Random, dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random))
.SetMaxBufferedDocs(2)
.SetMergePolicy(tmp));
const int numDocs = 20;
for (int docs = 0; docs < numDocs; docs++)
{
Expand Down Expand Up @@ -84,4 +86,4 @@ public virtual void Test()
dir.Dispose();
}
}
}
}
11 changes: 4 additions & 7 deletions src/Lucene.Net.Tests/Index/TestForceMergeForever.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class TestForceMergeForever : LuceneTestCase
private class MyIndexWriter : IndexWriter
{
internal AtomicInt32 mergeCount = new AtomicInt32();
internal bool first;
private bool first;

public MyIndexWriter(Directory dir, IndexWriterConfig conf)
: base(dir, conf)
Expand Down Expand Up @@ -97,7 +97,7 @@ public virtual void Test()

AtomicBoolean doStop = new AtomicBoolean();
w.Config.SetMaxBufferedDocs(2);
ThreadJob t = new ThreadAnonymousClass(this, w, numStartDocs, docs, doStop);
ThreadJob t = new ThreadAnonymousClass(w, numStartDocs, docs, doStop);
t.Start();
w.ForceMerge(1);
doStop.Value = true;
Expand All @@ -110,16 +110,13 @@ public virtual void Test()

private sealed class ThreadAnonymousClass : ThreadJob
{
private readonly TestForceMergeForever outerInstance;

private readonly MyIndexWriter w;
private readonly int numStartDocs;
private readonly LineFileDocs docs;
private readonly AtomicBoolean doStop;

public ThreadAnonymousClass(TestForceMergeForever outerInstance, Lucene.Net.Index.TestForceMergeForever.MyIndexWriter w, int numStartDocs, LineFileDocs docs, AtomicBoolean doStop)
public ThreadAnonymousClass(MyIndexWriter w, int numStartDocs, LineFileDocs docs, AtomicBoolean doStop)
{
this.outerInstance = outerInstance;
this.w = w;
this.numStartDocs = numStartDocs;
this.docs = docs;
Expand All @@ -144,4 +141,4 @@ public override void Run()
}
}
}
}
}
Loading

0 comments on commit 54553bb

Please sign in to comment.