lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [2/4] lucenenet git commit: Lucene.Net.Tests.Expressions.TestExpressionSorts: Uncommented Collections.Shuffle call and reformatted tests for readability
Date Sun, 17 Sep 2017 13:19:06 GMT
Lucene.Net.Tests.Expressions.TestExpressionSorts: Uncommented Collections.Shuffle call and
reformatted tests for readability


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/97e4cea2
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/97e4cea2
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/97e4cea2

Branch: refs/heads/master
Commit: 97e4cea287cb4545faa9f1d9c2e6f792e380ef36
Parents: e5be5ad
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Sun Sep 17 16:45:15 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Sun Sep 17 16:45:15 2017 +0700

----------------------------------------------------------------------
 .../TestExpressionSorts.cs                      | 45 ++++++++++----------
 1 file changed, 22 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/97e4cea2/src/Lucene.Net.Tests.Expressions/TestExpressionSorts.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Expressions/TestExpressionSorts.cs b/src/Lucene.Net.Tests.Expressions/TestExpressionSorts.cs
index aee18aa..ece8934 100644
--- a/src/Lucene.Net.Tests.Expressions/TestExpressionSorts.cs
+++ b/src/Lucene.Net.Tests.Expressions/TestExpressionSorts.cs
@@ -39,9 +39,7 @@ namespace Lucene.Net.Expressions
     public class TestExpressionSorts : LuceneTestCase
     {
         private Directory dir;
-
         private IndexReader reader;
-
         private IndexSearcher searcher;
 
         [SetUp]
@@ -56,16 +54,15 @@ namespace Lucene.Net.Expressions
                 var document = new Document
 				{
 				    NewTextField("english", English.IntToEnglish(i), Field.Store.NO),
-				    NewTextField("oddeven", (i%2 == 0) ? "even" : "odd", Field.Store.NO
-				        ),
-				    NewStringField("byte", string.Empty + (unchecked((byte) Random().Next
-				        ())), Field.Store.NO),
-				    NewStringField("short", string.Empty + ((short) Random().Next()), Field.Store
-				        .NO),
+				    NewTextField("oddeven", (i%2 == 0) ? "even" : "odd", Field.Store.NO),
+				    NewStringField("byte", string.Empty + (unchecked((byte) Random().Next())), Field.Store.NO),
+				    NewStringField("short", string.Empty + ((short) Random().Next()), Field.Store.NO),
 				    new Int32Field("int", Random().Next(), Field.Store.NO),
 				    new Int64Field("long", Random().NextLong(), Field.Store.NO),
+
 				    new SingleField("float", Random().NextFloat(), Field.Store.NO),
 				    new DoubleField("double", Random().NextDouble(), Field.Store.NO),
+
 				    new NumericDocValuesField("intdocvalues", Random().Next()),
 				    new SingleDocValuesField("floatdocvalues", Random().NextFloat())
 				};
@@ -84,6 +81,7 @@ namespace Lucene.Net.Expressions
             base.TearDown();
         }
 
+        // LUCENENET TODO: Fails on x86, Release, net45 (but doesn't fail if any of these
3 parameters are changed)
         [Test]
         public virtual void TestQueries()
         {
@@ -113,13 +111,16 @@ namespace Lucene.Net.Expressions
             {
                 bool reversed = Random().NextBoolean();
                 SortField[] fields =
-				{ new SortField("int", SortFieldType.INT32, reversed
-				    ), new SortField("long", SortFieldType.INT64, reversed), new SortField("float", 
-				        SortFieldType.SINGLE, reversed), new SortField("double", SortFieldType.DOUBLE,

-				            reversed), new SortField("intdocvalues", SortFieldType.INT32, reversed),
new SortField
-				                ("floatdocvalues", SortFieldType.SINGLE, reversed), new SortField("score",
SortFieldType.SCORE) };
-                //TODO: Add Shuffle extension
-                //Collections.Shuffle(Arrays.AsList(fields), Random());
+				{
+                    new SortField("int", SortFieldType.INT32, reversed),
+                    new SortField("long", SortFieldType.INT64, reversed),
+                    new SortField("float", SortFieldType.SINGLE, reversed),
+                    new SortField("double", SortFieldType.DOUBLE, reversed),
+                    new SortField("intdocvalues", SortFieldType.INT32, reversed),
+                    new SortField("floatdocvalues", SortFieldType.SINGLE, reversed),
+                    new SortField("score", SortFieldType.SCORE)
+                };
+                Collections.Shuffle(Arrays.AsList(fields), Random());
                 int numSorts = TestUtil.NextInt(Random(), 1, fields.Length);
                 AssertQuery(query, filter, new Sort(Arrays.CopyOfRange(fields, 0, numSorts)));
             }
@@ -129,10 +130,11 @@ namespace Lucene.Net.Expressions
         internal virtual void AssertQuery(Query query, Filter filter, Sort sort)
         {
             int size = TestUtil.NextInt(Random(), 1, searcher.IndexReader.MaxDoc / 5);
-            TopDocs expected = searcher.Search(query, filter, size, sort, Random().NextBoolean
-                (), Random().NextBoolean());
+            TopDocs expected = searcher.Search(query, filter, size, sort, Random().NextBoolean(),
Random().NextBoolean());
+
             // make our actual sort, mutating original by replacing some of the 
             // sortfields with equivalent expressions
+
             SortField[] original = sort.GetSort();
             SortField[] mutated = new SortField[original.Length];
             for (int i = 0; i < mutated.Length; i++)
@@ -152,15 +154,12 @@ namespace Lucene.Net.Expressions
                 }
             }
             Sort mutatedSort = new Sort(mutated);
-            TopDocs actual = searcher.Search(query, filter, size, mutatedSort, Random().NextBoolean
-                (), Random().NextBoolean());
+            TopDocs actual = searcher.Search(query, filter, size, mutatedSort, Random().NextBoolean(),
Random().NextBoolean());
             CheckHits.CheckEqual(query, expected.ScoreDocs, actual.ScoreDocs);
             if (size < actual.TotalHits)
             {
-                expected = searcher.SearchAfter(expected.ScoreDocs[size - 1], query, filter,
size
-                    , sort);
-                actual = searcher.SearchAfter(actual.ScoreDocs[size - 1], query, filter,
size, mutatedSort
-                    );
+                expected = searcher.SearchAfter(expected.ScoreDocs[size - 1], query, filter,
size, sort);
+                actual = searcher.SearchAfter(actual.ScoreDocs[size - 1], query, filter,
size, mutatedSort);
                 CheckHits.CheckEqual(query, expected.ScoreDocs, actual.ScoreDocs);
             }
         }


Mime
View raw message