lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Itamar Syn-Hershko <ita...@code972.com>
Subject Re: [2/3] lucenenet git commit: Fixing some more tests by asserting on the right things
Date Wed, 07 Jan 2015 01:25:36 GMT
To all committers - notice this change

>From now on lets try using the Java style asserts and bring new variants as
needed, this will greatly improve the speed of which we work as well as
stability

Complete list of methods I added is here
https://github.com/apache/lucenenet/blob/master/src/Lucene.Net.TestFramework/JavaCompatibility/LuceneTestCase.cs

--

Itamar Syn-Hershko
http://code972.com | @synhershko <https://twitter.com/synhershko>
Freelance Developer & Consultant
Author of RavenDB in Action <http://manning.com/synhershko/>

On Wed, Jan 7, 2015 at 3:23 AM, <synhershko@apache.org> wrote:

> Fixing some more tests by asserting on the right things
>
> I've extended the test framework to support Java style asserts, and will
> bring more as needed. This will help porting tests in the future (less
> style changes), abstract away the testing framework, and most importantly
> make sure we don't assert differently than in the Java world
>
>
> Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
> Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/c9426e74
> Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/c9426e74
> Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/c9426e74
>
> Branch: refs/heads/master
> Commit: c9426e746c41c2498df6616753236c6899034d65
> Parents: f79148c
> Author: Itamar Syn-Hershko <itamar@code972.com>
> Authored: Wed Jan 7 03:22:47 2015 +0200
> Committer: Itamar Syn-Hershko <itamar@code972.com>
> Committed: Wed Jan 7 03:22:47 2015 +0200
>
> ----------------------------------------------------------------------
>  .../Index/BaseDocValuesFormatTestCase.cs              |  4 ++--
>  .../Index/BaseIndexFileFormatTestCase.cs              |  2 +-
>  .../JavaCompatibility/LuceneTestCase.cs               | 14 +++++++++++---
>  src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs   |  2 +-
>  4 files changed, 15 insertions(+), 7 deletions(-)
> ----------------------------------------------------------------------
>
>
>
> http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c9426e74/src/Lucene.Net.TestFramework/Index/BaseDocValuesFormatTestCase.cs
> ----------------------------------------------------------------------
> diff --git
> a/src/Lucene.Net.TestFramework/Index/BaseDocValuesFormatTestCase.cs
> b/src/Lucene.Net.TestFramework/Index/BaseDocValuesFormatTestCase.cs
> index 4e940ee..970805c 100644
> --- a/src/Lucene.Net.TestFramework/Index/BaseDocValuesFormatTestCase.cs
> +++ b/src/Lucene.Net.TestFramework/Index/BaseDocValuesFormatTestCase.cs
> @@ -1477,12 +1477,12 @@ namespace Lucene.Net.Index
>
>              // compare
>              DirectoryReader ir = DirectoryReader.Open(dir);
> -            foreach (AtomicReaderContext context in ir.Leaves)
> +            foreach (var context in ir.Leaves)
>              {
>                  AtomicReader r = context.AtomicReader;
>                  Bits expected = FieldCache.DEFAULT.GetDocsWithField(r,
> "indexed");
>                  Bits actual = FieldCache.DEFAULT.GetDocsWithField(r,
> "dv");
> -                Assert.AreEqual(expected, actual);
> +                AssertEquals(expected, actual);
>              }
>              ir.Dispose();
>              dir.Dispose();
>
>
> http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c9426e74/src/Lucene.Net.TestFramework/Index/BaseIndexFileFormatTestCase.cs
> ----------------------------------------------------------------------
> diff --git
> a/src/Lucene.Net.TestFramework/Index/BaseIndexFileFormatTestCase.cs
> b/src/Lucene.Net.TestFramework/Index/BaseIndexFileFormatTestCase.cs
> index 67e606c..2ce7711 100644
> --- a/src/Lucene.Net.TestFramework/Index/BaseIndexFileFormatTestCase.cs
> +++ b/src/Lucene.Net.TestFramework/Index/BaseIndexFileFormatTestCase.cs
> @@ -120,7 +120,7 @@ namespace Lucene.Net.Index
>              w.Commit();
>              w.Dispose();
>
> -            Assert.AreEqual(BytesUsedByExtension(dir),
> BytesUsedByExtension(dir2));
> +            assertEquals(BytesUsedByExtension(dir),
> BytesUsedByExtension(dir2));
>
>              reader.Dispose();
>              dir.Dispose();
>
>
> http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c9426e74/src/Lucene.Net.TestFramework/JavaCompatibility/LuceneTestCase.cs
> ----------------------------------------------------------------------
> diff --git
> a/src/Lucene.Net.TestFramework/JavaCompatibility/LuceneTestCase.cs
> b/src/Lucene.Net.TestFramework/JavaCompatibility/LuceneTestCase.cs
> index b2c23f5..9f8c484 100644
> --- a/src/Lucene.Net.TestFramework/JavaCompatibility/LuceneTestCase.cs
> +++ b/src/Lucene.Net.TestFramework/JavaCompatibility/LuceneTestCase.cs
> @@ -1,9 +1,8 @@
> -using System;
> -using System.Collections;
> +using System.Collections;
>  using System.Collections.Generic;
>  using NUnit.Framework;
>
> -namespace Lucene.Net
> +namespace Lucene.Net.Util
>  {
>      public abstract partial class LuceneTestCase
>      {
> @@ -57,6 +56,15 @@ namespace Lucene.Net
>              Assert.True(expected.SetEquals(actual), message);
>          }
>
> +        public static void assertEquals<T, S>(IDictionary<T, S> expected,
> IDictionary<T, S> actual)
> +        {
> +            Assert.AreEqual(expected.Count, actual.Count);
> +            foreach (var key in expected.Keys)
> +            {
> +                Assert.AreEqual(expected[key], actual[key]);
> +            }
> +        }
> +
>          public static void assertNotSame(object unexpected, object actual)
>          {
>              Assert.AreNotSame(unexpected, actual);
>
>
> http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c9426e74/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
> ----------------------------------------------------------------------
> diff --git a/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
> b/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
> index 66bf0ca..564b30a 100644
> --- a/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
> +++ b/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
> @@ -190,7 +190,7 @@ namespace Lucene.Net.Util
>      /// </ul>
>      /// </summary>
>      [TestFixture]
> -    public abstract class LuceneTestCase : Assert // Wait long for leaked
> threads to complete before failure. zk needs this. -  See LUCENE-3995 for
> rationale.
> +    public abstract partial class LuceneTestCase : Assert // Wait long
> for leaked threads to complete before failure. zk needs this. -  See
> LUCENE-3995 for rationale.
>      {
>          public static System.IO.FileInfo TEMP_DIR;
>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message