Skip to content

Commit

Permalink
SWEEP: Lucene.Net.Util: Added using for Assert class to ensure our st…
Browse files Browse the repository at this point in the history
…rongly-typed overloads are being called to reduce boxing. (addresses apache#295, apache#261)
  • Loading branch information
NightOwl888 committed Jun 23, 2020
1 parent 4aac3cb commit acd6722
Show file tree
Hide file tree
Showing 32 changed files with 42 additions and 26 deletions.
1 change: 1 addition & 0 deletions src/Lucene.Net.Tests/Util/BaseSortTestCase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Lucene.Net.Support;
using NUnit.Framework;
using System;
using Assert = Lucene.Net.TestFramework.Assert;

namespace Lucene.Net.Util
{
Expand Down
2 changes: 1 addition & 1 deletion src/Lucene.Net.Tests/Util/TestArrayUtil.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Lucene.Net.Randomized.Generators;
using Lucene.Net.Support;
using NUnit.Framework;
using System;
using Assert = Lucene.Net.TestFramework.Assert;
using Console = Lucene.Net.Util.SystemConsole;

namespace Lucene.Net.Util
Expand Down
6 changes: 3 additions & 3 deletions src/Lucene.Net.Tests/Util/TestAttributeSource.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using Lucene.Net.Analysis.TokenAttributes;
using NUnit.Framework;
using System;
using System.Collections;
using System.Collections.Generic;
using Assert = Lucene.Net.TestFramework.Assert;
using FlagsAttribute = Lucene.Net.Analysis.TokenAttributes.FlagsAttribute;

namespace Lucene.Net.Util
{
using Lucene.Net.Analysis.TokenAttributes;

/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
Expand Down
1 change: 0 additions & 1 deletion src/Lucene.Net.Tests/Util/TestBroadWord.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using J2N.Numerics;
using Lucene.Net.Attributes;
using Lucene.Net.Support;
using NUnit.Framework;
using Assert = Lucene.Net.TestFramework.Assert;

Expand Down
1 change: 0 additions & 1 deletion src/Lucene.Net.Tests/Util/TestByteBlockPool.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Lucene.Net.Randomized.Generators;
using NUnit.Framework;
using System.Collections.Generic;
using Assert = Lucene.Net.TestFramework.Assert;
Expand Down
1 change: 1 addition & 0 deletions src/Lucene.Net.Tests/Util/TestBytesRef.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using J2N.Text;
using Lucene.Net.Attributes;
using NUnit.Framework;
using Assert = Lucene.Net.TestFramework.Assert;

namespace Lucene.Net.Util
{
Expand Down
4 changes: 2 additions & 2 deletions src/Lucene.Net.Tests/Util/TestBytesRefArray.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Lucene.Net.Randomized.Generators;
using NUnit.Framework;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using Assert = Lucene.Net.TestFramework.Assert;

namespace Lucene.Net.Util
{
Expand Down
1 change: 1 addition & 0 deletions src/Lucene.Net.Tests/Util/TestBytesRefHash.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Collections;
using System.Collections.Generic;
using JCG = J2N.Collections.Generic;
using Assert = Lucene.Net.TestFramework.Assert;

namespace Lucene.Net.Util
{
Expand Down
2 changes: 1 addition & 1 deletion src/Lucene.Net.Tests/Util/TestCharsRef.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using J2N.Text;
using Lucene.Net.Attributes;
//using Lucene.Net.Support;
using NUnit.Framework;
using System;
using System.Text;
using Assert = Lucene.Net.TestFramework.Assert;

namespace Lucene.Net.Util
{
Expand Down
16 changes: 7 additions & 9 deletions src/Lucene.Net.Tests/Util/TestCollectionUtil.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using Lucene.Net.Attributes;
using Lucene.Net.Support;
using NUnit.Framework;
using System;
using System.Collections;
using System.Collections.Generic;

namespace Lucene.Net.Util
Expand Down Expand Up @@ -46,39 +44,39 @@ public virtual void TestIntroSort()
IList<int> list1 = CreateRandomList(2000), list2 = new List<int>(list1);
CollectionUtil.IntroSort(list1);
list2.Sort();
Assert.AreEqual(list2, list1);
assertEquals(list2, list1);

list1 = CreateRandomList(2000);
list2 = new List<int>(list1);
CollectionUtil.IntroSort(list1, Collections.ReverseOrder<int>());
list2.Sort(Collections.ReverseOrder<int>());
Assert.AreEqual(list2, list1);
assertEquals(list2, list1);
// reverse back, so we can test that completely backwards sorted array (worst case) is working:
CollectionUtil.IntroSort(list1);
list2.Sort();
Assert.AreEqual(list2, list1);
assertEquals(list2, list1);
}
}

[Test, LongRunningTest]
[Test]
public virtual void TestTimSort()
{
for (int i = 0, c = AtLeast(500); i < c; i++)
{
IList<int> list1 = CreateRandomList(2000), list2 = new List<int>(list1);
CollectionUtil.TimSort(list1);
list2.Sort();
Assert.AreEqual(list2, list1);
assertEquals(list2, list1);

list1 = CreateRandomList(2000);
list2 = new List<int>(list1);
CollectionUtil.TimSort(list1, Collections.ReverseOrder<int>());
list2.Sort(Collections.ReverseOrder<int>());
Assert.AreEqual(list2, list1);
assertEquals(list2, list1);
// reverse back, so we can test that completely backwards sorted array (worst case) is working:
CollectionUtil.TimSort(list1);
list2.Sort();
Assert.AreEqual(list2, list1);
assertEquals(list2, list1);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/Lucene.Net.Tests/Util/TestFieldCacheSanityChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Globalization;
using System.IO;
using Assert = Lucene.Net.TestFramework.Assert;
using Console = Lucene.Net.Util.SystemConsole;

namespace Lucene.Net.Util
Expand Down
4 changes: 2 additions & 2 deletions src/Lucene.Net.Tests/Util/TestFilterIterator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
* limitations under the License.
*/

using Lucene.Net.Support;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using Assert = Lucene.Net.TestFramework.Assert;
using JCG = J2N.Collections.Generic;

namespace Lucene.Net.Util
{
[TestFixture]
public class TestFilterIterator : LuceneTestCase
{
private static readonly ISet<string> set = new JCG.SortedSet<string> { "a", "b", "c" };
private static readonly ISet<string> set = new JCG.SortedSet<string>(StringComparer.Ordinal) { "a", "b", "c" };

private static void AssertNoMore<T1>(IEnumerator<T1> it)
{
Expand Down
8 changes: 3 additions & 5 deletions src/Lucene.Net.Tests/Util/TestFixedBitSet.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using System;
using Lucene.Net.Attributes;
using Lucene.Net.Randomized.Generators;
using Lucene.Net.Support;
using NUnit.Framework;
using System;
using System.Collections;
using System.Linq;
using Assert = Lucene.Net.TestFramework.Assert;

/*
* Licensed to the Apache Software Foundation (ASF) under one or more
Expand All @@ -22,9 +23,6 @@
* limitations under the License.
*/

using System.Linq;
using Assert = Lucene.Net.TestFramework.Assert;

namespace Lucene.Net.Util
{
using DocIdSetIterator = Lucene.Net.Search.DocIdSetIterator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System;
using System.Globalization;
using System.Text;
using Assert = Lucene.Net.TestFramework.Assert;

namespace Lucene.Net.Util
{
Expand Down
1 change: 1 addition & 0 deletions src/Lucene.Net.Tests/Util/TestIntsRef.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NUnit.Framework;
using Assert = Lucene.Net.TestFramework.Assert;

namespace Lucene.Net.Util
{
Expand Down
2 changes: 1 addition & 1 deletion src/Lucene.Net.Tests/Util/TestLongBitSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

using System;
using Lucene.Net.Attributes;
using Lucene.Net.Randomized.Generators;
using Lucene.Net.Support;
using NUnit.Framework;
using System.Collections;
using Assert = Lucene.Net.TestFramework.Assert;

namespace Lucene.Net.Util
{
Expand Down
1 change: 1 addition & 0 deletions src/Lucene.Net.Tests/Util/TestMathUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using NUnit.Framework;
using System;
using System.Linq;
using Assert = Lucene.Net.TestFramework.Assert;

namespace Lucene.Net.Util
{
Expand Down
1 change: 1 addition & 0 deletions src/Lucene.Net.Tests/Util/TestMergedIterator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Assert = Lucene.Net.TestFramework.Assert;

namespace Lucene.Net.Util
{
Expand Down
1 change: 1 addition & 0 deletions src/Lucene.Net.Tests/Util/TestPForDeltaDocIdSet.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Lucene.Net.Support;
using NUnit.Framework;
using System.Collections;
using Assert = Lucene.Net.TestFramework.Assert;

namespace Lucene.Net.Util
{
Expand Down
1 change: 1 addition & 0 deletions src/Lucene.Net.Tests/Util/TestPriorityQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using NUnit.Framework;
using System;
using System.Collections.Generic;
using Assert = Lucene.Net.TestFramework.Assert;
using Console = Lucene.Net.Util.SystemConsole;

namespace Lucene.Net.Util
Expand Down
1 change: 1 addition & 0 deletions src/Lucene.Net.Tests/Util/TestQueryBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using NUnit.Framework;
using System;
using System.IO;
using Assert = Lucene.Net.TestFramework.Assert;

namespace Lucene.Net.Util
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Assert = Lucene.Net.TestFramework.Assert;
using JCG = J2N.Collections.Generic;

namespace Lucene.Net.Util
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Assert = Lucene.Net.TestFramework.Assert;
using JCG = J2N.Collections.Generic;

namespace Lucene.Net.Util
Expand Down
1 change: 1 addition & 0 deletions src/Lucene.Net.Tests/Util/TestRollingBuffer.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using NUnit.Framework;
using System;
using Assert = Lucene.Net.TestFramework.Assert;
using Console = Lucene.Net.Util.SystemConsole;

namespace Lucene.Net.Util
Expand Down
1 change: 1 addition & 0 deletions src/Lucene.Net.Tests/Util/TestSentinelIntSet.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using NUnit.Framework;
using System.Collections.Generic;
using Assert = Lucene.Net.TestFramework.Assert;
using JCG = J2N.Collections.Generic;

namespace Lucene.Net.Util
Expand Down
1 change: 1 addition & 0 deletions src/Lucene.Net.Tests/Util/TestSetOnce.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using System.Globalization;
using System.Threading;
using Assert = Lucene.Net.TestFramework.Assert;

namespace Lucene.Net.Util
{
Expand Down
1 change: 1 addition & 0 deletions src/Lucene.Net.Tests/Util/TestSloppyMath.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Lucene.Net.Randomized.Generators;
using NUnit.Framework;
using System;
using Assert = Lucene.Net.TestFramework.Assert;

namespace Lucene.Net.Util
{
Expand Down
1 change: 1 addition & 0 deletions src/Lucene.Net.Tests/Util/TestSmallFloat.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Lucene.Net.Support;
using NUnit.Framework;
using Assert = Lucene.Net.TestFramework.Assert;

namespace Lucene.Net.Util
{
Expand Down
1 change: 1 addition & 0 deletions src/Lucene.Net.Tests/Util/TestStringHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NUnit.Framework;
using Assert = Lucene.Net.TestFramework.Assert;

namespace Lucene.Net.Util
{
Expand Down
1 change: 1 addition & 0 deletions src/Lucene.Net.Tests/Util/TestUnicodeUtil.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using J2N;
using NUnit.Framework;
using System;
using Assert = Lucene.Net.TestFramework.Assert;
using Console = Lucene.Net.Util.SystemConsole;

namespace Lucene.Net.Util
Expand Down
1 change: 1 addition & 0 deletions src/Lucene.Net.Tests/Util/TestVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using System;
using System.Linq;
using System.Reflection;
using Assert = Lucene.Net.TestFramework.Assert;

namespace Lucene.Net.Util
{
Expand Down
1 change: 1 addition & 0 deletions src/Lucene.Net.Tests/Util/TestVirtualMethod.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using NUnit.Framework;
using System;
using Assert = Lucene.Net.TestFramework.Assert;

namespace Lucene.Net.Util
{
Expand Down

0 comments on commit acd6722

Please sign in to comment.