aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org/traccar/helper/BitBufferTest.java
blob: c2abad36dcc46f1b1d9e9707f9957e42232765fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package org.traccar.helper;

import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class BitBufferTest {
    
    @Test
    public void test() {
        BitBuffer buffer = new BitBuffer();

        buffer.write(0b100100);
        buffer.write(0b110110);
        buffer.write(0b111111);
        buffer.write(0b111111);

        assertEquals(0b100, buffer.readUnsigned(3));
        assertEquals(-7, buffer.readSigned(4));
        assertEquals(0b10110, buffer.readUnsigned(5));
    }

}