lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [46/58] [abbrv] lucenenet git commit: Fixed several string comparison bugs in Grouping tests
Date Thu, 10 Nov 2016 11:48:00 GMT
Fixed several string comparison bugs in Grouping tests


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

Branch: refs/heads/master
Commit: 840c67b6562a29979ed4b5572ebaac1a4dd392b8
Parents: 7c01e88
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Sun Nov 6 20:29:33 2016 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Tue Nov 8 02:24:57 2016 +0700

----------------------------------------------------------------------
 .../AbstractGroupingTestCase.cs                   |  2 +-
 .../AllGroupHeadsCollectorTest.cs                 | 14 +++++++-------
 .../AllGroupsCollectorTest.cs                     |  2 +-
 .../DistinctValuesCollectorTest.cs                |  4 ++--
 .../GroupFacetCollectorTest.cs                    | 16 ++++++++--------
 .../GroupingSearchTest.cs                         |  2 +-
 src/Lucene.Net.Tests.Grouping/TestGrouping.cs     | 18 +++++++++---------
 7 files changed, 29 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/840c67b6/src/Lucene.Net.Tests.Grouping/AbstractGroupingTestCase.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Grouping/AbstractGroupingTestCase.cs b/src/Lucene.Net.Tests.Grouping/AbstractGroupingTestCase.cs
index 4cc29e3..d4cd062 100644
--- a/src/Lucene.Net.Tests.Grouping/AbstractGroupingTestCase.cs
+++ b/src/Lucene.Net.Tests.Grouping/AbstractGroupingTestCase.cs
@@ -23,7 +23,7 @@ namespace Lucene.Net.Search.Grouping
                 // groups.
                 randomValue = TestUtil.RandomRealisticUnicodeString(Random());
                 //randomValue = TestUtil.randomSimpleString(random());
-            } while ("".equals(randomValue));
+            } while ("".Equals(randomValue, StringComparison.Ordinal));
             return randomValue;
         }
     }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/840c67b6/src/Lucene.Net.Tests.Grouping/AllGroupHeadsCollectorTest.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Grouping/AllGroupHeadsCollectorTest.cs b/src/Lucene.Net.Tests.Grouping/AllGroupHeadsCollectorTest.cs
index 80ed421..6b7c06a 100644
--- a/src/Lucene.Net.Tests.Grouping/AllGroupHeadsCollectorTest.cs
+++ b/src/Lucene.Net.Tests.Grouping/AllGroupHeadsCollectorTest.cs
@@ -37,7 +37,7 @@ namespace Lucene.Net.Search.Grouping
             dir,
             NewIndexWriterConfig(TEST_VERSION_CURRENT,
                 new MockAnalyzer(Random())).SetMergePolicy(NewLogMergePolicy()));
-            bool canUseIDV = !"Lucene3x".equals(w.w.Config.Codec.Name);
+            bool canUseIDV = !"Lucene3x".Equals(w.w.Config.Codec.Name, StringComparison.Ordinal);
             DocValuesType_e valueType = vts[Random().nextInt(vts.Length)];
 
             // 0
@@ -171,7 +171,7 @@ namespace Lucene.Net.Search.Grouping
                         // B/c of DV based impl we can't see the difference between an empty
string and a null value.
                         // For that reason we don't generate empty string groups.
                         randomValue = TestUtil.RandomRealisticUnicodeString(Random());
-                    } while ("".equals(randomValue));
+                    } while ("".Equals(randomValue, StringComparison.Ordinal));
                     groups.Add(new BytesRef(randomValue));
                 }
                 string[] contentStrings = new string[TestUtil.NextInt(Random(), 2, 20)];
@@ -201,7 +201,7 @@ namespace Lucene.Net.Search.Grouping
                     dir,
                     NewIndexWriterConfig(TEST_VERSION_CURRENT,
                         new MockAnalyzer(Random())));
-                bool preFlex = "Lucene3x".equals(w.w.Config.Codec.Name);
+                bool preFlex = "Lucene3x".Equals(w.w.Config.Codec.Name, StringComparison.Ordinal);
                 bool canUseIDV = !preFlex;
                 DocValuesType_e valueType = vts[Random().nextInt(vts.Length)];
 
@@ -467,7 +467,7 @@ namespace Lucene.Net.Search.Grouping
             IDictionary<BytesRef, List<GroupDoc>> groupHeads = new HashMap<BytesRef,
