예제 #1
0
        public void benStringEncodingBuffered()
        {
            Span <byte> data = Encoding.UTF8.GetBytes("22:this is my test string");

            BEncodedString benString = new BEncodedString("this is my test string");

            byte[] result = new byte[benString.LengthInBytes()];
            benString.Encode(result.AsSpan());
            Assert.IsTrue(data.SequenceEqual(result));
        }
예제 #2
0
        public void benStringLengthInBytes()
        {
            string text = "thisisateststring";

            BEncodedString str    = text;
            int            length = text.Length;

            length += text.Length.ToString().Length;
            length++;

            Assert.AreEqual(length, str.LengthInBytes());
        }