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


C# UnicodeEncoding.GetMaxByteCount方法代码示例

本文整理汇总了C#中UnicodeEncoding.GetMaxByteCount方法的典型用法代码示例。如果您正苦于以下问题:C# UnicodeEncoding.GetMaxByteCount方法的具体用法?C# UnicodeEncoding.GetMaxByteCount怎么用?C# UnicodeEncoding.GetMaxByteCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnicodeEncoding的用法示例。


在下文中一共展示了UnicodeEncoding.GetMaxByteCount方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PosTest1

    public bool PosTest1()
    {
        bool retVal = true;

        int expectedValue = 2;
        int actualValue;

        UnicodeEncoding uE = new UnicodeEncoding();

        TestLibrary.TestFramework.BeginScenario("PosTest1:Invoke the method and set charCount as 0.");
        try
        {
            actualValue = uE.GetMaxByteCount(0);

            if (expectedValue != actualValue)
            {
                TestLibrary.TestFramework.LogError("001", "ExpectedValue(" + expectedValue + ") !=ActualValue(" + actualValue + ")");
                retVal = false;
            }

        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002", "Unexpected exception:" + e);
            retVal = false;
        }
        return retVal;
    }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:28,代码来源:unicodeencodinggetmaxbytecount.cs

示例2: PosTest2

        public void PosTest2()
        {
            int expectedValue = 4;
            int actualValue;
            UnicodeEncoding uE = new UnicodeEncoding();

            actualValue = uE.GetMaxByteCount(1);
            Assert.Equal(expectedValue, actualValue);
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:9,代码来源:UnicodeEncodingGetMaxByteCount.cs

示例3: NegTest2

        public void NegTest2()
        {
            int actualValue;
            UnicodeEncoding uE = new UnicodeEncoding();

            Assert.Throws<ArgumentOutOfRangeException>(() =>
            {
                actualValue = uE.GetMaxByteCount(int.MaxValue / 2);
            });
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:10,代码来源:UnicodeEncodingGetMaxByteCount.cs

示例4: PosTest3

        public void PosTest3()
        {
            int charCount = (_generator.GetInt32(-55) % Int32.MaxValue + 1) / 2;
            int expectedValue = (charCount + 1) * 2;
            int actualValue;
            UnicodeEncoding uE = new UnicodeEncoding();

            actualValue = uE.GetMaxByteCount(charCount);
            Assert.Equal(expectedValue, actualValue);
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:10,代码来源:UnicodeEncodingGetMaxByteCount.cs

示例5: NegTest2

    public bool NegTest2()
    {
        bool retVal = true;

        int actualValue;

        UnicodeEncoding uE = new UnicodeEncoding();

        TestLibrary.TestFramework.BeginScenario("NegTest2:Invoke the method and set charCount as a large integer that lead the bytecount to overflow..");
        try
        {
            actualValue = uE.GetMaxByteCount(int.MaxValue / 2);
            TestLibrary.TestFramework.LogError("009", "No ArgumentOutOfRangeException expected.");
            retVal = false;
        }
        catch (ArgumentOutOfRangeException)
        {

        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("010", "Unexpected exception:" + e);
            retVal = false;
        }
        return retVal;
    }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:26,代码来源:unicodeencodinggetmaxbytecount.cs

示例6: NegTest1

    public bool NegTest1()
    {
        bool retVal = true;

        int actualValue;

        UnicodeEncoding uE = new UnicodeEncoding();

        TestLibrary.TestFramework.BeginScenario("NegTest1:Invoke the method and set charCount as -1.");
        try
        {
            actualValue = uE.GetMaxByteCount(-1);
            TestLibrary.TestFramework.LogError("007", "No ArgumentOutOfRangeException expected.");
            retVal = false;
        }
        catch (ArgumentOutOfRangeException)
        {
        
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("008", "Unexpected exception:" + e);
            retVal = false;
        }
        return retVal;
    }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:26,代码来源:unicodeencodinggetmaxbytecount.cs

示例7: PosTest3

    public bool PosTest3()
    {
        bool retVal = true;

        int charCount = (TestLibrary.Generator.GetInt32(-55) % Int32.MaxValue + 1) / 2;

        int expectedValue = (charCount + 1) * 2;
        int actualValue;

        UnicodeEncoding uE = new UnicodeEncoding();

        TestLibrary.TestFramework.BeginScenario("PosTest3:Invoke the method and set charCount as random integer.");
        try
        {
            actualValue = uE.GetMaxByteCount(charCount);

            if (expectedValue != actualValue)
            {
                TestLibrary.TestFramework.LogError("005", "ExpectedValue(" + expectedValue + ") !=ActualValue(" + actualValue + ")");
                retVal = false;
            }

        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("006", "Unexpected exception:" + e);
            retVal = false;
        }
        return retVal;
    }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:30,代码来源:unicodeencodinggetmaxbytecount.cs


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