lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [1/2] lucenenet git commit: Make some test failures easier to catch and understand
Date Wed, 31 Dec 2014 19:36:50 GMT
Repository: lucenenet
Updated Branches:
  refs/heads/master 56049f927 -> 48c00dbd4


Make some test failures easier to catch and understand


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

Branch: refs/heads/master
Commit: b0e9276ee430daf224e4c9a130e650eca91217fb
Parents: 56049f9
Author: Itamar Syn-Hershko <itamar@code972.com>
Authored: Wed Dec 31 21:29:38 2014 +0200
Committer: Itamar Syn-Hershko <itamar@code972.com>
Committed: Wed Dec 31 21:29:38 2014 +0200

----------------------------------------------------------------------
 src/Lucene.Net.TestFramework/Search/AssertingQuery.cs  | 9 ++++++---
 src/Lucene.Net.Tests/core/Search/TestAutomatonQuery.cs | 4 +++-
 src/Lucene.Net.Tests/core/Store/TestDirectory.cs       | 4 ++--
 3 files changed, 11 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b0e9276e/src/Lucene.Net.TestFramework/Search/AssertingQuery.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Search/AssertingQuery.cs b/src/Lucene.Net.TestFramework/Search/AssertingQuery.cs
index 97eb685..bd2651c 100644
--- a/src/Lucene.Net.TestFramework/Search/AssertingQuery.cs
+++ b/src/Lucene.Net.TestFramework/Search/AssertingQuery.cs
@@ -1,4 +1,5 @@
 using System;
+using System.Diagnostics;
 
 namespace Lucene.Net.Search
 {
@@ -32,9 +33,11 @@ namespace Lucene.Net.Search
         private readonly Query @in;
 
         /// <summary>
-        /// Sole constructor. </summary>
+        /// Sole constructor.
+        /// </summary>
         public AssertingQuery(Random random, Query @in)
         {
+            Debug.Assert(@in != null);
             this.Random = random;
             this.@in = @in;
         }
@@ -63,11 +66,11 @@ namespace Lucene.Net.Search
 
         public override bool Equals(object obj)
         {
-            if (obj == null || !(obj is AssertingQuery))
+            var that = obj as AssertingQuery;
+            if (that == null)
             {
                 return false;
             }
-            AssertingQuery that = (AssertingQuery)obj;
             return this.@in.Equals(that.@in);
         }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b0e9276e/src/Lucene.Net.Tests/core/Search/TestAutomatonQuery.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Search/TestAutomatonQuery.cs b/src/Lucene.Net.Tests/core/Search/TestAutomatonQuery.cs
index ee35231..edbbded 100644
--- a/src/Lucene.Net.Tests/core/Search/TestAutomatonQuery.cs
+++ b/src/Lucene.Net.Tests/core/Search/TestAutomatonQuery.cs
@@ -202,7 +202,9 @@ namespace Lucene.Net.Search
             Automaton prefixAutomaton = BasicOperations.Concatenate(pfx, BasicAutomata.MakeAnyString());
             AutomatonQuery aq = new AutomatonQuery(NewTerm("bogus"), prefixAutomaton);
             Terms terms = MultiFields.GetTerms(Searcher.IndexReader, FN);
-            Assert.IsTrue(aq.GetTermsEnum(terms) is PrefixTermsEnum);
+
+            var en = aq.GetTermsEnum(terms);
+            Assert.IsTrue(en is PrefixTermsEnum, "Expected type PrefixTermEnum but was {0}",
en.GetType().Name);
             Assert.AreEqual(3, AutomatonQueryNrHits(aq));
         }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b0e9276e/src/Lucene.Net.Tests/core/Store/TestDirectory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Store/TestDirectory.cs b/src/Lucene.Net.Tests/core/Store/TestDirectory.cs
index 501bc39..ac4a4d9 100644
--- a/src/Lucene.Net.Tests/core/Store/TestDirectory.cs
+++ b/src/Lucene.Net.Tests/core/Store/TestDirectory.cs
@@ -375,9 +375,9 @@ namespace Lucene.Net.Store
                 newDir.Create();
                 newDir.Delete();
             }
-            catch (Exception)
+            catch (Exception e)
             {
-                Assert.Fail("Deletion of new Directory should never fail.");
+                Assert.Fail("Deletion of new Directory should never fail.\nException thrown:
{0}", e);
             }
 
             // directory is empty


Mime
View raw message