Beispiel #1
0
        public void benNumberEncoding()
        {
            byte[]         data   = Encoding.UTF8.GetBytes("i12345e");
            BEncodedNumber number = 12345;

            Assert.IsTrue(Toolbox.ByteMatch(data, number.Encode()));
        }
Beispiel #2
0
        public void benNumberEncoding6()
        {
            BEncodedNumber a = -123;
            BEncodedNumber b = BEncodedNumber.Decode <BEncodedNumber>(a.Encode());

            Assert.AreEqual(a.Number, b.Number, "#1");
        }
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 benNumberEncoding4()
        {
            byte[]         data   = Encoding.UTF8.GetBytes("i-1230e");
            BEncodedNumber number = -1230;

            Assert.AreEqual(7, number.LengthInBytes());
            Assert.IsTrue(Toolbox.ByteMatch(data, number.Encode()));
        }
Beispiel #5
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 #6
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 #7
0
        public void BenNumberEncoding6()
        {
            BEncodedNumber actual = -123;

            var number = BEncodedValue.Decode <BEncodedNumber>(actual.Encode());

            Assert.AreEqual(actual.Number, number.Number, "#1");
        }
Beispiel #8
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 #9
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 #10
0
 public void One() => OneValue.Encode(buffer);
Beispiel #11
0
 public void Zero() => ZeroValue.Encode(buffer);
Beispiel #12
0
 public void Smallest() => MinValue.Encode(buffer);
Beispiel #13
0
 public BEncodedNumberBenchmark()
 {
     MaxValue.Encode(buffer);
 }