List<GroupDoc>>();
             foreach (GroupDoc groupDoc in groupDocs)
             {
-                if (!groupDoc.content.StartsWith(searchTerm))
+                if (!groupDoc.content.StartsWith(searchTerm, StringComparison.Ordinal))
                 {
                     continue;
                 }
@@ -568,15 +568,15 @@ namespace Lucene.Net.Search.Grouping
                             cmp = sortByScoreOnly ? fieldIdToDocID[d1.id] - fieldIdToDocID[d2.id]
: 0;
                         }
                     }
-                    else if (sf.Field.equals("sort1"))
+                    else if (sf.Field.Equals("sort1", StringComparison.Ordinal))
                     {
                         cmp = d1.sort1.CompareTo(d2.sort1);
                     }
-                    else if (sf.Field.equals("sort2"))
+                    else if (sf.Field.Equals("sort2", StringComparison.Ordinal))
                     {
                         cmp = d1.sort2.CompareTo(d2.sort2);
                     }
-                    else if (sf.Field.equals("sort3"))
+                    else if (sf.Field.Equals("sort3", StringComparison.Ordinal))
                     {
                         cmp = d1.sort3.CompareTo(d2.sort3);
                     }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/840c67b6/src/Lucene.Net.Tests.Grouping/AllGroupsCollectorTest.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Grouping/AllGroupsCollectorTest.cs b/src/Lucene.Net.Tests.Grouping/AllGroupsCollectorTest.cs
index 32bdbc1..681c644 100644
--- a/src/Lucene.Net.Tests.Grouping/AllGroupsCollectorTest.cs
+++ b/src/Lucene.Net.Tests.Grouping/AllGroupsCollectorTest.cs
@@ -34,7 +34,7 @@ namespace Lucene.Net.Search.Grouping
                 dir,
                 NewIndexWriterConfig(TEST_VERSION_CURRENT,
                     new MockAnalyzer(Random())).SetMergePolicy(NewLogMergePolicy()));
-            bool canUseIDV = !"Lucene3x".equals(w.w.Config.Codec.Name);
+            bool canUseIDV = !"Lucene3x".Equals(w.w.Config.Codec.Name, StringComparison.Ordinal);
 
             // 0
             Document doc = new Document();

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/840c67b6/src/Lucene.Net.Tests.Grouping/DistinctValuesCollectorTest.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Grouping/DistinctValuesCollectorTest.cs b/src/Lucene.Net.Tests.Grouping/DistinctValuesCollectorTest.cs
index 58fae2c..24beb86 100644
--- a/src/Lucene.Net.Tests.Grouping/DistinctValuesCollectorTest.cs
+++ b/src/Lucene.Net.Tests.Grouping/DistinctValuesCollectorTest.cs
@@ -71,7 +71,7 @@ namespace Lucene.Net.Search.Grouping
                 dir,
                 NewIndexWriterConfig(TEST_VERSION_CURRENT,
                     new MockAnalyzer(random)).SetMergePolicy(NewLogMergePolicy()));
-            bool canUseDV = !"Lucene3x".equals(w.w.Config.Codec.Name);
+            bool canUseDV = !"Lucene3x".Equals(w.w.Config.Codec.Name, StringComparison.Ordinal);
             FieldInfo.DocValuesType_e? dvType = canUseDV ? dvTypes[random.nextInt(dvTypes.Length)]
: (FieldInfo.DocValuesType_e?)null;
 
             Document doc = new Document();
@@ -522,7 +522,7 @@ namespace Lucene.Net.Search.Grouping
                 new MockAnalyzer(random)).SetMergePolicy(NewLogMergePolicy())
               );
 
-            bool canUseDV = !"Lucene3x".equals(w.w.Config.Codec.Name);
+            bool canUseDV = !"Lucene3x".Equals(w.w.Config.Codec.Name, StringComparison.Ordinal);
             FieldInfo.DocValuesType_e? dvType = canUseDV ? dvTypes[random.nextInt(dvTypes.Length)]
: (FieldInfo.DocValuesType_e?)null;
 
             int numDocs = 86 + random.nextInt(1087) * RANDOM_MULTIPLIER;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/840c67b6/src/Lucene.Net.Tests.Grouping/GroupFacetCollectorTest.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Grouping/GroupFacetCollectorTest.cs b/src/Lucene.Net.Tests.Grouping/GroupFacetCollectorTest.cs
