Beispiel #1
0
        public void benNumberLengthInBytes()
        {
            int            number = 1635;
            BEncodedNumber num    = number;

            Assert.AreEqual(number.ToString().Length + 2, num.LengthInBytes());
        }
Beispiel #2
0
        public void benNumberEncoding4()
        {
            byte[]         data   = Encoding.UTF8.GetBytes("i-1230e");
            BEncodedNumber number = -1230;

            Assert.AreEqual(7, number.LengthInBytes());
            Assert.IsTrue(Toolbox.ByteMatch(data, number.Encode()));
        }
Beispiel #3
0
        public void benNumberEncoding5()
        {
            byte[]         data   = System.Text.Encoding.UTF8.GetBytes("i-123e");
            BEncodedNumber number = -123;

            Assert.AreEqual(6, number.LengthInBytes());
            Assert.IsTrue(Toolbox.ByteMatch(data, number.Encode()));
        }
Beispiel #4
0
        public void benNumberEncoding3()
        {
            byte[]         data   = System.Text.Encoding.UTF8.GetBytes("i1230e");
            BEncodedNumber number = 1230;

            Assert.Equal(6, number.LengthInBytes());
            Assert.True(Toolbox.ByteMatch(data, number.Encode()));
        }
Beispiel #5
0
        public void BenNumberEncoding2()
        {
            byte[]         data   = Encoding.UTF8.GetBytes("i0e");
            BEncodedNumber number = 0;

            Assert.Equal(3, number.LengthInBytes());
            Assert.True(Toolbox.ByteMatch(data, number.Encode()));
        }
Beispiel #6
0
        public void benNumberEncodingBuffered()
        {
            byte[]         data   = System.Text.Encoding.UTF8.GetBytes("i12345e");
            BEncodedNumber number = 12345;

            byte[] result = new byte[number.LengthInBytes()];
            number.Encode(result, 0);
            Assert.IsTrue(Toolbox.ByteMatch(data, result));
        }
Beispiel #7
0
        public void BenNumberEncodingBuffered()
        {
            var            data   = Encoding.UTF8.GetBytes("i12345e");
            BEncodedNumber number = 12345;
            var            result = new byte[number.LengthInBytes()];

            number.Encode(result, 0);
            Assert.IsTrue(Toolbox.ByteMatch(data, result));
        }
Beispiel #8
0
 public void One() => OneValue.LengthInBytes();
Beispiel #9
0
 public void Zero() => ZeroValue.LengthInBytes();
Beispiel #10
0
 public void Largest() => MaxValue.LengthInBytes();
Beispiel #11
0
 public void Smallest() => MinValue.LengthInBytes();