Beispiel #1
0
        [InlineData(new byte[] { 0xFF, 0xFF, 0x00 })]                   // Encoded with 1 byte too many.
        public void HPack_Integer_TooLarge(byte[] encoded)
        {
            Assert.Throws <HPackDecodingException>(() =>
            {
                var dec = new IntegerDecoder();

                if (!dec.StartDecode((byte)(encoded[0] & 0x7F), 7))
                {
                    for (int i = 1; !dec.Decode(encoded[i]); ++i)
                    {
                    }
                }

                return(dec.Value);
            });
        }
Beispiel #2
0
        public void HPack_IntegerRoundTrip(int value, int bits)
        {
            var decoder = new IntegerDecoder();

            Span <byte> encoded = stackalloc byte[5];

            Assert.True(IntegerEncoder.Encode(value, bits, encoded, out int bytesWritten));

            bool finished = decoder.StartDecode(encoded[0], bits);

            int i = 1;

            for (; !finished && i < encoded.Length; ++i)
            {
                finished = decoder.Decode(encoded[i]);
            }

            Assert.True(finished);
            Assert.Equal(bytesWritten, i);
            Assert.Equal(value, decoder.Value);
        }