You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by cc...@apache.org on 2011/11/12 20:11:58 UTC

[Lucene.Net] svn commit: r1201305 - in /incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core: ./ Analysis/ Index/ Search/ Search/Function/ Search/Payloads/ Util/ Util/Cache/

Author: ccurrens
Date: Sat Nov 12 19:11:57 2011
New Revision: 1201305

URL: http://svn.apache.org/viewvc?rev=1201305&view=rev
Log:
Updated the rest of the tests in Util and Util/Cache.
Deleted tests irrelevant to 3.x

Removed:
    incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Analysis/TestCharacterCache.cs
    incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Analysis/TestTeeSinkTokenFilter.cs
    incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Analysis/TestTokenStreamBWComp.cs
    incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestIndexModifier.cs
    incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/Function/TestValueSource.cs
    incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/Payloads/TestBoostingTermQuery.cs
    incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/SampleComparable.cs
    incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestSearchHitsWithDeletions.cs
    incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestStressSort.cs
    incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestTimeLimitedCollector.cs
    incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/TestHitIterator.cs
Modified:
    incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/UpdatedTests.txt
    incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Util/Cache/TestSimpleLRUCache.cs
    incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Util/TestNumericUtils.cs
    incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Util/TestPriorityQueue.cs

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/UpdatedTests.txt
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/UpdatedTests.txt?rev=1201305&r1=1201304&r2=1201305&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/UpdatedTests.txt (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/UpdatedTests.txt Sat Nov 12 19:11:57 2011
@@ -1,7 +1,7 @@
 util\
 util\_TestUtil.java - DONE
 util\ArrayUtilTest.java - IDENTICAL
-util\English.java - Text files are different
+util\English.java - DONE
 util\util\util\LocalizedTestCase.java - DONE
 util\LuceneTestCase.java - DONE
 util\TestAttributeSource.java - DONE
@@ -9,12 +9,13 @@ util\util\TestBitVector.java - DONE
 util\TestCloseableThreadLocal.java - DONE? * Had to add type parameters to CloseableThreadLocal that java didn't require?
 util\TestFieldCacheSanityChecker.java - DONE
 util\TestIndexableBinaryStringTools.java - DONE
-util\TestNumericUtils.java - Text files are different
+util\TestNumericUtils.java - DONE
 util\TestOpenBitSet.java - IDENTICAL
-util\TestPriorityQueue.java - Text files are different
+util\TestPriorityQueue.java - DONE
 util\TestRamUsageEstimator.java - IDENTICAL
 util\TestSmallFloat.java - IDENTICAL
 util\TestSortedVIntList.java - IDENTICAL
 util\TestStringHelper.java - IDENTICAL
-util\TestStringIntern.java - Text files are different
-util\TestVersion.java - Right only: C:\SVN\apache\Lucene\lucene-3.0.3\src\test\org\apache\lucene\util
\ No newline at end of file
+util\TestStringIntern.java - DONE
+util\TestVersion.java - DONE
+util\cache\TestSimpleLRUCache.cs - DONE
\ No newline at end of file

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Util/Cache/TestSimpleLRUCache.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Util/Cache/TestSimpleLRUCache.cs?rev=1201305&r1=1201304&r2=1201305&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Util/Cache/TestSimpleLRUCache.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Util/Cache/TestSimpleLRUCache.cs Sat Nov 12 19:11:57 2011
@@ -32,45 +32,45 @@ namespace Lucene.Net.Util.Cache
 		public virtual void  TestLRUCache()
 		{
 			int n = 100;
-			System.Object dummy = new System.Object();
-			
-			Cache cache = new SimpleLRUCache(n);
+            object dummy = new object();
+
+            Cache<int, object> cache = new SimpleLRUCache<int, object>(n);
 			
 			for (int i = 0; i < n; i++)
 			{
-				cache.Put((System.Object) i, dummy);
+				cache.Put(i, dummy);
 			}
 			
 			// access every 2nd item in cache
 			for (int i = 0; i < n; i += 2)
 			{
-				Assert.IsNotNull(cache.Get((System.Object) i));
+				Assert.IsNotNull(cache.Get(i));
 			}
 			
 			// add n/2 elements to cache, the ones that weren't
 			// touched in the previous loop should now be thrown away
 			for (int i = n; i < n + (n / 2); i++)
 			{
-				cache.Put((System.Object) i, dummy);
+				cache.Put(i, dummy);
 			}
 			
 			// access every 4th item in cache
 			for (int i = 0; i < n; i += 4)
 			{
-				Assert.IsNotNull(cache.Get((System.Object) i));
+				Assert.IsNotNull(cache.Get(i));
 			}
 			
 			// add 3/4n elements to cache, the ones that weren't
 			// touched in the previous loops should now be thrown away
 			for (int i = n; i < n + (n * 3 / 4); i++)
 			{
-				cache.Put((System.Object) i, dummy);
+				cache.Put(i, dummy);
 			}
 			
 			// access every 4th item in cache
 			for (int i = 0; i < n; i += 4)
 			{
-				Assert.IsNotNull(cache.Get((System.Object) i));
+				Assert.IsNotNull(cache.Get(i));
 			}
 		}
 	}

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Util/TestNumericUtils.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Util/TestNumericUtils.cs?rev=1201305&r1=1201304&r2=1201305&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Util/TestNumericUtils.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Util/TestNumericUtils.cs Sat Nov 12 19:11:57 2011
@@ -88,11 +88,11 @@ namespace Lucene.Net.Util
 
 		private class AnonymousClassIntRangeBuilder:NumericUtils.IntRangeBuilder
 		{
-			public AnonymousClassIntRangeBuilder(int lower, int upper, bool useBitSet, Lucene.Net.Util.OpenBitSet bits, System.Collections.IEnumerator neededBounds, System.Collections.IEnumerator neededShifts,TestNumericUtils enclosingInstance)
+            public AnonymousClassIntRangeBuilder(int lower, int upper, bool useBitSet, Lucene.Net.Util.OpenBitSet bits, IEnumerator<int> neededBounds, IEnumerator<int> neededShifts, TestNumericUtils enclosingInstance)
 			{
                 InitBlock(lower, upper, useBitSet, bits, neededBounds, neededShifts,enclosingInstance);
 			}
-			private void  InitBlock(int lower, int upper, bool useBitSet, Lucene.Net.Util.OpenBitSet bits, System.Collections.IEnumerator neededBounds, System.Collections.IEnumerator neededShifts,TestNumericUtils enclosingInstance)
+            private void InitBlock(int lower, int upper, bool useBitSet, Lucene.Net.Util.OpenBitSet bits, IEnumerator<int> neededBounds, IEnumerator<int> neededShifts, TestNumericUtils enclosingInstance)
 			{
 				this.lower = lower;
 				this.upper = upper;
@@ -106,8 +106,8 @@ namespace Lucene.Net.Util
 			private int upper;
 			private bool useBitSet;
 			private Lucene.Net.Util.OpenBitSet bits;
-			private System.Collections.IEnumerator neededBounds;
-            private System.Collections.IEnumerator neededShifts;
+            private IEnumerator<int> neededBounds;
+            private IEnumerator<int> neededShifts;
 			private TestNumericUtils enclosingInstance;
 			public TestNumericUtils Enclosing_Instance
 			{
@@ -509,7 +509,7 @@ namespace Lucene.Net.Util
 		
 
 		/// <summary>Note: The neededBounds iterator must be unsigned (easier understanding what's happening) </summary>
-		protected internal virtual void  AssertIntRangeSplit(int lower, int upper, int precisionStep, bool useBitSet, System.Collections.IEnumerator neededBounds,System.Collections.IEnumerator neededShifts)
+		protected internal virtual void  AssertIntRangeSplit(int lower, int upper, int precisionStep, bool useBitSet, IEnumerator<int> neededBounds, IEnumerator<int> neededShifts)
 		{
 		    OpenBitSet bits = useBitSet ? new OpenBitSet(upper - lower + 1) : null;
 
@@ -527,32 +527,57 @@ namespace Lucene.Net.Util
 		public virtual void  TestSplitIntRange()
 		{
 			// a hard-coded "standard" range
-			AssertIntRangeSplit(- 5000, 9500, 4, true, new System.Collections.ArrayList(new System.Int32[]{0x7fffec78, 0x7fffec7f, unchecked((System.Int32) 0x80002510), unchecked((System.Int32) 0x8000251c), 0x7fffec8, 0x7fffecf, 0x8000250, 0x8000250, 0x7fffed, 0x7fffef, 0x800020, 0x800024, 0x7ffff, 0x80001}).GetEnumerator(),new int[]{0,0,4,4,8,8,12}.GetEnumerator());
+            AssertIntRangeSplit(- 5000, 9500, 4, true,
+                                new System.Int32[]
+                                    {
+                                        0x7fffec78, 0x7fffec7f, unchecked((System.Int32) 0x80002510),
+                                        unchecked((System.Int32) 0x8000251c), 0x7fffec8, 0x7fffecf, 0x8000250, 0x8000250,
+                                        0x7fffed, 0x7fffef, 0x800020, 0x800024, 0x7ffff, 0x80001
+                                    }.Cast<int>().GetEnumerator
+                                    (), new int[] { 0, 0, 4, 4, 8, 8, 12 }.Cast<int>().GetEnumerator());
 			
 			// the same with no range splitting
-            AssertIntRangeSplit(-5000, 9500, 32, true, new System.Collections.ArrayList(new System.Int32[] { 0x7fffec78, unchecked((System.Int32)0x8000251c) }).GetEnumerator(), new int[] { 0}.GetEnumerator());
+            AssertIntRangeSplit(-5000, 9500, 32, true,
+                                new System.Int32[] {0x7fffec78, unchecked((System.Int32) 0x8000251c)}.Cast<int>().
+                                    GetEnumerator(), new int[] { 0 }.Cast<int>().GetEnumerator());
 			
 			// this tests optimized range splitting, if one of the inner bounds
 			// is also the bound of the next lower precision, it should be used completely
-            AssertIntRangeSplit(0, 1024 + 63, 4, true, new System.Collections.ArrayList(new System.Int32[] { 0x8000040, 0x8000043, 0x800000, 0x800003 }).GetEnumerator(), new int[] {4,8 }.GetEnumerator());
+            AssertIntRangeSplit(0, 1024 + 63, 4, true,
+                                new System.Int32[] {0x8000040, 0x8000043, 0x800000, 0x800003}.Cast<int>().GetEnumerator(),
+                                new int[] { 4, 8 }.Cast<int>().GetEnumerator());
 			
 			// the full int range should only consist of a lowest precision range; no bitset testing here, as too much memory needed :-)
-            AssertIntRangeSplit(System.Int32.MinValue, System.Int32.MaxValue, 8, false, new System.Collections.ArrayList(new System.Int32[] { 0x00, 0xff }).GetEnumerator(), new int[] { 24}.GetEnumerator());
+            AssertIntRangeSplit(System.Int32.MinValue, System.Int32.MaxValue, 8, false,
+                                new System.Int32[] {0x00, 0xff}.Cast<int>().GetEnumerator(),
+                                new int[] { 24 }.Cast<int>().GetEnumerator());
 			
 			// the same with precisionStep=4
-            AssertIntRangeSplit(System.Int32.MinValue, System.Int32.MaxValue, 4, false, new System.Collections.ArrayList(new System.Int32[] { 0x0, 0xf }).GetEnumerator(), new int[] { 28}.GetEnumerator());
+            AssertIntRangeSplit(System.Int32.MinValue, System.Int32.MaxValue, 4, false,
+                                new System.Int32[] {0x0, 0xf}.Cast<int>().GetEnumerator(),
+                                new int[] {28}.Cast<int>().GetEnumerator());
 			
 			// the same with precisionStep=2
-            AssertIntRangeSplit(System.Int32.MinValue, System.Int32.MaxValue, 2, false, new System.Collections.ArrayList(new System.Int32[] { 0x0, 0x3 }).GetEnumerator(), new int[] {30 }.GetEnumerator());
+            AssertIntRangeSplit(System.Int32.MinValue, System.Int32.MaxValue, 2, false,
+                                new System.Int32[] {0x0, 0x3}.Cast<int>().GetEnumerator(),
+                                new int[] {30}.Cast<int>().GetEnumerator());
 			
 			// the same with precisionStep=1
-            AssertIntRangeSplit(System.Int32.MinValue, System.Int32.MaxValue, 1, false, new System.Collections.ArrayList(new System.Int32[] { 0x0, 0x1 }).GetEnumerator(), new int[] {31 }.GetEnumerator());
+            AssertIntRangeSplit(System.Int32.MinValue, System.Int32.MaxValue, 1, false,
+                                new System.Int32[] {0x0, 0x1}.Cast<int>().GetEnumerator(),
+                                new int[] {31}.Cast<int>().GetEnumerator());
 			
 			// a inverse range should produce no sub-ranges
-            AssertIntRangeSplit(9500, -5000, 4, false, ((System.Collections.IList)System.Collections.ArrayList.ReadOnly(new System.Collections.ArrayList())).GetEnumerator(), new int[] { }.GetEnumerator());
+            AssertIntRangeSplit(9500, -5000, 4, false, Enumerable.Empty<int>().GetEnumerator(),
+                                new int[] {}.Cast<int>().GetEnumerator());
 			
 			// a 0-length range should reproduce the range itsself
-            AssertIntRangeSplit(9500, 9500, 4, false, new System.Collections.ArrayList(new System.Int32[] { unchecked((System.Int32)0x8000251c), unchecked((System.Int32)0x8000251c) }).GetEnumerator(), new int[] {0 }.GetEnumerator());
+            AssertIntRangeSplit(9500, 9500, 4, false, new System.Int32[]
+                                                          {
+                                                              unchecked((System.Int32) 0x8000251c),
+                                                              unchecked((System.Int32) 0x8000251c)
+                                                          }.Cast<int>().GetEnumerator(),
+                                new int[] {0}.Cast<int>().GetEnumerator());
 		}
 	}
 }
\ No newline at end of file

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Util/TestPriorityQueue.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Util/TestPriorityQueue.cs?rev=1201305&r1=1201304&r2=1201305&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Util/TestPriorityQueue.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Util/TestPriorityQueue.cs Sat Nov 12 19:11:57 2011
@@ -25,20 +25,19 @@ namespace Lucene.Net.Util
 	[TestFixture]
 	public class TestPriorityQueue:LuceneTestCase
 	{
-		
-		private class IntegerQueue:PriorityQueue
-		{
-			public IntegerQueue(int count):base()
-			{
-				Initialize(count);
-			}
-			
-			public override bool LessThan(System.Object a, System.Object b)
-			{
-				return ((System.Int32) a) < ((System.Int32) b);
-			}
-		}
-		
+        private class IntegerQueue : PriorityQueue<int?>
+        {
+            public IntegerQueue(int count)
+            {
+                Initialize(count);
+            }
+
+            public override bool LessThan(int? a, int? b)
+            {
+                return (a < b);
+            }
+        }
+
 		[Test]
 		public virtual void  TestPQ()
 		{
@@ -47,14 +46,15 @@ namespace Lucene.Net.Util
 		
 		public static void  TestPQ(int count, System.Random gen)
 		{
-			PriorityQueue pq = new IntegerQueue(count);
-			int sum = 0, sum2 = 0;
+			PriorityQueue<int?> pq = new IntegerQueue(count);
+		    int sum = 0;
+            int? sum2 = 0;
 			
 			for (int i = 0; i < count; i++)
 			{
 				int next = gen.Next();
 				sum += next;
-				pq.Put((System.Object) next);
+				pq.Add(next);
 			}
 			
 			//      Date end = new Date();
@@ -64,10 +64,10 @@ namespace Lucene.Net.Util
 			
 			//      start = new Date();
 			
-			int last = System.Int32.MinValue;
+			int? last = int.MinValue;
 			for (int i = 0; i < count; i++)
 			{
-				System.Int32 next = (System.Int32) pq.Pop();
+				int? next = pq.Pop();
 				Assert.IsTrue(next >= last);
 				last = next;
 				sum2 += last;
@@ -83,10 +83,10 @@ namespace Lucene.Net.Util
 		[Test]
 		public virtual void  TestClear()
 		{
-			PriorityQueue pq = new IntegerQueue(3);
-			pq.Put((System.Object) 2);
-			pq.Put((System.Object) 3);
-			pq.Put((System.Object) 1);
+			PriorityQueue<int?> pq = new IntegerQueue(3);
+			pq.Add(2);
+            pq.Add(3);
+            pq.Add(1);
 			Assert.AreEqual(3, pq.Size());
 			pq.Clear();
 			Assert.AreEqual(0, pq.Size());
@@ -95,22 +95,22 @@ namespace Lucene.Net.Util
 		[Test]
 		public virtual void  TestFixedSize()
 		{
-			PriorityQueue pq = new IntegerQueue(3);
-			pq.Insert((System.Object) 2);
-			pq.Insert((System.Object) 3);
-			pq.Insert((System.Object) 1);
-			pq.Insert((System.Object) 5);
-			pq.Insert((System.Object) 7);
-			pq.Insert((System.Object) 1);
+			PriorityQueue<int?> pq = new IntegerQueue(3);
+			pq.InsertWithOverflow(2);
+            pq.InsertWithOverflow(3);
+            pq.InsertWithOverflow(1);
+            pq.InsertWithOverflow(5);
+            pq.InsertWithOverflow(7);
+            pq.InsertWithOverflow(1);
 			Assert.AreEqual(3, pq.Size());
-			Assert.AreEqual(3, ((System.Int32) pq.Top()));
+			Assert.AreEqual(3, pq.Top());
 		}
 		
 		[Test]
 		public virtual void  TestInsertWithOverflow()
 		{
 			int size = 4;
-			PriorityQueue pq = new IntegerQueue(size);
+			PriorityQueue<int?> pq = new IntegerQueue(size);
 			System.Int32 i1 = 2;
 			System.Int32 i2 = 3;
 			System.Int32 i3 = 1;
@@ -125,7 +125,7 @@ namespace Lucene.Net.Util
 			Assert.IsTrue((int) pq.InsertWithOverflow(i5) == i3); // i3 should have been dropped
 			Assert.IsTrue((int) pq.InsertWithOverflow(i6) == i6); // i6 should not have been inserted
 			Assert.AreEqual(size, pq.Size());
-			Assert.AreEqual(2, ((System.Int32) pq.Top()));
+			Assert.AreEqual(2, pq.Top());
 		}
 	}
 }
\ No newline at end of file