lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpou...@apache.org
Subject [1/2] lucene-solr:master: LUCENE-7469: Avoid TestBooleanRewrites test failures due to floating-point inaccuracy issues.
Date Mon, 03 Oct 2016 07:10:08 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/branch_6x cbb39c3e2 -> c6f5abaae
  refs/heads/master 31d07eda1 -> 632d12987


LUCENE-7469: Avoid TestBooleanRewrites test failures due to floating-point inaccuracy issues.


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/632d1298
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/632d1298
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/632d1298

Branch: refs/heads/master
Commit: 632d129871ab35a341b9215d3bc99043cb4cc041
Parents: 31d07ed
Author: Adrien Grand <jpountz@gmail.com>
Authored: Mon Oct 3 09:07:23 2016 +0200
Committer: Adrien Grand <jpountz@gmail.com>
Committed: Mon Oct 3 09:07:23 2016 +0200

----------------------------------------------------------------------
 .../lucene/search/TestBooleanRewrites.java       | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/632d1298/lucene/core/src/test/org/apache/lucene/search/TestBooleanRewrites.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestBooleanRewrites.java b/lucene/core/src/test/org/apache/lucene/search/TestBooleanRewrites.java
index 3ec2dd3..5e65906 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestBooleanRewrites.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestBooleanRewrites.java
@@ -18,6 +18,10 @@ package org.apache.lucene.search;
 
 
 import java.io.IOException;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
 
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
@@ -411,11 +415,16 @@ public class TestBooleanRewrites extends LuceneTestCase {
   private void assertEquals(TopDocs td1, TopDocs td2) {
     assertEquals(td1.totalHits, td2.totalHits);
     assertEquals(td1.scoreDocs.length, td2.scoreDocs.length);
-    for (int i = 0; i < td1.scoreDocs.length; ++i) {
-      ScoreDoc sd1 = td1.scoreDocs[i];
-      ScoreDoc sd2 = td2.scoreDocs[i];
-      assertEquals(sd1.doc, sd2.doc);
-      assertEquals(sd1.score, sd2.score, 0.01f);
+    Map<Integer, Float> expectedScores = Arrays.stream(td1.scoreDocs).collect(Collectors.toMap(sd
-> sd.doc, sd -> sd.score));
+    Set<Integer> actualResultSet = Arrays.stream(td2.scoreDocs).map(sd -> sd.doc).collect(Collectors.toSet());
+
+    assertEquals("Set of matching documents differs",
+        expectedScores.keySet(), actualResultSet);
+
+    for (ScoreDoc scoreDoc : td2.scoreDocs) {
+      final float expectedScore = expectedScores.get(scoreDoc.doc);
+      final float actualScore = scoreDoc.score;
+      assertEquals(expectedScore, actualScore, 10e-5);
     }
   }
 }


Mime
View raw message