You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2020/06/17 19:01:05 UTC
[lucenenet] 01/04: PERFORMANCE: Boxing issue causing issue with
some unit tests that were using AreEqual with bool. Added overloads of
AreEqual that accept bool to cover the project systemically without
changing tests. (#261, #295)
This is an automated email from the ASF dual-hosted git repository.
nightowl888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git
commit a54545d57e9c4370bec46282e7597e252653e743
Author: Shad Storhaug <sh...@shadstorhaug.com>
AuthorDate: Wed Jun 17 19:32:59 2020 +0700
PERFORMANCE: Boxing issue causing issue with some unit tests that were using AreEqual with bool. Added overloads of AreEqual that accept bool to cover the project systemically without changing tests. (#261, #295)
---
.../Support/TestFramework/Assert.cs | 40 ++++++++++++++++++++++
.../Support/TestFramework/Assert.cs | 40 ++++++++++++++++++++++
.../Support/TestFramework/Assert.cs | 40 ++++++++++++++++++++++
.../Support/JavaCompatibility/LuceneTestCase.cs | 10 ++++++
4 files changed, 130 insertions(+)
diff --git a/src/Lucene.Net.TestFramework.MSTest/Support/TestFramework/Assert.cs b/src/Lucene.Net.TestFramework.MSTest/Support/TestFramework/Assert.cs
index a0c688c..5570ff3 100644
--- a/src/Lucene.Net.TestFramework.MSTest/Support/TestFramework/Assert.cs
+++ b/src/Lucene.Net.TestFramework.MSTest/Support/TestFramework/Assert.cs
@@ -78,6 +78,46 @@ namespace Lucene.Net.TestFramework
{
MSTest.Assert.AreEqual(expected, actual, message, args);
}
+ //
+ // Summary:
+ // Verifies that two objects are equal. Two objects are considered equal if both
+ // are null, or if both have the same value. NUnit has special semantics for some
+ // object types. If they are not equal an NUnit.Framework.AssertionException is
+ // thrown.
+ //
+ // Parameters:
+ // expected:
+ // The value that is expected
+ //
+ // actual:
+ // The actual value
+ public static void AreEqual(bool expected, bool actual)
+ {
+ MSTest.Assert.IsTrue(expected.Equals(actual));
+ }
+ //
+ // Summary:
+ // Verifies that two objects are equal. Two objects are considered equal if both
+ // are null, or if both have the same value. NUnit has special semantics for some
+ // object types. If they are not equal an NUnit.Framework.AssertionException is
+ // thrown.
+ //
+ // Parameters:
+ // expected:
+ // The value that is expected
+ //
+ // actual:
+ // The actual value
+ //
+ // message:
+ // The message to display in case of failure
+ //
+ // args:
+ // Array of objects to be used in formatting the message
+ public static void AreEqual(bool expected, bool actual, string message, params object[] args)
+ {
+ MSTest.Assert.IsTrue(expected.Equals(actual), message, args);
+ }
//
// Summary:
// Verifies that two doubles are equal considering a delta. If the expected value
diff --git a/src/Lucene.Net.TestFramework.NUnit/Support/TestFramework/Assert.cs b/src/Lucene.Net.TestFramework.NUnit/Support/TestFramework/Assert.cs
index 42a1bed..428e476 100644
--- a/src/Lucene.Net.TestFramework.NUnit/Support/TestFramework/Assert.cs
+++ b/src/Lucene.Net.TestFramework.NUnit/Support/TestFramework/Assert.cs
@@ -80,6 +80,46 @@ namespace Lucene.Net.TestFramework
}
//
// Summary:
+ // Verifies that two objects are equal. Two objects are considered equal if both
+ // are null, or if both have the same value. NUnit has special semantics for some
+ // object types. If they are not equal an NUnit.Framework.AssertionException is
+ // thrown.
+ //
+ // Parameters:
+ // expected:
+ // The value that is expected
+ //
+ // actual:
+ // The actual value
+ public static void AreEqual(bool expected, bool actual)
+ {
+ _NUnit.Assert.IsTrue(expected.Equals(actual));
+ }
+ //
+ // Summary:
+ // Verifies that two objects are equal. Two objects are considered equal if both
+ // are null, or if both have the same value. NUnit has special semantics for some
+ // object types. If they are not equal an NUnit.Framework.AssertionException is
+ // thrown.
+ //
+ // Parameters:
+ // expected:
+ // The value that is expected
+ //
+ // actual:
+ // The actual value
+ //
+ // message:
+ // The message to display in case of failure
+ //
+ // args:
+ // Array of objects to be used in formatting the message
+ public static void AreEqual(bool expected, bool actual, string message, params object[] args)
+ {
+ _NUnit.Assert.IsTrue(expected.Equals(actual), message, args);
+ }
+ //
+ // Summary:
// Verifies that two doubles are equal considering a delta. If the expected value
// is infinity then the delta value is ignored. If they are not equal then an NUnit.Framework.AssertionException
// is thrown.
diff --git a/src/Lucene.Net.TestFramework.xUnit/Support/TestFramework/Assert.cs b/src/Lucene.Net.TestFramework.xUnit/Support/TestFramework/Assert.cs
index e086675..51c00b9 100644
--- a/src/Lucene.Net.TestFramework.xUnit/Support/TestFramework/Assert.cs
+++ b/src/Lucene.Net.TestFramework.xUnit/Support/TestFramework/Assert.cs
@@ -77,6 +77,46 @@ namespace Lucene.Net.TestFramework
{
Xunit.Assert.True(object.Equals(expected, actual), FormatMessage(message, args));
}
+ //
+ // Summary:
+ // Verifies that two objects are equal. Two objects are considered equal if both
+ // are null, or if both have the same value. NUnit has special semantics for some
+ // object types. If they are not equal an NUnit.Framework.AssertionException is
+ // thrown.
+ //
+ // Parameters:
+ // expected:
+ // The value that is expected
+ //
+ // actual:
+ // The actual value
+ public static void AreEqual(bool expected, bool actual)
+ {
+ Xunit.Assert.True(expected.Equals(actual));
+ }
+ //
+ // Summary:
+ // Verifies that two objects are equal. Two objects are considered equal if both
+ // are null, or if both have the same value. NUnit has special semantics for some
+ // object types. If they are not equal an NUnit.Framework.AssertionException is
+ // thrown.
+ //
+ // Parameters:
+ // expected:
+ // The value that is expected
+ //
+ // actual:
+ // The actual value
+ //
+ // message:
+ // The message to display in case of failure
+ //
+ // args:
+ // Array of objects to be used in formatting the message
+ public static void AreEqual(bool expected, bool actual, string message, params object[] args)
+ {
+ Xunit.Assert.True(expected.Equals(actual), FormatMessage(message, args));
+ }
//
// Summary:
// Verifies that two doubles are equal considering a delta. If the expected value
diff --git a/src/Lucene.Net.TestFramework/Support/JavaCompatibility/LuceneTestCase.cs b/src/Lucene.Net.TestFramework/Support/JavaCompatibility/LuceneTestCase.cs
index 8442531..aaca9df 100644
--- a/src/Lucene.Net.TestFramework/Support/JavaCompatibility/LuceneTestCase.cs
+++ b/src/Lucene.Net.TestFramework/Support/JavaCompatibility/LuceneTestCase.cs
@@ -78,6 +78,16 @@ namespace Lucene.Net.Util
Assert.AreEqual(expected, actual, message);
}
+ internal static void assertEquals(bool expected, bool actual)
+ {
+ Assert.AreEqual(expected, actual);
+ }
+
+ internal static void assertEquals(string message, bool expected, bool actual)
+ {
+ Assert.AreEqual(expected, actual, message);
+ }
+
internal static void assertEquals(long expected, long actual)
{
Assert.AreEqual(expected, actual);