B.setBit(values.get(i).intValue());
/** * Test method: long getSelect1(int i) * * @throws Exception */ public void testGetSelect1() throws Exception { BitMap instance = new BitMap(2048); ArrayList<Long> test = new ArrayList<Long>(); for (int i = 0; i < 2048; i++) { if ((int) (Math.random() * 2) == 1) { instance.setBit(i); test.add((long) i); } } for (int i = 0; i < test.size(); i++) { assertEquals(instance.getSelect1(i), (long) test.get(i)); } }
/** * Test method: long getRank1(int i) * * @throws Exception */ public void testGetRank1() throws Exception { BitMap instance = new BitMap(2048); ArrayList<Long> test = new ArrayList<Long>(); long count = 0; for (int i = 0; i < 2048; i++) { if ((int) (Math.random() * 2) == 1) { instance.setBit(i); count++; } test.add(count); } for (int i = 0; i < test.size(); i++) { assertEquals(instance.getRank1(i), (long) test.get(i)); } }
/** * Test method: void setBit(int pos) * Test method: long getBit(int pos) * * @throws Exception */ public void testSetAndGetBit() throws Exception { BitMap instance = new BitMap(1000L); ArrayList<Long> test = new ArrayList<Long>(); for (int i = 0; i < 1000; i++) { if ((int) (Math.random() * 2) == 1) { instance.setBit(i); test.add(1L); } else { test.add(0L); } } for (int i = 0; i < 1000; i++) { long expResult = test.get(i); long result = instance.getBit(i); assertEquals(expResult, result); } }
/** * Test method: long getSelect0(int i) * * @throws Exception */ public void testGetSelect0() throws Exception { BitMap instance = new BitMap(2048); ArrayList<Long> test = new ArrayList<Long>(); for (int i = 0; i < 2048; i++) { if ((int) (Math.random() * 2) == 1) { instance.setBit(i); } else { test.add((long) i); } } for (int i = 0; i < test.size(); i++) { assertEquals(instance.getSelect0(i), (long) test.get(i)); } }
/** * Test method: long getRank0(int i) * * @throws Exception */ public void testGetRank0() throws Exception { BitMap instance = new BitMap(2048); ArrayList<Long> test = new ArrayList<Long>(); long count = 0; for (int i = 0; i < 2048; i++) { if ((int) (Math.random() * 2) == 1) { instance.setBit(i); } else { count++; } test.add(count); } for (int i = 0; i < test.size(); i++) { assertEquals(instance.getRank0(i), (long) test.get(i)); } }
/** * Test method: long getBit(LongBuffer bitmap, int i) * * @throws Exception */ public void testGetBit() throws Exception { BitMap instance = new BitMap(1000L); ArrayList<Long> test = new ArrayList<Long>(); for (int i = 0; i < 1000; i++) { if ((int) (Math.random() * 2) == 1) { instance.setBit(i); test.add(1L); } else { test.add(0L); } } LongBuffer bBuf = instance.getLongBuffer(); for (int i = 0; i < 1000; i++) { long expResult = test.get(i); long result = BitMapOps.getBit(bBuf, i); assertEquals(expResult, result); } }
/** * Test method: getSelect0(ByteBuffer buf, int startPos, int i) * * @throws Exception */ public void testGetSelect0() throws Exception { BitMap B = new BitMap(2048); ArrayList<Long> test = new ArrayList<Long>(); for (int i = 0; i < 2048; i++) { if ((int) (Math.random() * 2) == 1) { B.setBit(i); } else { test.add((long) i); } } Dictionary D = new Dictionary(B); ByteBuffer dBuf = D.getByteBuffer(); for (int i = 0; i < test.size(); i++) { assertEquals(DictionaryOps.getSelect0(dBuf, 0, i), (long) test.get(i)); } } }
/** * Test method: getSelect1(ByteBuffer buf, int startPos, int i) * * @throws Exception */ public void testGetSelect1() throws Exception { BitMap B = new BitMap(2048); ArrayList<Long> test = new ArrayList<Long>(); for (int i = 0; i < 2048; i++) { if ((int) (Math.random() * 2) == 1) { B.setBit(i); test.add((long) i); } } Dictionary D = new Dictionary(B); ByteBuffer dBuf = D.getByteBuffer(); for (int i = 0; i < test.size(); i++) { assertEquals(DictionaryOps.getSelect1(dBuf, 0, i), (long) test.get(i)); } }
/** * Test method: void clear() * * @throws Exception */ public void testClear() throws Exception { BitMap instance = new BitMap(1000L); for (int i = 0; i < 1000; i++) { if ((int) (Math.random() * 2) == 1) { instance.setBit(i); } } instance.clear(); for (int i = 0; i < 1000; i++) { assertEquals(instance.getBit(i), 0L); } }
/** * Test method: ByteBuffer getByteBuffer() * * @throws Exception */ public void testGetByteBuffer() throws Exception { BitMap B = new BitMap(2048); for (int i = 0; i < 2048; i++) { if ((int) (Math.random() * 2) == 1) { B.setBit(i); } } ByteBuffer instance = new Dictionary(B).getByteBuffer(); assertNotNull(instance); } }
/** * Test method: LongBuffer getLongBuffer() * * @throws Exception */ public void testGetLongBuffer() throws Exception { BitMap instance = new BitMap(1000L); for (int i = 0; i < 1000; i++) { if ((int) (Math.random() * 2) == 1) { instance.setBit(i); } } LongBuffer bBuf = instance.getLongBuffer(); assertNotNull(bBuf); for (int i = 0; i < instance.bitmapSize(); i++) { assertEquals(bBuf.get(i), instance.data[i]); } }
/** * Test method: long getRank1(int i) * * @throws Exception */ public void testGetRank1() throws Exception { BitMap B = new BitMap(2048); for (int i = 0; i < 2048; i++) { if ((int) (Math.random() * 2) == 1) { B.setBit(i); } } Dictionary instance = new Dictionary(B); for (int i = 0; i < 2048; i++) { assertEquals(B.getRank1(i), instance.getRank1(i)); } }
/** * Test method: long getRank0(int i) * * @throws Exception */ public void testGetRank0() throws Exception { BitMap B = new BitMap(2048); for (int i = 0; i < 2048; i++) { if ((int) (Math.random() * 2) == 1) { B.setBit(i); } } Dictionary instance = new Dictionary(B); for (int i = 0; i < 2048; i++) { assertEquals(B.getRank0(i), instance.getRank0(i)); } }
/** * Test method: getRank0(ByteBuffer buf, int startPos, int i) * * @throws Exception */ public void testGetRank0() throws Exception { BitMap B = new BitMap(2048); for (int i = 0; i < 2048; i++) { if ((int) (Math.random() * 2) == 1) { B.setBit(i); } } Dictionary D = new Dictionary(B); ByteBuffer dBuf = D.getByteBuffer(); for (int i = 0; i < 2048; i++) { assertEquals(DictionaryOps.getRank0(dBuf, 0, i), D.getRank0(i)); } }
/** * Test method: getRank1(ByteBuffer buf, int startPos, int i) * * @throws Exception */ public void testGetRank1() throws Exception { BitMap B = new BitMap(2048); for (int i = 0; i < 2048; i++) { if ((int) (Math.random() * 2) == 1) { B.setBit(i); } } Dictionary D = new Dictionary(B); ByteBuffer dBuf = D.getByteBuffer(); for (int i = 0; i < 2048; i++) { assertEquals(DictionaryOps.getRank1(dBuf, 0, i), D.getRank1(i)); } }