소스 검색

2004-06-07 Atsushi Enomoto <[email protected]>

	* UTF8EncodingTest.cs : Added TestThrowOnInvalid().

svn path=/trunk/mcs/; revision=28979
Atsushi Eno 21 년 전
부모
커밋
8dcd4adc79
2개의 변경된 파일22개의 추가작업 그리고 0개의 파일을 삭제
  1. 4 0
      mcs/class/corlib/Test/System.Text/ChangeLog
  2. 18 0
      mcs/class/corlib/Test/System.Text/UTF8EncodingTest.cs

+ 4 - 0
mcs/class/corlib/Test/System.Text/ChangeLog

@@ -1,3 +1,7 @@
+2004-06-07  Atsushi Enomoto  <[email protected]>
+
+	* UTF8EncodingTest.cs : Added TestThrowOnInvalid().
+
 2004-05-26  Sebastien Pouliot  <[email protected]>
 
 	* StringBuilderTest.cs: Added unit tests to be sure integer overflows

+ 18 - 0
mcs/class/corlib/Test/System.Text/UTF8EncodingTest.cs

@@ -100,6 +100,24 @@ namespace MonoTests.System.Text {
                         Assertion.AssertEquals ("UTF #1", 200, UTF8enc.GetMaxByteCount(50));
                 }
 
+		// regression for bug #59648
+		[Test]
+		public void TestThrowOnInvalid ()
+		{
+			UTF8Encoding u = new UTF8Encoding (true, false);
+
+			byte[] data = new byte [] { 0xC0, 0xAF };
+			string s = u.GetString (data);
+			AssertEquals (0, s.Length);
+
+			data = new byte [] { 0x30, 0x31, 0xC0, 0xAF, 0x30, 0x32 };
+			s = u.GetString (data);
+			AssertEquals (4, s.Length);
+			AssertEquals (0x30, (int) s [0]);
+			AssertEquals (0x31, (int) s [1]);
+			AssertEquals (0x30, (int) s [2]);
+			AssertEquals (0x32, (int) s [3]);
+		}
 
 		// UTF8 decoding tests from http://www.cl.cam.ac.uk/~mgk25/