@Test public void testSignedPositive() throws IOException { BitReader bu = new BitReader(new byte[] {32,0,0,0}); assertEquals(2, (int) bu.bits2SInt(4)); }
@Test public void testSignedNegative() throws IOException { BitReader bu = new BitReader(new byte[] {(byte)160,0,0,0}); int binary = (int) bu.bits2SInt(4); assertEquals(-2, binary); }
@Test public void testSignedNegative2() throws IOException { BitReader bu = new BitReader(new byte[] {(byte)71,(byte)200,(byte)235,(byte)216,(byte)128,(byte)0}); assertEquals(574, (int) bu.bits2UInt(11)); assertEquals(570, (int) bu.bits2UInt(11)); assertEquals(-945, (int) bu.bits2SInt(11)); }
@Test @Ignore("why is this failing?") public void testSignedNegative3() throws IOException { BitReader bu = new BitReader(new byte[] {(byte)199,(byte)242,(byte)0,(byte)0,(byte)6,(byte)6}); assertEquals(799, (int) bu.bits2UInt(10)); assertEquals(800, (int) bu.bits2UInt(10)); assertEquals(-344, (int) bu.bits2SInt(10)); }
this.spd[orderOfSPD] = (int) bitReader.bits2SInt(widthOfSPD); this.lengthOfSection6 = GribNumbers.int4(raf); this.section6 = raf.read();