index 8a01ee0..a8f191d 100644
--- a/src/Lucene.Net.Tests.Grouping/GroupFacetCollectorTest.cs
+++ b/src/Lucene.Net.Tests.Grouping/GroupFacetCollectorTest.cs
@@ -29,7 +29,7 @@ namespace Lucene.Net.Search.Grouping
                 dir,
                 NewIndexWriterConfig(TEST_VERSION_CURRENT,
                     new MockAnalyzer(Random())).SetMergePolicy(NewLogMergePolicy()));
-            bool canUseDV = !"Lucene3x".equals(w.w.Config.Codec.Name);
+            bool canUseDV = !"Lucene3x".Equals(w.w.Config.Codec.Name, StringComparison.Ordinal);
             bool useDv = canUseDV && Random().nextBoolean();
 
             // 0
@@ -542,7 +542,7 @@ namespace Lucene.Net.Search.Grouping
                     new MockAnalyzer(random)
                 )
             );
-            bool canUseDV = !"Lucene3x".equals(writer.w.Config.Codec.Name);
+            bool canUseDV = !"Lucene3x".Equals(writer.w.Config.Codec.Name, StringComparison.Ordinal);
             bool useDv = canUseDV && !multipleFacetValuesPerDocument && random.nextBoolean();
 
             Document doc = new Document();
