aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org/traccar/helper/BitUtilTest.java
blob: 90431bf55548a3e4c8fb767137d1f9b483ca1a31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package org.traccar.helper;

import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class BitUtilTest {
    
    @Test
    public void testCheck() {
        assertFalse(BitUtil.check(0, 0));
        assertTrue(BitUtil.check(1, 0));
        assertFalse(BitUtil.check(2, 0));
    }
    
    @Test
    public void testBetween() {
        assertEquals(0, BitUtil.between(0, 0, 0));
        assertEquals(1, BitUtil.between(1, 0, 1));
        assertEquals(2, BitUtil.between(2, 0, 2));
        assertEquals(2, BitUtil.between(6, 0, 2));
    }

    @Test
    public void testFrom() {
        assertEquals(1, BitUtil.from(1, 0));
        assertEquals(0, BitUtil.from(1, 1));
    }

    @Test
    public void testTo() {
        assertEquals(2, BitUtil.to(2, 2));
        assertEquals(0, BitUtil.to(2, 1));
    }

}