Example #1
0
 public virtual void TestTrimTrailingWhitespace()
 {
     NUnit.Framework.Assert.AreEqual(0, RawCharUtil.TrimTrailingWhitespace(Sharpen.Runtime.GetBytesForString
                                                                               (string.Empty, "US-ASCII"), 0, 0));
     NUnit.Framework.Assert.AreEqual(0, RawCharUtil.TrimTrailingWhitespace(Sharpen.Runtime.GetBytesForString
                                                                               (" ", "US-ASCII"), 0, 1));
     NUnit.Framework.Assert.AreEqual(1, RawCharUtil.TrimTrailingWhitespace(Sharpen.Runtime.GetBytesForString
                                                                               ("a ", "US-ASCII"), 0, 2));
     NUnit.Framework.Assert.AreEqual(2, RawCharUtil.TrimTrailingWhitespace(Sharpen.Runtime.GetBytesForString
                                                                               (" a ", "US-ASCII"), 0, 3));
     NUnit.Framework.Assert.AreEqual(3, RawCharUtil.TrimTrailingWhitespace(Sharpen.Runtime.GetBytesForString
                                                                               ("  a", "US-ASCII"), 0, 3));
     NUnit.Framework.Assert.AreEqual(6, RawCharUtil.TrimTrailingWhitespace(Sharpen.Runtime.GetBytesForString
                                                                               ("  test   ", "US-ASCII"), 2, 9));
 }
Example #2
0
        public virtual void TestIsWhitespace()
        {
            for (byte c = unchecked ((byte)(-128)); ((sbyte)c) < 127; c++)
            {
                switch (c)
                {
                case unchecked ((byte)(byte)('\r')):
                case unchecked ((byte)(byte)('\n')):
                case unchecked ((byte)(byte)('\t')):
                case unchecked ((byte)(byte)(' ')):
                {
                    NUnit.Framework.Assert.IsTrue(RawCharUtil.IsWhitespace(c));
                    break;
                }

                default:
                {
                    NUnit.Framework.Assert.IsFalse(RawCharUtil.IsWhitespace(c));
                    break;
                }
                }
            }
        }