From d1dbbebeeb89a6d6126285208f4aef281bff8114 Mon Sep 17 00:00:00 2001 From: Shad Storhaug Date: Sat, 23 Oct 2021 02:27:53 +0700 Subject: [PATCH] BUG: Lucene.Net.Search.TestBooleanQuery::TestBS2DisjunctionNextVsAdvance(): Use Assert.AreEqual instead of Asssert.IsTrue with == to fix floating point comparison on x86 .NET Framework with optimizations enabled. --- src/Lucene.Net.Tests/Search/TestBooleanQuery.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Lucene.Net.Tests/Search/TestBooleanQuery.cs b/src/Lucene.Net.Tests/Search/TestBooleanQuery.cs index a511922073..5d6cef3188 100644 --- a/src/Lucene.Net.Tests/Search/TestBooleanQuery.cs +++ b/src/Lucene.Net.Tests/Search/TestBooleanQuery.cs @@ -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(); @@ -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; }