* Convert.cs: For now, do not throw OverflowException if hex prefixed
authorGert Driesen <drieseng@users.sourceforge.net>
Thu, 18 Aug 2005 11:06:02 +0000 (11:06 -0000)
committerGert Driesen <drieseng@users.sourceforge.net>
Thu, 18 Aug 2005 11:06:02 +0000 (11:06 -0000)
value is negative for signed types (other than int64). Need to look
into this further.
 * ConvertTest.cs: Added mix/max base 16 convert from string tests for
byte/short/int.

svn path=/trunk/mcs/; revision=48490

mcs/class/corlib/System/ChangeLog
mcs/class/corlib/System/Convert.cs
mcs/class/corlib/Test/System/ChangeLog
mcs/class/corlib/Test/System/ConvertTest.cs

index fcc1ac8753c47ca00dc4342ba567787c63039eb0..cf0ab0f39d276baa3c8dae0078ce46e84405896e 100644 (file)
@@ -1,3 +1,9 @@
+2005-08-17  Gert Driesen  <drieseng@users.sourceforge.net>
+
+       * Convert.cs: For now, do not throw OverflowException if hex prefixed
+       value is negative for signed types (other than int64). Need to look
+       into this further.      
+
 2005-08-17  Gert Driesen  <drieseng@users.sourceforge.net>
 
        * Convert.cs: Numerous fixed in overloads taking base to match 
index 1825a3283805692d5096354930e9f7869440df78..41dce91d6d2e3ac7b9cbc1d61677bb5f5766d33a 100644 (file)
@@ -2565,12 +2565,14 @@ namespace System {
                        if (chars == 0)\r
                                throw new FormatException ("Could not find any parsable digits.");\r
 \r
+                       /*\r
                        if (fromBase == 16 && hexPrefix && !unsigned) {\r
                                if (result < UInt32.MinValue) {\r
                                        throw new OverflowException ("Value was either too large or"\r
                                                + " too small for a UInt32.");\r
                                }\r
                        }\r
+                       */\r
                        \r
                        if (negative)\r
                                return -result;\r
index fefd234a12e9bfd595d167c6cb02846882d48d44..dadd5e6dac09562e597af5028f697b8a32ad7418 100644 (file)
@@ -1,3 +1,8 @@
+2005-08-18  Gert Driesen  <drieseng@users.sourceforge.net>
+
+       * ConvertTest.cs: Added mix/max base 16 convert from string tests for
+       byte/short/int.
+
 2005-08-17  Gert Driesen  <drieseng@users.sourceforge.net>
 
        * ConvertTest.cs: Added tests for hex prefixed value, bad hex prefixes,
index bde91bde9f2d579c261c55c262ce8e9723bfb256..3f4faa51a66cdbe62eda83d3ff3d2ed2b77891b8 100644 (file)
@@ -3767,24 +3767,42 @@ namespace MonoTests.System {
                }
 
                [Test]
-               [ExpectedException (typeof (OverflowException))]
-               public void ToSByte_NegativeHex ()
+               public void ToSByte_Base16_MinMax ()
                {
-                       AssertEquals ("0xFFFFFFFFFFFFFF80,16", SByte.MinValue, Convert.ToSByte ("0xFFFFFFFFFFFFFF80", 16));
+                       AssertEquals ("80,16", SByte.MinValue, Convert.ToSByte ("80", 16));
+                       AssertEquals ("0x80,16", SByte.MinValue, Convert.ToSByte ("0x80", 16));
+                       AssertEquals ("0X80,16", SByte.MinValue, Convert.ToSByte ("0X80", 16));
+
+                       AssertEquals ("7f,16", SByte.MaxValue, Convert.ToSByte ("7f", 16));
+                       AssertEquals ("7F,16", SByte.MaxValue, Convert.ToSByte ("7F", 16));
+                       AssertEquals ("0x7f,16", SByte.MaxValue, Convert.ToSByte ("0x7f", 16));
+                       AssertEquals ("0X7F,16", SByte.MaxValue, Convert.ToSByte ("0X7F", 16));
                }
 
                [Test]
-               [ExpectedException (typeof (OverflowException))]
-               public void ToInt16_NegativeHex ()
+               public void ToInt16_Base16_MinMax ()
                {
-                       AssertEquals ("0xFFFFFFFFFFFF8000,16", Int16.MinValue, Convert.ToInt16 ("0xFFFFFFFFFFFF8000", 16));
+                       AssertEquals ("8000,16", short.MinValue, Convert.ToInt16 ("8000", 16));
+                       AssertEquals ("0x8000,16", short.MinValue, Convert.ToInt16 ("0x8000", 16));
+                       AssertEquals ("0X8000,16", short.MinValue, Convert.ToInt16 ("0X8000", 16));
+
+                       AssertEquals ("7fff,16", short.MaxValue, Convert.ToInt16 ("7fff", 16));
+                       AssertEquals ("7FFF,16", short.MaxValue, Convert.ToInt16 ("7FFF", 16));
+                       AssertEquals ("0x7fff,16", short.MaxValue, Convert.ToInt16 ("0x7fff", 16));
+                       AssertEquals ("0X7FFF,16", short.MaxValue, Convert.ToInt16 ("0X7FFF", 16));
                }
 
                [Test]
-               [ExpectedException (typeof (OverflowException))]
-               public void ToInt32_NegativeHex ()
+               public void ToInt32_Base16_MinMax ()
                {
-                       AssertEquals ("0xFFFFFFFF80000000,16", Int32.MinValue, Convert.ToInt32 ("0xFFFFFFFF80000000", 16));
+                       AssertEquals ("80000000,16", int.MinValue, Convert.ToInt32 ("80000000", 16));
+                       AssertEquals ("0x80000000,16", int.MinValue, Convert.ToInt32 ("0x80000000", 16));
+                       AssertEquals ("0X80000000,16", int.MinValue, Convert.ToInt32 ("0X80000000", 16));
+
+                       AssertEquals ("7fffffff,16", int.MaxValue, Convert.ToInt32 ("7fffffff", 16));
+                       AssertEquals ("7FFFFFFF,16", int.MaxValue, Convert.ToInt32 ("7FFFFFFF", 16));
+                       AssertEquals ("0x7fffffff,16", int.MaxValue, Convert.ToInt32 ("0x7fffffff", 16));
+                       AssertEquals ("0X7FFFFFFF,16", int.MaxValue, Convert.ToInt32 ("0X7FFFFFFF", 16));
                }
 
                [Test]