New test.
[mono.git] / mcs / class / corlib / Test / System / BitConverterTest.cs
old mode 100755 (executable)
new mode 100644 (file)
index d24be8d..d059d2e
@@ -5,6 +5,7 @@
 //   Duco Fijma (duco@lorentz.xs4all.nl)
 //
 // (C) 2002 Duco Fijma
+// Copyright (C) 2004 Novell (http://www.novell.com)
 // 
 
 using NUnit.Framework;
@@ -13,14 +14,9 @@ using System;
 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;
@@ -532,5 +528,55 @@ public class BitConverterTest : TestCase {
 
        }
 
+       [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));
+       }
 }
 }