lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [Lucene.Net] svn commit: r1082321 [4/4] - in /incubator/lucene.net/trunk/C#/src: Lucene.Net/Analysis/ Lucene.Net/Analysis/Standard/ Lucene.Net/Index/ Lucene.Net/Search/ Lucene.Net/Store/ Lucene.Net/Util/ Test/Index/ Test/Search/ Test/Util/
Date Wed, 16 Mar 2011 22:14:43 GMT
Modified: incubator/lucene.net/trunk/C#/src/Test/Search/TestSort.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestSort.cs?rev=1082321&r1=1082320&r2=1082321&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestSort.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestSort.cs Wed Mar 16 22:14:41 2011
@@ -1281,5 +1281,24 @@ namespace Lucene.Net.Search
 				}
 			}
 		}
+
+        [Test]
+        public void TestLUCENE2142()
+        {
+            RAMDirectory indexStore = new RAMDirectory();
+            IndexWriter writer = new IndexWriter(indexStore, new SimpleAnalyzer(), true,
IndexWriter.MaxFieldLength.LIMITED);
+            for (int i = 0; i < 5; i++)
+            {
+                Document doc = new Document();
+                doc.Add(new Field("string", "a" + i, Field.Store.NO, Field.Index.NOT_ANALYZED));
+                doc.Add(new Field("string", "b" + i, Field.Store.NO, Field.Index.NOT_ANALYZED));
+                writer.AddDocument(doc);
+            }
+            writer.Optimize(); // enforce one segment to have a higher unique term count
in all cases
+            writer.Close();
+            sort.SetSort(new SortField[]{new SortField("string", SortField.STRING),SortField.FIELD_DOC
});
+            // this should not throw AIOOBE or RuntimeEx
+            new IndexSearcher(indexStore, true).Search(new MatchAllDocsQuery(), null, 500,
sort);
+        }
 	}
 }
\ No newline at end of file

Modified: incubator/lucene.net/trunk/C#/src/Test/Search/TestWildcard.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestWildcard.cs?rev=1082321&r1=1082320&r2=1082321&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestWildcard.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestWildcard.cs Wed Mar 16 22:14:41 2011
@@ -116,6 +116,27 @@ namespace Lucene.Net.Search
 			AssertMatches(searcher, new WildcardQuery(new Term("body", "*tal*")), 2);
 		}
 		
+
+        /**
+         * LUCENE-2620
+         */
+        [Test]
+        public void TestLotsOfAsterisks()
+        {
+            RAMDirectory indexStore = GetIndexStore("body", new String[] { "metal", "metals"
});
+            IndexSearcher searcher = new IndexSearcher(indexStore, true);
+            System.Text.StringBuilder term = new System.Text.StringBuilder();
+            term.Append("m");
+            for (int i = 0; i < 512; i++)
+                term.Append("*");
+            term.Append("tal");
+            Query query3 = new WildcardQuery(new Term("body", term.ToString()));
+
+            AssertMatches(searcher, query3, 1);
+            searcher.Close();
+            indexStore.Close();
+        }
+
 		/// <summary> Tests Wildcard queries with a question mark.
 		/// 
 		/// </summary>

