lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aro...@apache.org
Subject svn commit: r836053 - in /incubator/lucene.net/trunk/C#/src: Lucene.Net/Util/NumericUtils.cs Test/Util/TestNumericUtils.cs
Date Fri, 13 Nov 2009 23:07:11 GMT
Author: aroush
Date: Fri Nov 13 23:07:10 2009
New Revision: 836053

URL: http://svn.apache.org/viewvc?rev=836053&view=rev
Log:
Fixed NUnit test-cases for: TestNumericUtils

Modified:
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/NumericUtils.cs
    incubator/lucene.net/trunk/C#/src/Test/Util/TestNumericUtils.cs

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/NumericUtils.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Util/NumericUtils.cs?rev=836053&r1=836052&r2=836053&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/NumericUtils.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/NumericUtils.cs Fri Nov 13 23:07:10
2009
@@ -315,7 +315,7 @@
 		/// </seealso>
 		public static int FloatToSortableInt(float val)
 		{
-			int f = System.Convert.ToInt32(val);
+			int f = BitConverter.ToInt32(BitConverter.GetBytes(val), 0);
 			if (f < 0)
 				f ^= 0x7fffffff;
 			return f;

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=836053&r1=836052&r2=836053&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Util/TestNumericUtils.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Util/TestNumericUtils.cs Fri Nov 13 23:07:10 2009
@@ -64,12 +64,14 @@
 						Assert.IsFalse(bits.GetAndSet(l - lower), "ranges should not overlap");
 					}
 				// make unsigned longs for easier display and understanding
-				min ^= unchecked((int) 0x8000000000000000L);
-				max ^= unchecked((int) 0x8000000000000000L);
+				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),");
-				Assert.AreEqual((long) ((System.Int64) neededBounds.Current), SupportClass.Number.URShift(min,
shift), "inner min bound");
-				Assert.AreEqual((long) ((System.Int64) neededBounds.Current), SupportClass.Number.URShift(max,
shift), "inner max bound");
-			}
+                neededBounds.MoveNext();
+				Assert.AreEqual((long) neededBounds.Current, SupportClass.Number.URShift(min, shift),
"inner min bound");
+                neededBounds.MoveNext();
+				Assert.AreEqual((long) neededBounds.Current, SupportClass.Number.URShift(max, shift),
"inner max bound");
+            }
 		}
 		private class AnonymousClassIntRangeBuilder:NumericUtils.IntRangeBuilder
 		{
@@ -113,7 +115,9 @@
 				min ^= unchecked((int) 0x80000000);
 				max ^= unchecked((int) 0x80000000);
 				//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");
+                neededBounds.MoveNext();
 				Assert.AreEqual(((System.Int32) neededBounds.Current), SupportClass.Number.URShift(max,
shift), "inner max bound");
 			}
 		}
@@ -254,7 +258,7 @@
 			for (int i = 0; i < vals.Length; i++)
 			{
 				longVals[i] = NumericUtils.DoubleToSortableLong(vals[i]);
-				Assert.IsTrue(BitConverter.Int64BitsToDouble((long) vals[i]) == NumericUtils.SortableLongToDouble(longVals[i]),
"forward and back conversion should generate same double");
+				Assert.IsTrue(vals[i].CompareTo(NumericUtils.SortableLongToDouble(longVals[i])) == 0,
"forward and back conversion should generate same double");
 			}
 			
 			// check sort order (prefixVals should be ascending)
@@ -274,7 +278,7 @@
 			for (int i = 0; i < vals.Length; i++)
 			{
 				intVals[i] = NumericUtils.FloatToSortableInt(vals[i]);
-				Assert.IsTrue(BitConverter.ToSingle(BitConverter.GetBytes(vals[i]), 0) == NumericUtils.SortableIntToFloat(intVals[i]),
"forward and back conversion should generate same double");
+				Assert.IsTrue(vals[i].CompareTo(NumericUtils.SortableIntToFloat(intVals[i])) == 0, "forward
and back conversion should generate same double");
 			}
 			
 			// check sort order (prefixVals should be ascending)



Mime
View raw message