package com.wizzardo.http.http2;

import com.wizzardo.http.http2.hpack.HpackReader;
import org.junit.Assert;
import org.junit.Test;

/**
 * Created by wizzardo on 10.08.15.
 */
public class HpackReaderTest {

    @Test
    public void test_int_encoding_1() {
        byte[] bytes;

        bytes = new byte[1];

        Assert.assertEquals(8, HpackReader.encode(10, bytes, 3));
        Assert.assertEquals(0b00001010, bytes[0] & 0xff);

        bytes[0] = (byte) 255;
        Assert.assertEquals(8, HpackReader.encode(10, bytes, 3));
        Assert.assertEquals(0b11101010, bytes[0] & 0xff);
    }
}

@@ -590,11 +590,598 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void test_int_encoding_2() %7B%0A        byte%5B%5D bytes;%0A%0A        bytes = new byte%5B3%5D;%0A%0A        Assert.assertEquals(24, HpackReader.encode(1337, bytes, 3));%0A        Assert.assertEquals(0b00011111, bytes%5B0%5D & 0xff);%0A        Assert.assertEquals(0b10011010, bytes%5B1%5D & 0xff);%0A        Assert.assertEquals(0b00001010, bytes%5B2%5D & 0xff);%0A    %7D%0A%0A    @Test%0A    public void test_int_encoding_3() %7B%0A        byte%5B%5D bytes;%0A%0A        bytes = new byte%5B1%5D;%0A%0A        Assert.assertEquals(8, HpackReader.encode(42, bytes, 0));%0A        Assert.assertEquals(0b00101010, bytes%5B0%5D & 0xff);%0A    %7D
 %0A%7D%0A

improve tests