Skip to content

Commit

Permalink
2004-06-05 Sebastien Pouliot <[email protected]>
Browse files Browse the repository at this point in the history
	* ConvertTest.cs: Added tests to convert min/max values of integer
	types to strings in all bases.
	* SByteTest.cs: Added test to parse min/max values.

svn path=/trunk/mcs/; revision=28869
  • Loading branch information
Sebastien Pouliot committed Jun 5, 2004
1 parent 8fde154 commit 4e222e0
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 7 deletions.
6 changes: 6 additions & 0 deletions mcs/class/corlib/Test/System/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2004-06-05 Sebastien Pouliot <[email protected]>

* ConvertTest.cs: Added tests to convert min/max values of integer
types to strings in all bases.
* SByteTest.cs: Added test to parse min/max values.

2004-06-04 Sebastien Pouliot <[email protected]>

* MathTest.cs: Added case to check for negative 0 (double) in
Expand Down
44 changes: 44 additions & 0 deletions mcs/class/corlib/Test/System/ConvertTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3475,5 +3475,49 @@ public void ChangeTypeToTypeCodeEmpty ()
{
Convert.ChangeType (true, TypeCode.Empty);
}

[Test]
public void ToString_MinMax_WithBase ()
{
AssertEquals ("Byte.MinValue base 2", "0", Convert.ToString (Byte.MinValue, 2));
AssertEquals ("Byte.MinValue base 8", "0", Convert.ToString (Byte.MinValue, 8));
AssertEquals ("Byte.MinValue base 10", "0", Convert.ToString (Byte.MinValue, 10));
AssertEquals ("Byte.MinValue base 16", "0", Convert.ToString (Byte.MinValue, 16));

AssertEquals ("Byte.MaxValue base 2", "11111111", Convert.ToString (Byte.MaxValue, 2));
AssertEquals ("Byte.MaxValue base 8", "377", Convert.ToString (Byte.MaxValue, 8));
AssertEquals ("Byte.MaxValue base 10", "255", Convert.ToString (Byte.MaxValue, 10));
AssertEquals ("Byte.MaxValue base 16", "ff", Convert.ToString (Byte.MaxValue, 16));

AssertEquals ("Int16.MinValue base 2", "1000000000000000", Convert.ToString (Int16.MinValue, 2));
AssertEquals ("Int16.MinValue base 8", "100000", Convert.ToString (Int16.MinValue, 8));
AssertEquals ("Int16.MinValue base 10", "-32768", Convert.ToString (Int16.MinValue, 10));
AssertEquals ("Int16.MinValue base 16", "8000", Convert.ToString (Int16.MinValue, 16));

AssertEquals ("Int16.MaxValue base 2", "111111111111111", Convert.ToString (Int16.MaxValue, 2));
AssertEquals ("Int16.MaxValue base 8", "77777", Convert.ToString (Int16.MaxValue, 8));
AssertEquals ("Int16.MaxValue base 10", "32767", Convert.ToString (Int16.MaxValue, 10));
AssertEquals ("Int16.MaxValue base 16", "7fff", Convert.ToString (Int16.MaxValue, 16));

AssertEquals ("Int32.MinValue base 2", "10000000000000000000000000000000", Convert.ToString (Int32.MinValue, 2));
AssertEquals ("Int32.MinValue base 8", "20000000000", Convert.ToString (Int32.MinValue, 8));
AssertEquals ("Int32.MinValue base 10", "-2147483648", Convert.ToString (Int32.MinValue, 10));
AssertEquals ("Int32.MinValue base 16", "80000000", Convert.ToString (Int32.MinValue, 16));

AssertEquals ("Int32.MaxValue base 2", "1111111111111111111111111111111", Convert.ToString (Int32.MaxValue, 2));
AssertEquals ("Int32.MaxValue base 8", "17777777777", Convert.ToString (Int32.MaxValue, 8));
AssertEquals ("Int32.MaxValue base 10", "2147483647", Convert.ToString (Int32.MaxValue, 10));
AssertEquals ("Int32.MaxValue base 16", "7fffffff", Convert.ToString (Int32.MaxValue, 16));

AssertEquals ("Int64.MinValue base 2", "1000000000000000000000000000000000000000000000000000000000000000", Convert.ToString (Int64.MinValue, 2));
AssertEquals ("Int64.MinValue base 8", "1000000000000000000000", Convert.ToString (Int64.MinValue, 8));
AssertEquals ("Int64.MinValue base 10", "-9223372036854775808", Convert.ToString (Int64.MinValue, 10));
AssertEquals ("Int64.MinValue base 16", "8000000000000000", Convert.ToString (Int64.MinValue, 16));

AssertEquals ("Int64.MaxValue base 2", "111111111111111111111111111111111111111111111111111111111111111", Convert.ToString (Int64.MaxValue, 2));
AssertEquals ("Int64.MaxValue base 8", "777777777777777777777", Convert.ToString (Int64.MaxValue, 8));
AssertEquals ("Int64.MaxValue base 10", "9223372036854775807", Convert.ToString (Int64.MaxValue, 10));
AssertEquals ("Int64.MaxValue base 16", "7fffffffffffffff", Convert.ToString (Int64.MaxValue, 16));
}
}
}
17 changes: 10 additions & 7 deletions mcs/class/corlib/Test/System/SByteTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Mario Martinez ([email protected])
//
// (C) Ximian, Inc. http://www.ximian.com
// Copyright (C) 2004 Novell (http://www.novell.com)
//

using NUnit.Framework;
Expand All @@ -12,7 +13,8 @@
namespace MonoTests.System
{

public class SByteTest : TestCase
[TestFixture]
public class SByteTest : Assertion
{
private const SByte MySByte1 = -42;
private const SByte MySByte2 = -128;
Expand All @@ -36,12 +38,6 @@ public class SByteTest : TestCase
"127", "127.00000", "12,700.00000 %", "0007f"};
private NumberFormatInfo Nfi = NumberFormatInfo.InvariantInfo;

public SByteTest() {}

protected override void SetUp()
{
}

public void TestMinMax()
{
AssertEquals(SByte.MinValue, MySByte2);
Expand Down Expand Up @@ -139,6 +135,13 @@ public void TestParse()
Assert(typeof(FormatException) == e.GetType());
}
}

[Test]
public void Parse_MinMax ()
{
AssertEquals ("MinValue", SByte.MinValue, SByte.Parse ("-128"));
AssertEquals ("MaxValue", SByte.MaxValue, SByte.Parse ("127"));
}

public void TestToString()
{
Expand Down

0 comments on commit 4e222e0

Please sign in to comment.