merge -r 60814:60815
[mono.git] / mcs / class / corlib / Test / System.IO / BinaryReaderTest.cs
index 69efbae9ee55f598c36e6a3a156a0ed68a5ada0a..5661fef921c013a803e89db9488664bc29e9e3eb 100644 (file)
@@ -1279,6 +1279,20 @@ namespace MonoTests.System.IO
                        stream.Close ();                        
                }
        }
+
+       [Test]
+       public void ReadLongUTF8String ()
+       {
+               // \u00A9 == (C)
+               string s = new String ('\u00A9', 100);
+               MemoryStream ms = new MemoryStream ();
+               BinaryWriter w = new BinaryWriter (ms);         
+               w.Write (s);
+               w.Flush ();
+               ms.Position = 0;
+               BinaryReader r = new BinaryReader (ms);
+               AssertEquals (s, r.ReadString ());
+       }               
        
        [Test]
        [ExpectedException(typeof(EndOfStreamException))]               
@@ -1373,7 +1387,17 @@ namespace MonoTests.System.IO
                        stream.Close ();                        
                }
        }
-       
+
+       [Test]
+       public void Test_ReadZeroBytes ()
+       {
+               MemoryStream stream = new MemoryStream (new byte [] {65, 1, 32, 43, 5, 3, 54, 0, 34, 5, 7, 4, 23, 4, 76, 34, 76, 2, 6,45});
+               BinaryReader reader = new BinaryReader (stream);
+
+               char [] result = reader.ReadChars (0);
+               AssertEquals ("ZERO_1", result.Length, 0);
+       }
+               
        [Test]
        [ExpectedException(typeof(EndOfStreamException))]       
        public void ReadUInt64Exception ()
@@ -1395,6 +1419,6 @@ namespace MonoTests.System.IO
        {
                if (File.Exists (path))
                        File.Delete (path);
-       }       
+       }
 }
 }