// Duco Fijma (duco@lorentz.xs4all.nl)
//
// (C) 2002 Duco Fijma
+// Copyright (C) 2004 Novell (http://www.novell.com)
//
using NUnit.Framework;
namespace MonoTests.System
{
-public class BitConverterTest : TestCase {
+[TestFixture]
+public class BitConverterTest : Assertion {
- public BitConverterTest () {}
-
- protected override void SetUp () {}
-
- protected override void TearDown() {}
-
public void TestIsLittleEndian ()
{
byte[] b;
}
+ [Test]
+ [ExpectedException (typeof (ArgumentOutOfRangeException))]
+ public void ToString_StartIndexOverflow ()
+ {
+ byte[] array = new byte [4];
+ BitConverter.ToString (array, Int32.MaxValue, 1);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void ToString_LengthOverflow ()
+ {
+ byte[] array = new byte [4];
+ BitConverter.ToString (array, 1, Int32.MaxValue);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentOutOfRangeException))]
+ public void ToUpperLimit ()
+ {
+ byte[] array = new byte [4];
+ BitConverter.ToInt32 (array, Int32.MaxValue);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentOutOfRangeException))]
+ public void ToLowerLimit ()
+ {
+ byte[] array = new byte [4];
+ BitConverter.ToInt32 (array, Int32.MinValue);
+ }
+
+ [Test]
+#if !NET_2_0
+ [ExpectedException (typeof (ArgumentOutOfRangeException))]
+#endif
+ public void ToString_Empty ()
+ {
+ byte[] empty = new byte [0];
+ AssertEquals ("Empty", String.Empty, BitConverter.ToString (empty));
+ }
+
+ [Test]
+ public void ToBoolean ()
+ {
+ byte[] array = new byte [2] { 0x02, 0x00 };
+ Assert ("True", BitConverter.ToBoolean (array, 0));
+ AssertEquals ("True==True", true, BitConverter.ToBoolean (array, 0));
+ Assert ("False", !BitConverter.ToBoolean (array, 1));
+ }
}
}