Add uncommited patch
authorMiguel de Icaza <miguel@gnome.org>
Wed, 2 Apr 2008 23:23:43 +0000 (23:23 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Wed, 2 Apr 2008 23:23:43 +0000 (23:23 -0000)
svn path=/trunk/mcs/; revision=99709

mcs/class/corlib/Test/System.IO/UnmanagedMemoryStreamTest.cs

index f41bdc9b3888d87d8e4277b550d0f9cfe75f5a42..fa406aa705bd50aef16c03da07ed7419bb09d5c8 100644 (file)
@@ -1024,6 +1024,41 @@ namespace MonoTests.System.IO
                        } catch (ObjectDisposedException) {
                        }
                }
+
+               [Test]
+               [ExpectedException (typeof(IOException))]
+               public void PositionPointer_Underflow ()
+               {
+                       byte [] n = new byte [8];
+                       fixed (byte *p = n){
+                               UnmanagedMemoryStream m = new UnmanagedMemoryStream (p, 8);
+                               m.PositionPointer = p-1;
+                       }
+               }
+
+               [Test]
+               [ExpectedException (typeof(ArgumentOutOfRangeException))]
+               public void PositionPointer_Overflow ()
+               {
+                       byte [] n = new byte [8];
+                       fixed (byte *p = n){
+                               UnmanagedMemoryStream m = new UnmanagedMemoryStream (p, 8);
+                               m.PositionPointer = p+9;
+                       }
+               }
+
+               [Test]
+               public void PositionPointer_Set ()
+               {
+                       byte [] n = new byte [8];
+                       n [4] = 65;
+                       fixed (byte *p = n){
+                               UnmanagedMemoryStream m = new UnmanagedMemoryStream (p, 8);
+                               m.PositionPointer = p + 4;
+                               Assert.AreEqual (65, m.ReadByte ());
+                       }
+               }
+               
        }
 }
 #endif