@@ -647,8 +647,8 @@ namespace Lucene.Net.Search.Grouping
                 {
                     if (useDv)
                     {
-                        String facetValue = facetValues[random.nextInt(facetValues.size())];
-                        uniqueFacetValues.add(facetValue);
+                        string facetValue = facetValues[random.nextInt(facetValues.size())];
+                        uniqueFacetValues.Add(facetValue);
                         if (!facetToGroups.ContainsKey(facetValue))
                         {
                             facetToGroups[facetValue] = new HashSet<string>();
@@ -668,7 +668,7 @@ namespace Lucene.Net.Search.Grouping
                         foreach (Field facetField in facetFields)
                         {
                             string facetValue = facetValues[random.nextInt(facetValues.size())];
-                            uniqueFacetValues.add(facetValue);
+                            uniqueFacetValues.Add(facetValue);
                             if (!facetToGroups.ContainsKey(facetValue))
                             {
                                 facetToGroups[facetValue] = new HashSet<string>();
@@ -686,7 +686,7 @@ namespace Lucene.Net.Search.Grouping
                 }
                 else
                 {
-                    uniqueFacetValues.add(null);
+                    uniqueFacetValues.Add(null);
                     if (!facetToGroups.ContainsKey(null))
                     {
                         facetToGroups.Put(null, new HashSet<string>());
@@ -783,7 +783,7 @@ namespace Lucene.Net.Search.Grouping
                 facetValues = new HashSet<string>();
                 foreach (string facetValue in context.facetValues)
                 {
-                    if (facetValue != null && facetValue.StartsWith(facetPrefix))
+                    if (facetValue != null && facetValue.StartsWith(facetPrefix,
StringComparison.Ordinal))
                     {
                         facetValues.add(facetValue);
                     }
@@ -865,7 +865,7 @@ namespace Lucene.Net.Search.Grouping
         {
             BytesRef facetPrefixBR = facetPrefix == null ? null : new BytesRef(facetPrefix);
             // DocValues cannot be multi-valued:
-            Debug.Assert(!multipleFacetsPerDocument || !groupField.EndsWith("_dv"));
+            Debug.Assert(!multipleFacetsPerDocument || !groupField.EndsWith("_dv", StringComparison.Ordinal));
             return TermGroupFacetCollector.CreateTermGroupFacetCollector(groupField, facetField,
multipleFacetsPerDocument, facetPrefixBR, Random().nextInt(1024));
         }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/840c67b6/src/Lucene.Net.Tests.Grouping/GroupingSearchTest.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Grouping/GroupingSearchTest.cs b/src/Lucene.Net.Tests.Grouping/GroupingSearchTest.cs
index 0b80e2e..2971a52 100644
--- a/src/Lucene.Net.Tests.Grouping/GroupingSearchTest.cs
+++ b/src/Lucene.Net.Tests.Grouping/GroupingSearchTest.cs
@@ -31,7 +31,7 @@ namespace Lucene.Net.Search.Grouping
                 dir,
                 NewIndexWriterConfig(TEST_VERSION_CURRENT,
                     new MockAnalyzer(Random())).SetMergePolicy(NewLogMergePolicy()));
-            bool canUseIDV = !"Lucene3x".equals(w.w.Config.Codec.Name);
+            bool canUseIDV = !"Lucene3x".Equals(w.w.Config.Codec.Name, StringComparison.Ordinal);
             List<Document> documents = new List<Document>();
             // 0
             Document doc = new Document();

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/840c67b6/src/Lucene.Net.Tests.Grouping/TestGrouping.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Grouping/TestGrouping.cs b/src/Lucene.Net.Tests.Grouping/TestGrouping.cs
index 8a45bd5..2291a74 100644
--- a/src/Lucene.Net.Tests.Grouping/TestGrouping.cs
+++ b/src/Lucene.Net.Tests.Grouping/TestGrouping.cs
@@ -41,7 +41,7 @@ namespace Lucene.Net.Search.Grouping
                                        dir,
                                        NewIndexWriterConfig(TEST_VERSION_CURRENT,
                                                             new MockAnalyzer(Random())).SetMergePolicy(NewLogMergePolicy()));
-            bool canUseIDV = !"Lucene3x".equals(w.w.Config.Codec.Name);
+            bool canUseIDV = !"Lucene3x".Equals(w.w.Config.Codec.Name, StringComparison.Ordinal);
             // 0
             Document doc = new Document();
             AddGroupField(doc, groupField, "author1", canUseIDV);
@@ -448,11 +448,11 @@ namespace Lucene.Net.Search.Grouping
                             cmp = 0;
                         }
                     }
-                    else if (sf.Field.equals("sort1"))
+                    else if (sf.Field.Equals("sort1", StringComparison.Ordinal))
                     {
                         cmp = d1.sort1.CompareTo(d2.sort1);
                     }
-                    else if (sf.Field.equals("sort2"))
+                    else if (sf.Field.Equals("sort2", StringComparison.Ordinal))
                     {
                         cmp = d1.sort2.CompareTo(d2.sort2);
                     }
@@ -539,11 +539,11 @@ namespace Lucene.Net.Search.Grouping
                 {
                     c = new float?(d.score);
                 }
-                else if (sf.Field.equals("sort1"))
+                else if (sf.Field.Equals("sort1", StringComparison.Ordinal))
                 {
                     c = d.sort1;
                 }
-                else if (sf.Field.equals("sort2"))
+                else if (sf.Field.Equals("sort2", StringComparison.Ordinal))
                 {
                     c = d.sort2;
                 }
@@ -597,7 +597,7 @@ namespace Lucene.Net.Search.Grouping
             foreach (GroupDoc d in groupDocs)
             {
                 // TODO: would be better to filter by searchTerm before sorting!
-                if (!d.content.StartsWith(searchTerm))
+                if (!d.content.StartsWith(searchTerm, StringComparison.Ordinal))
                 {
                     continue;
                 }
@@ -823,7 +823,7 @@ namespace Lucene.Net.Search.Grouping
                         // groups.
                         randomValue = TestUtil.RandomRealisticUnicodeString(Random());
                         //randomValue = TestUtil.RandomSimpleString(Random());
-                    } while ("".equals(randomValue));
+                    } while ("".Equals(randomValue, StringComparison.Ordinal));
 
                     groups.Add(new BytesRef(randomValue));
                 }
@@ -854,7 +854,7 @@ namespace Lucene.Net.Search.Grouping
                                                             dir,
                                                             NewIndexWriterConfig(TEST_VERSION_CURRENT,
                                                                                  new MockAnalyzer(Random())));
-                bool preFlex = "Lucene3x".equals(w.w.Config.Codec.Name);
+                bool preFlex = "Lucene3x".Equals(w.w.Config.Codec.Name, StringComparison.Ordinal);
                 bool canUseIDV = !preFlex;
 
                 Document doc = new Document();
@@ -1329,7 +1329,7 @@ namespace Lucene.Net.Search.Grouping
                             }
                         }
 
-                        AssertEquals(docIDToID, expectedGroups, groupsResult, true, true,
true, getScores, groupField.EndsWith("_dv"));
+                        AssertEquals(docIDToID, expectedGroups, groupsResult, true, true,
true, getScores, groupField.EndsWith("_dv", StringComparison.Ordinal));
 
                         // Confirm merged shards match:
                         AssertEquals(docIDToID, expectedGroups, topGroupsShards, true, false,
fillFields, getScores, idvBasedImplsUsedSharded.value);


Mime
View raw message