public void testSetLargeValues() { final BitField bf1 = new BitField(0xF), bf2 = new BitField(0xF0000000); int a = 0; a = bf1.setValue(a, 9); a = bf2.setValue(a, 9); assertEquals(9, bf1.getValue(a)); assertEquals(9, bf2.getValue(a)); }
public void testSetValue() { for (int j = 0; j < 128; j++) { assertEquals(bf_multi.getValue(bf_multi.setValue(0, j)), j); assertEquals(bf_multi.setValue(0, j), j << 7); } // verify that excess bits are stripped off assertEquals(bf_multi.setValue(0x3f80, 128), 0); for (int j = 0; j < 2; j++) { assertEquals(bf_single.getValue(bf_single.setValue(0, j)), j); assertEquals(bf_single.setValue(0, j), j << 14); } // verify that excess bits are stripped off assertEquals(bf_single.setValue(0x4000, 2), 0); }
public void testGetValue() { assertEquals(bf_multi.getValue(-1), 127); assertEquals(bf_multi.getValue(0), 0); assertEquals(bf_single.getValue(-1), 1); assertEquals(bf_single.getValue(0), 0); }