aboutsummaryrefslogtreecommitdiff
path: root/test/org/traccar/helper/BitUtilTest.java
blob: 4aa295e127edbc44c1587d93b55c63860a1ea0c5 (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
package org.traccar.helper;

import org.junit.Assert;
import org.junit.Test;

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

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

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

}