本文整理汇总了C#中Decoder.GetCharCount方法的典型用法代码示例。如果您正苦于以下问题:C# Decoder.GetCharCount方法的具体用法?C# Decoder.GetCharCount怎么用?C# Decoder.GetCharCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Decoder
的用法示例。
在下文中一共展示了Decoder.GetCharCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Decoder_GetChars_Invalid
public static void Decoder_GetChars_Invalid(Encoding _, Decoder decoder, bool flush)
{
// Bytes is null
Assert.Throws<ArgumentNullException>("bytes", () => decoder.GetChars(null, 0, 0, new char[4], 0, flush));
// ByteIndex is invalid
Assert.Throws<ArgumentOutOfRangeException>("byteIndex", () => decoder.GetChars(new byte[4], -1, 0, new char[4], 0, flush));
Assert.Throws<ArgumentOutOfRangeException>("bytes", () => decoder.GetChars(new byte[4], 5, 0, new char[4], 0, flush));
// ByteCount is invalid
Assert.Throws<ArgumentOutOfRangeException>("byteCount", () => decoder.GetChars(new byte[4], 0, -1, new char[4], 0, flush));
Assert.Throws<ArgumentOutOfRangeException>("bytes", () => decoder.GetChars(new byte[4], 0, 5, new char[4], 0, flush));
Assert.Throws<ArgumentOutOfRangeException>("bytes", () => decoder.GetChars(new byte
[4], 1, 4, new char[4], 0, flush));
// Chars is null
Assert.Throws<ArgumentNullException>("chars", () => decoder.GetChars(new byte[1], 0, 1, null, 0, flush));
// CharIndex is invalid
Assert.Throws<ArgumentOutOfRangeException>("charIndex", () => decoder.GetChars(new byte[1], 0, 1, new char[4], -1, flush));
Assert.Throws<ArgumentOutOfRangeException>("charIndex", () => decoder.GetChars(new byte[1], 0, 1, new char[4], 5, flush));
// Chars does not have enough space
int charCount = decoder.GetCharCount(new byte[4], 0, 4, flush);
Assert.Throws<ArgumentException>("chars", () => decoder.GetChars(new byte[4], 0, 4, new char[charCount - 1], 0, flush));
}
示例2: VerificationHelper
private void VerificationHelper(Decoder decoder, byte[] bytes, int index, int count, int expected, string errorno)
{
int ret = decoder.GetCharCount(bytes, index, count);
Assert.Equal(expected, ret);
}
示例3: Decoder_GetCharCount_Invalid
public static void Decoder_GetCharCount_Invalid(Encoding _, Decoder decoder, bool flush)
{
// Bytes is null
Assert.Throws<ArgumentNullException>("bytes", () => decoder.GetCharCount(null, 0, 0, flush));
// Index is invalid
Assert.Throws<ArgumentOutOfRangeException>("index", () => decoder.GetCharCount(new byte[4], -1, 0, flush));
Assert.Throws<ArgumentOutOfRangeException>("bytes", () => decoder.GetCharCount(new byte[4], 5, 0, flush));
// Count is invalid
Assert.Throws<ArgumentOutOfRangeException>("count", () => decoder.GetCharCount(new byte[4], 0, -1, flush));
Assert.Throws<ArgumentOutOfRangeException>("bytes", () => decoder.GetCharCount(new byte[4], 0, 5, flush));
Assert.Throws<ArgumentOutOfRangeException>("bytes", () => decoder.GetCharCount(new byte[4], 1, 4, flush));
}