Skip to content

Commit

Permalink
BUG: Lucene.Net.Search.TestBooleanQuery::TestBS2DisjunctionNextVsAdva…
Browse files Browse the repository at this point in the history
…nce(): Use Assert.AreEqual instead of Asssert.IsTrue with == to fix floating point comparison on x86 .NET Framework with optimizations enabled.
  • Loading branch information
NightOwl888 committed Oct 22, 2021
1 parent dd7ed62 commit d1dbbeb
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/Lucene.Net.Tests/Search/TestBooleanQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,6 @@ public virtual void TestDeMorgan()
}

[Test]
#if NETFRAMEWORK
[AwaitsFix(BugUrl = "https://github.com/apache/lucenenet/issues/269")] // LUCENENET TODO: this test fails on x86 on .NET Framework in Release mode only
#endif
public virtual void TestBS2DisjunctionNextVsAdvance()
{
Directory d = NewDirectory();
Expand Down Expand Up @@ -337,8 +334,10 @@ public virtual void TestBS2DisjunctionNextVsAdvance()
{
ScoreDoc hit = hits[nextUpto];
Assert.AreEqual(hit.Doc, nextDoc);

// LUCENENET: For some weird reason, on x86 in .NET Framework (optimizations enabled), using == (as they did in Lucene) doesn't work with optimizations enabled, but using AreEqual with epsilon of 0f does.
// Test for precise float equality:
Assert.IsTrue(hit.Score == scorer.GetScore(), "doc " + hit.Doc + " has wrong score: expected=" + hit.Score + " actual=" + scorer.GetScore());
Assert.AreEqual(hit.Score, scorer.GetScore(), 0f, "doc " + hit.Doc + " has wrong score: expected=" + hit.Score + " actual=" + scorer.GetScore());
}
upto = nextUpto;
}
Expand Down

0 comments on commit d1dbbeb

Please sign in to comment.