Imported Upstream version 3.10.0

Former-commit-id: 172c8e3c300b39d5785c7a3e8dfb08ebdbc1a99b
This commit is contained in:
Jo Shields
2014-10-04 11:27:48 +01:00
parent fe777c5c82
commit 8b9b85e7f5
970 changed files with 20242 additions and 31308 deletions

View File

@ -44,7 +44,7 @@ namespace MonoTests.System.Text
char [] chars = new char [10000];
byte [] bytes = new byte [10000];
Decoder conv = Encoding.UTF8.GetDecoder ();
Decoder conv = new ExposedDecoder ();
int charsUsed, bytesUsed;
bool done;
@ -56,6 +56,24 @@ namespace MonoTests.System.Text
Assert.AreEqual (625, bytesUsed, "#3");
}
[Test]
public void ConvertLimitedDestinationUTF8 ()
{
char [] chars = new char [10000];
byte [] bytes = new byte [10000];
Decoder conv = Encoding.UTF8.GetDecoder ();
int charsUsed, bytesUsed;
bool done;
conv.Convert (bytes, 0, 10000, chars, 0, 1000, true,
out charsUsed, out bytesUsed, out done);
Assert.IsFalse (done, "#1");
Assert.AreEqual (1000, charsUsed, "#2");
Assert.AreEqual (1000, bytesUsed, "#3");
}
[Test]
public void CustomEncodingGetDecoder ()
@ -65,6 +83,18 @@ namespace MonoTests.System.Text
Assert.IsNotNull (decoder);
}
class ExposedDecoder : Decoder {
public override int GetCharCount (byte [] bytes, int index, int count)
{
return Encoding.UTF8.GetDecoder ().GetCharCount (bytes, index, count);
}
public override int GetChars (byte [] bytes, int byteIndex, int byteCount, char [] chars, int charIndex)
{
return Encoding.UTF8.GetDecoder ().GetChars (bytes, byteIndex, byteCount, chars, charIndex);
}
}
class CustomEncoding : Encoding {
public override int GetByteCount (char [] chars, int index, int count)