Modified: incubator/lucene.net/trunk/C#/src/Test/Util/LuceneTestCase.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Util/LuceneTestCase.cs?rev=1082321&r1=1082320&r2=1082321&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Util/LuceneTestCase.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Util/LuceneTestCase.cs Wed Mar 16 22:14:41 2011
@@ -48,7 +48,15 @@ namespace Lucene.Net.Util
 	[Serializable]
 	public abstract class LuceneTestCase
 	{
-		
+		public static  System.IO.FileInfo TEMP_DIR;
+        static LuceneTestCase()
+        {
+            String s = System.Environment.GetEnvironmentVariable("TEMP");
+            if (s == null)
+                throw new  Exception("To run tests, you need to define system property 'temp'");
+            TEMP_DIR = new System.IO.FileInfo(s);
+        }
+
 		[NonSerialized]
 		private bool savedAPISetting = false;
         bool allowDocsOutOfOrder = true;

Modified: incubator/lucene.net/trunk/C#/src/Test/Util/TestNumericUtils.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Util/TestNumericUtils.cs?rev=1082321&r1=1082320&r2=1082321&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Util/TestNumericUtils.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Util/TestNumericUtils.cs Wed Mar 16 22:14:41 2011
@@ -27,17 +27,18 @@ namespace Lucene.Net.Util
 	{
 		private class AnonymousClassLongRangeBuilder:NumericUtils.LongRangeBuilder
 		{
-			public AnonymousClassLongRangeBuilder(long lower, long upper, bool useBitSet, Lucene.Net.Util.OpenBitSet
bits, System.Collections.IEnumerator neededBounds, TestNumericUtils enclosingInstance)
+			public AnonymousClassLongRangeBuilder(long lower, long upper, bool useBitSet, Lucene.Net.Util.OpenBitSet
bits, System.Collections.IEnumerator neededBounds, System.Collections.IEnumerator neededShifts,TestNumericUtils
enclosingInstance)
 			{
-				InitBlock(lower, upper, useBitSet, bits, neededBounds, enclosingInstance);
+				InitBlock(lower, upper, useBitSet, bits, neededBounds, neededShifts, enclosingInstance);
 			}
-			private void  InitBlock(long lower, long upper, bool useBitSet, Lucene.Net.Util.OpenBitSet
bits, System.Collections.IEnumerator neededBounds, TestNumericUtils enclosingInstance)
+			private void  InitBlock(long lower, long upper, bool useBitSet, Lucene.Net.Util.OpenBitSet
bits, System.Collections.IEnumerator neededBounds, System.Collections.IEnumerator neededShifts,TestNumericUtils
enclosingInstance)
 			{
 				this.lower = lower;
 				this.upper = upper;
 				this.useBitSet = useBitSet;
 				this.bits = bits;
 				this.neededBounds = neededBounds;
+                this.neededShifts = neededShifts;
 				this.enclosingInstance = enclosingInstance;
 			}
 			private long lower;
@@ -45,6 +46,7 @@ namespace Lucene.Net.Util
 			private bool useBitSet;
 			private Lucene.Net.Util.OpenBitSet bits;
 			private System.Collections.IEnumerator neededBounds;
+            private System.Collections.IEnumerator neededShifts;
 			private TestNumericUtils enclosingInstance;
 			public TestNumericUtils Enclosing_Instance
 			{
@@ -62,11 +64,16 @@ namespace Lucene.Net.Util
 					for (long l = min; l <= max; l++)
 					{
 						Assert.IsFalse(bits.GetAndSet(l - lower), "ranges should not overlap");
+                        // extra exit condition to prevent overflow on MAX_VALUE
+                        if (l == max) break;
 					}
+                if (neededBounds == null || neededShifts == null) return;
 				// make unsigned longs for easier display and understanding
 				min ^= unchecked((long) 0x8000000000000000L);
 				max ^= unchecked((long) 0x8000000000000000L);
 				//System.out.println("new Long(0x"+Long.toHexString(min>>>shift)+"L),new Long(0x"+Long.toHexString(max>>>shift)+"L),");
+                neededShifts.MoveNext();
+                Assert.AreEqual(((Int32)neededShifts.Current), shift, "shift");
                 neededBounds.MoveNext();
 				Assert.AreEqual((long) neededBounds.Current, SupportClass.Number.URShift(min, shift),
"inner min bound");
                 neededBounds.MoveNext();
@@ -75,17 +82,18 @@ 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, TestNumericUtils enclosingInstance)
+			public AnonymousClassIntRangeBuilder(int lower, int upper, bool useBitSet, Lucene.Net.Util.OpenBitSet
bits, System.Collections.IEnumerator neededBounds, System.Collections.IEnumerator neededShifts,TestNumericUtils
enclosingInstance)
 			{
-				InitBlock(lower, upper, useBitSet, bits, neededBounds, 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, TestNumericUtils 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)
 			{
 				this.lower = lower;
 				this.upper = upper;
 				this.useBitSet = useBitSet;
 				this.bits = bits;
 				this.neededBounds = neededBounds;
+                this.neededShifts = neededShifts;
 				this.enclosingInstance = enclosingInstance;
 			}
 			private int lower;
@@ -93,6 +101,7 @@ namespace Lucene.Net.Util
 			private bool useBitSet;
 			private Lucene.Net.Util.OpenBitSet bits;
 			private System.Collections.IEnumerator neededBounds;
+            private System.Collections.IEnumerator neededShifts;
 			private TestNumericUtils enclosingInstance;
 			public TestNumericUtils Enclosing_Instance
 			{
@@ -110,10 +119,15 @@ namespace Lucene.Net.Util
 					for (int i = min; i <= max; i++)
 					{
 						Assert.IsFalse(bits.GetAndSet(i - lower), "ranges should not overlap");
+                        // extra exit condition to prevent overflow on MAX_VALUE
+                        if (i == max) break;
 					}
+                if (neededBounds == null) return;
 				// make unsigned ints for easier display and understanding
 				min ^= unchecked((int) 0x80000000);
 				max ^= unchecked((int) 0x80000000);
+                neededShifts.MoveNext();
+                Assert.AreEqual(((int)neededShifts.Current), shift,"shift");
 				//System.out.println("new Integer(0x"+Integer.toHexString(min>>>shift)+"),new
Integer(0x"+Integer.toHexString(max>>>shift)+"),");
                 neededBounds.MoveNext();
 				Assert.AreEqual(((System.Int32) neededBounds.Current), SupportClass.Number.URShift(min,
shift), "inner min bound");
@@ -291,11 +305,11 @@ namespace Lucene.Net.Util
 		// INFO: Tests for trieCodeLong()/trieCodeInt() not needed because implicitely tested by
range filter tests
 		
 		/// <summary>Note: The neededBounds iterator must be unsigned (easier understanding
what's happening) </summary>
-		protected internal virtual void  AssertLongRangeSplit(long lower, long upper, int precisionStep,
bool useBitSet, System.Collections.IEnumerator neededBounds)
+		internal virtual void  AssertLongRangeSplit(long lower, long upper, int precisionStep,
bool useBitSet, System.Collections.IEnumerator neededBounds, System.Collections.IEnumerator
neededShifts)
 		{
 			OpenBitSet bits = useBitSet?new OpenBitSet(upper - lower + 1):null;
 			
-			NumericUtils.SplitLongRange(new AnonymousClassLongRangeBuilder(lower, upper, useBitSet,
bits, neededBounds, this), precisionStep, lower, upper);
+			NumericUtils.SplitLongRange(new AnonymousClassLongRangeBuilder(lower, upper, useBitSet,
bits, neededBounds,neededShifts,this), precisionStep, lower, upper);
 			
 			if (useBitSet)
 			{
@@ -305,44 +319,166 @@ namespace Lucene.Net.Util
 			}
 		}
 		
+         /** LUCENE-2541: NumericRangeQuery errors with endpoints near long min and max values
*/
         [Test]
-		public virtual void  TestSplitLongRange()
+        public void TestLongExtremeValues()
+        {
+            // upper end extremes
+            AssertLongRangeSplit(long.MaxValue, long.MaxValue, 1, true,
+                new ulong[] { 0xffffffffffffffffL, 0xffffffffffffffffL }.GetEnumerator(),
+                new int[] { 0 }.GetEnumerator());
+
+            AssertLongRangeSplit(long.MaxValue, long.MaxValue, 2, true,
+                new ulong[] { 0xffffffffffffffffL, 0xffffffffffffffffL }.GetEnumerator(),
+                new int[] { 0 }.GetEnumerator());
+
+            AssertLongRangeSplit(long.MaxValue, long.MaxValue, 4, true,
+                new ulong[] { 0xffffffffffffffffL, 0xffffffffffffffffL }.GetEnumerator(),
+                new int[] { 0 }.GetEnumerator());
+
+            AssertLongRangeSplit(long.MaxValue, long.MaxValue, 6, true,
+                new ulong[] { 0xffffffffffffffffL, 0xffffffffffffffffL }.GetEnumerator(),
+                new int[] { 0 }.GetEnumerator());
+
+            AssertLongRangeSplit(long.MaxValue, long.MaxValue, 8, true,
+                new ulong[] { 0xffffffffffffffffL, 0xffffffffffffffffL }.GetEnumerator(),
+                new int[] { 0 }.GetEnumerator());
+
+            AssertLongRangeSplit(long.MaxValue, long.MaxValue, 64, true,
+                new ulong[] { 0xffffffffffffffffL, 0xffffffffffffffffL }.GetEnumerator(),
+                new int[] { 0 }.GetEnumerator());
+            
+            AssertLongRangeSplit(long.MaxValue - 0xfL, long.MaxValue, 4, true,
+                new ulong[] { 0xfffffffffffffffL, 0xfffffffffffffffL }.GetEnumerator(),
+                new int[] { 4 }.GetEnumerator());
+            AssertLongRangeSplit(long.MaxValue - 0x10L, long.MaxValue, 4, true,
+                new ulong[] { 0xffffffffffffffefL, 0xffffffffffffffefL, 0xfffffffffffffffL,
0xfffffffffffffffL }.GetEnumerator(),
+                new int[] { 0, 4 }.GetEnumerator());
+
+            // lower end extremes
+            AssertLongRangeSplit(long.MinValue, long.MinValue, 1, true,
+                new long[] { 0x0000000000000000L, 0x0000000000000000L }.GetEnumerator(),
+                new int[] { 0 }.GetEnumerator());
+
+            AssertLongRangeSplit(long.MinValue, long.MinValue, 2, true,
+                new long[] { 0x0000000000000000L, 0x0000000000000000L }.GetEnumerator(),
+                new int[] { 0 }.GetEnumerator());
+
+            AssertLongRangeSplit(long.MinValue, long.MinValue, 4, true,
+                new long[] { 0x0000000000000000L, 0x0000000000000000L }.GetEnumerator(),
+                new int[] { 0 }.GetEnumerator());
+
+            AssertLongRangeSplit(long.MinValue, long.MinValue, 6, true,
+                new long[] { 0x0000000000000000L, 0x0000000000000000L }.GetEnumerator(),
+                new int[] { 0 }.GetEnumerator());
+
+            AssertLongRangeSplit(long.MinValue, long.MinValue, 8, true,
+                new long[] { 0x0000000000000000L, 0x0000000000000000L }.GetEnumerator(),
+                new int[] { 0 }.GetEnumerator());
+
+            AssertLongRangeSplit(long.MinValue, long.MinValue, 64, true,
+                new long[] { 0x0000000000000000L, 0x0000000000000000L }.GetEnumerator(),
+                new int[] { 0 }.GetEnumerator());
+
+
+            AssertLongRangeSplit(long.MinValue, long.MinValue + 0xfL, 4, true,
+                new long[] { 0x000000000000000L, 0x000000000000000L }.GetEnumerator(),
+                new int[] { 4 }.GetEnumerator());
+            AssertLongRangeSplit(long.MinValue, long.MinValue + 0x10L, 4, true,
+                new long[] { 0x0000000000000010L, 0x0000000000000010L, 0x000000000000000L,
0x000000000000000L }.GetEnumerator(),
+                new int[] { 0, 4 }.GetEnumerator());
+        }
+
+        [Test]
+        public void TestRandomSplit()
+        {
+            Random random = new Random();
+            for (int i = 0; i < 100; i++)
+            {
+                ExecuteOneRandomSplit(random);
+            }
+        }
+
+        private void ExecuteOneRandomSplit(Random random)
+        {
+            long lower = RandomLong(random);
+            long len = (long)random.Next(16384 * 1024); // not too large bitsets, else OOME!
+            while (lower + len < lower)
+            { // overflow
+                lower >>= 1;
+            }
+            AssertLongRangeSplit(lower, lower + len, random.Next(64) + 1, true, null, null);
+        }
+
+        private long RandomLong(Random random)
+        {
+            long val;
+            switch (random.Next(4))
+            {
+                case 0:
+                    val = 1L << (random.Next(63)); //  patterns like 0x000000100000
(-1 yields patterns like 0x0000fff)
+                    break;
+                case 1:
+                    val = -1L << (random.Next(63)); // patterns like 0xfffff00000
+                    break;
+                default:
+                    val = random.Next();
+                    break;
+            }
+
+            val += random.Next(5) - 2;
+
+            if (random.Next(2) == 1)
+            {
+                if (random.Next(2) == 1) val += random.Next(100) - 50;
+                if (random.Next(2) == 1) val = ~val;
+                if (random.Next(2) == 1) val = val << 1;
+                if (random.Next(2) == 1) val = SupportClass.Number.URShift(val, 1);
+            }
+
+            return val;
+        }
+
+
+        [Test]
+		public void  TestSplitLongRange()
 		{
 			// a hard-coded "standard" range
-			AssertLongRangeSplit(- 5000L, 9500L, 4, true, new System.Collections.ArrayList(new System.Int64[]{0x7fffffffffffec78L,
0x7fffffffffffec7fL, unchecked((long) (0x8000000000002510L)), unchecked((long) (0x800000000000251cL)),
0x7fffffffffffec8L, 0x7fffffffffffecfL, 0x800000000000250L, 0x800000000000250L, 0x7fffffffffffedL,
0x7fffffffffffefL, 0x80000000000020L, 0x80000000000024L, 0x7ffffffffffffL, 0x8000000000001L}).GetEnumerator());
+			AssertLongRangeSplit(- 5000L, 9500L, 4, true, new System.Collections.ArrayList(new System.Int64[]{0x7fffffffffffec78L,
0x7fffffffffffec7fL, unchecked((long) (0x8000000000002510L)), unchecked((long) (0x800000000000251cL)),
0x7fffffffffffec8L, 0x7fffffffffffecfL, 0x800000000000250L, 0x800000000000250L, 0x7fffffffffffedL,
0x7fffffffffffefL, 0x80000000000020L, 0x80000000000024L, 0x7ffffffffffffL, 0x8000000000001L}).GetEnumerator(),new
int[]{0,0,4,4,8,8,12}.GetEnumerator());
 			
 			// the same with no range splitting
-			AssertLongRangeSplit(- 5000L, 9500L, 64, true, new System.Collections.ArrayList(new System.Int64[]{0x7fffffffffffec78L,
unchecked((long) (0x800000000000251cL))}).GetEnumerator());
+            AssertLongRangeSplit(-5000L, 9500L, 64, true, new System.Collections.ArrayList(new
System.Int64[] { 0x7fffffffffffec78L, unchecked((long)(0x800000000000251cL)) }).GetEnumerator(),
new int[] { 0 }.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
-			AssertLongRangeSplit(0L, 1024L + 63L, 4, true, new System.Collections.ArrayList(new System.Int64[]{0x800000000000040L,
0x800000000000043L, 0x80000000000000L, 0x80000000000003L}).GetEnumerator());
+            AssertLongRangeSplit(0L, 1024L + 63L, 4, true, new System.Collections.ArrayList(new
System.Int64[] { 0x800000000000040L, 0x800000000000043L, 0x80000000000000L, 0x80000000000003L
}).GetEnumerator(), new int[] {4,8}.GetEnumerator());
 			
 			// the full long range should only consist of a lowest precision range; no bitset testing
here, as too much memory needed :-)
-			AssertLongRangeSplit(System.Int64.MinValue, System.Int64.MaxValue, 8, false, new System.Collections.ArrayList(new
System.Int64[]{0x00L, 0xffL}).GetEnumerator());
+            AssertLongRangeSplit(System.Int64.MinValue, System.Int64.MaxValue, 8, false,
new System.Collections.ArrayList(new System.Int64[] { 0x00L, 0xffL }).GetEnumerator(), new
int[] {56}.GetEnumerator());
 			
 			// the same with precisionStep=4
-			AssertLongRangeSplit(System.Int64.MinValue, System.Int64.MaxValue, 4, false, new System.Collections.ArrayList(new
System.Int64[]{0x0L, 0xfL}).GetEnumerator());
+            AssertLongRangeSplit(System.Int64.MinValue, System.Int64.MaxValue, 4, false,
new System.Collections.ArrayList(new System.Int64[] { 0x0L, 0xfL }).GetEnumerator(), new int[]
{60}.GetEnumerator());
 			
 			// the same with precisionStep=2
-			AssertLongRangeSplit(System.Int64.MinValue, System.Int64.MaxValue, 2, false, new System.Collections.ArrayList(new
System.Int64[]{0x0L, 0x3L}).GetEnumerator());
+            AssertLongRangeSplit(System.Int64.MinValue, System.Int64.MaxValue, 2, false,
new System.Collections.ArrayList(new System.Int64[] { 0x0L, 0x3L }).GetEnumerator(), new int[]
{62}.GetEnumerator());
 			
 			// the same with precisionStep=1
-			AssertLongRangeSplit(System.Int64.MinValue, System.Int64.MaxValue, 1, false, new System.Collections.ArrayList(new
System.Int64[]{0x0L, 0x1L}).GetEnumerator());
+            AssertLongRangeSplit(System.Int64.MinValue, System.Int64.MaxValue, 1, false,
new System.Collections.ArrayList(new System.Int64[] { 0x0L, 0x1L }).GetEnumerator(), new int[]
{63}.GetEnumerator());
 			
 			// a inverse range should produce no sub-ranges
-			AssertLongRangeSplit(9500L, - 5000L, 4, false, ((System.Collections.IList) System.Collections.ArrayList.ReadOnly(new
System.Collections.ArrayList())).GetEnumerator());
+            AssertLongRangeSplit(9500L, -5000L, 4, false, ((System.Collections.IList)System.Collections.ArrayList.ReadOnly(new
System.Collections.ArrayList())).GetEnumerator(), new int[] { }.GetEnumerator());
 			
 			// a 0-length range should reproduce the range itsself
-			AssertLongRangeSplit(9500L, 9500L, 4, false, new System.Collections.ArrayList(new System.Int64[]{unchecked((long)
(0x800000000000251cL)), unchecked((long) (0x800000000000251cL))}).GetEnumerator());
+            AssertLongRangeSplit(9500L, 9500L, 4, false, new System.Collections.ArrayList(new
System.Int64[] { unchecked((long)(0x800000000000251cL)), unchecked((long)(0x800000000000251cL))
}).GetEnumerator(), new int[] {0}.GetEnumerator());
 		}
 		
+
 		/// <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)
+		protected internal virtual void  AssertIntRangeSplit(int lower, int upper, int precisionStep,
bool useBitSet, System.Collections.IEnumerator neededBounds,System.Collections.IEnumerator
neededShifts)
 		{
 			OpenBitSet bits = useBitSet?new OpenBitSet(upper - lower + 1):null;
-			
-			NumericUtils.SplitIntRange(new AnonymousClassIntRangeBuilder(lower, upper, useBitSet,
bits, neededBounds, this), precisionStep, lower, upper);
+
+            NumericUtils.SplitIntRange(new AnonymousClassIntRangeBuilder(lower, upper, useBitSet,
bits, neededBounds, neededShifts,this), precisionStep, lower, upper);
 			
 			if (useBitSet)
 			{
@@ -356,32 +492,32 @@ 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());
+			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());
 			
 			// the same with no range splitting
-			AssertIntRangeSplit(- 5000, 9500, 32, true, new System.Collections.ArrayList(new System.Int32[]{0x7fffec78,
unchecked((System.Int32) 0x8000251c)}).GetEnumerator());
+            AssertIntRangeSplit(-5000, 9500, 32, true, new System.Collections.ArrayList(new
System.Int32[] { 0x7fffec78, unchecked((System.Int32)0x8000251c) }).GetEnumerator(), new int[]
{ 0}.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());
+            AssertIntRangeSplit(0, 1024 + 63, 4, true, new System.Collections.ArrayList(new
System.Int32[] { 0x8000040, 0x8000043, 0x800000, 0x800003 }).GetEnumerator(), new int[] {4,8
}.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());
+            AssertIntRangeSplit(System.Int32.MinValue, System.Int32.MaxValue, 8, false, new
System.Collections.ArrayList(new System.Int32[] { 0x00, 0xff }).GetEnumerator(), new int[]
{ 24}.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());
+            AssertIntRangeSplit(System.Int32.MinValue, System.Int32.MaxValue, 4, false, new
System.Collections.ArrayList(new System.Int32[] { 0x0, 0xf }).GetEnumerator(), new int[] {
28}.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());
+            AssertIntRangeSplit(System.Int32.MinValue, System.Int32.MaxValue, 2, false, new
System.Collections.ArrayList(new System.Int32[] { 0x0, 0x3 }).GetEnumerator(), new int[] {30
}.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());
+            AssertIntRangeSplit(System.Int32.MinValue, System.Int32.MaxValue, 1, false, new
System.Collections.ArrayList(new System.Int32[] { 0x0, 0x1 }).GetEnumerator(), new int[] {31
}.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());
+            AssertIntRangeSplit(9500, -5000, 4, false, ((System.Collections.IList)System.Collections.ArrayList.ReadOnly(new
System.Collections.ArrayList())).GetEnumerator(), new 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());
+            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());
 		}
 	}
 }
\ No newline at end of file

Modified: incubator/lucene.net/trunk/C#/src/Test/Util/TestOpenBitSet.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Util/TestOpenBitSet.cs?rev=1082321&r1=1082320&r2=1082321&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Util/TestOpenBitSet.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Util/TestOpenBitSet.cs Wed Mar 16 22:14:41 2011
@@ -376,5 +376,18 @@ namespace Lucene.Net.Util
 				Assert.AreEqual(i, BitUtil.Ntz3(num));
 			}
 		}
+
+        [Test]
+        public void TestHashCodeEquals()
+        {
+            OpenBitSet bs1 = new OpenBitSet(200);
+            OpenBitSet bs2 = new OpenBitSet(64);
+            bs1.Set(3);
+            bs2.Set(3);
+            Assert.AreEqual(bs1, bs2);
+            Assert.AreEqual(bs1.GetHashCode(), bs2.GetHashCode());
+        }
 	}
+
+    
 }
\ No newline at end of file



Mime
View raw message