当前位置: 首页>>代码示例>>C#>>正文


C# Decoder.GetCharCount方法代码示例

本文整理汇总了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));
        }
开发者ID:ESgarbi,项目名称:corefx,代码行数:26,代码来源:NegativeEncodingTests.cs

示例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);
 }
开发者ID:ESgarbi,项目名称:corefx,代码行数:5,代码来源:DecoderGetCharCount3.cs

示例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));
        }
开发者ID:ESgarbi,项目名称:corefx,代码行数:14,代码来源:NegativeEncodingTests.cs


注:本文中的Decoder.GetCharCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。