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


C# UnicodeEncoding.GetByteCount方法代码示例

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


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

示例1: PosTest1

 public void PosTest1()
 {
     UnicodeEncoding uEncoding = new UnicodeEncoding();
     int actualValue;
     actualValue = uEncoding.GetByteCount("");
     Assert.Equal(0, actualValue);
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:7,代码来源:UnicodeEncodingGetByteCount2.cs

示例2: PosTest3

 public void PosTest3()
 {
     String str = GetString(1);
     UnicodeEncoding uEncoding = new UnicodeEncoding();
     int actualValue;
     actualValue = uEncoding.GetByteCount(str);
     Assert.Equal(2, actualValue);
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:8,代码来源:UnicodeEncodingGetByteCount2.cs

示例3: PosTest1

 public void PosTest1()
 {
     Char[] chars = new Char[] { };
     UnicodeEncoding uEncoding = new UnicodeEncoding();
     int actualValue;
     actualValue = uEncoding.GetByteCount(chars, 0, 0);
     Assert.Equal(0, actualValue);
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:8,代码来源:UnicodeEncodingGetByteCount1.cs

示例4: NegTest1

 public void NegTest1()
 {
     UnicodeEncoding uEncoding = new UnicodeEncoding();
     int actualValue;
     Assert.Throws<ArgumentNullException>(() =>
     {
         actualValue = uEncoding.GetByteCount(null, 0, 0);
     });
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:9,代码来源:UnicodeEncodingGetByteCount1.cs

示例5: PosTest3

        public void PosTest3()
        {
            Char[] chars = GetCharArray(1);
            UnicodeEncoding uEncoding = new UnicodeEncoding();
            int actualValue;

            actualValue = uEncoding.GetByteCount(chars, 0, 1);
            Assert.Equal(2, actualValue);
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:9,代码来源:UnicodeEncodingGetByteCount1.cs

示例6: PosTest2

        public void PosTest2()
        {
            String str = GetString(10);
            UnicodeEncoding uEncoding = new UnicodeEncoding();
            int actualValue;

            String temp = ToString(str);
            actualValue = uEncoding.GetByteCount(str);
            Assert.Equal(20, actualValue);
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:10,代码来源:UnicodeEncodingGetByteCount2.cs

示例7: NegTest3

 public void NegTest3()
 {
     Char[] chars = GetCharArray(10);
     UnicodeEncoding uEncoding = new UnicodeEncoding();
     int actualValue;
     Assert.Throws<ArgumentOutOfRangeException>(() =>
     {
         actualValue = uEncoding.GetByteCount(chars, 5, -1);
     });
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:10,代码来源:UnicodeEncodingGetByteCount1.cs

示例8: GetByteCount_OverlyLargeCount_ThrowsArgumentOutOfRangeException

 public unsafe void GetByteCount_OverlyLargeCount_ThrowsArgumentOutOfRangeException()
 {
     UnicodeEncoding encoding = new UnicodeEncoding();
     fixed (char* pChars = "abc")
     {
         char* pCharsLocal = pChars;
         Assert.Throws<ArgumentOutOfRangeException>("count", () => encoding.GetByteCount(pCharsLocal, int.MaxValue / 2 + 1));
     }
 }
开发者ID:SGuyGe,项目名称:corefx,代码行数:9,代码来源:UnicodeEncodingEncode.cs

示例9: PosTest1

    public bool PosTest1()
    {
        bool retVal = true;

        UnicodeEncoding uEncoding = new UnicodeEncoding();

        int expectedValue = 0;
        int actualValue;

        TestLibrary.TestFramework.BeginScenario("PosTest1:Invoke the method with a empty String.");
        try
        {
            actualValue = uEncoding.GetByteCount("");

            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,代码来源:unicodeencodinggetbytecount2.cs

示例10: NegTest1

    public bool NegTest1()
    {
        bool retVal = true;

        String str = null;

        UnicodeEncoding uEncoding = new UnicodeEncoding();

        int actualValue;

        TestLibrary.TestFramework.BeginScenario("NegTest1:Invoke the method with null");
        try
        {
            actualValue = uEncoding.GetByteCount(str);

            TestLibrary.TestFramework.LogError("007", "No ArgumentNullException throw out expected.");
            retVal = false;
        }
        catch (ArgumentNullException)
        {

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

示例11: PosTest3

    public bool PosTest3()
    {
        bool retVal = true;

        String str = GetString(1);
        UnicodeEncoding uEncoding = new UnicodeEncoding();

        int expectedValue = 2;
        int actualValue;


        TestLibrary.TestFramework.BeginScenario("PosTest3:Invoke the method with one char String.");
        try
        {
            actualValue = uEncoding.GetByteCount(str);

            if (expectedValue != actualValue)
            {
                TestLibrary.TestFramework.LogError("005", "ExpectedValue(" + expectedValue + ") !=ActualValue(" + actualValue + ") when chars is:" + ToString(str));
                retVal = false;
            }

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

示例12: NegTest3

    public bool NegTest3()
    {
        bool retVal = true;

        Char[] chars = GetCharArray(10);
        UnicodeEncoding uEncoding = new UnicodeEncoding();

        int actualValue;

        TestLibrary.TestFramework.BeginScenario("NegTest3:Invoke the method with count out of range.");
        try
        {
            actualValue = uEncoding.GetByteCount(chars, 5, -1);

            TestLibrary.TestFramework.LogError("011", "No ArgumentOutOfRangeException throw out expected when chars is:" + ToString(chars));
            retVal = false;
        }
        catch (ArgumentOutOfRangeException)
        {

        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("012", "Unexpected exception:" + e + " when chars is:" + ToString(chars));
            retVal = false;
        }
        return retVal;
    } 
开发者ID:l1183479157,项目名称:coreclr,代码行数:28,代码来源:unicodeencodinggetbytecount1.cs

示例13: PosTest2

    public bool PosTest2()
    {
        bool retVal = true;

        Char[] chars = GetCharArray(10);
        UnicodeEncoding uEncoding = new UnicodeEncoding();
        
        int expectedValue = 20;
        int actualValue;


        TestLibrary.TestFramework.BeginScenario("PosTest2:Invoke the method with max length of the char array.");
        try
        {
            actualValue = uEncoding.GetByteCount(chars, 0, chars.Length);

            if (expectedValue != actualValue)
            {
                TestLibrary.TestFramework.LogError("003", "ExpectedValue(" + expectedValue + ") !=ActualValue(" + actualValue + ") when chars is:" + ToString(chars));
                retVal = false;
            }

        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004", "Unexpected exception:" + e + "when chars is:" + ToString(chars));
            retVal = false;
        }
        return retVal;
    }
开发者ID:l1183479157,项目名称:coreclr,代码行数:30,代码来源:unicodeencodinggetbytecount1.cs


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