### Question:
DittedBitSequence { public int getNumInitialFixedBits(int marked) { if (dits == null) { return 0; } if ((marked <= 0) || (marked > dits.length)) { return 0; } int popcnt = 0; for (int i = 0; i < marked; ++i) { popcnt += popcount[0xff & dits[i]]; } return popcnt; } DittedBitSequence();  DittedBitSequence(String dittedBitData);  DittedBitSequence(String dittedBitData, boolean hex);  DittedBitSequence(DittedBitSequence op2);  DittedBitSequence(byte[] bytes);  DittedBitSequence(byte[] bytes, byte[] mask);  DittedBitSequence(DittedBitSequence s1, DittedBitSequence s2); byte[] getValueBytes(); byte[] getMaskBytes(); @Override int hashCode(); @Override boolean equals(Object obj); DittedBitSequence concatenate(DittedBitSequence op2); boolean isMatch(int pos, int val); int getIndex(); int getSize(); int getNumFixedBits(); int getNumUncertainBits(); void writeBits(StringBuffer buf); @Override String toString(); String getHexString(); int getNumInitialFixedBits(int marked); static int[] popcount; }### Answer:
@Test public void testGetNumInitialFixedBits() { DittedBitSequence uninitialized = new DittedBitSequence(); assertEquals(0, uninitialized.getNumInitialFixedBits(0)); assertEquals(0, uninitialized.getNumInitialFixedBits(1)); DittedBitSequence lengthZero = new DittedBitSequence(new byte[0]); assertEquals(0, lengthZero.getNumInitialFixedBits(0)); assertEquals(0, lengthZero.getNumInitialFixedBits(1)); DittedBitSequence noDits = new DittedBitSequence("0x00ff"); assertEquals(0, noDits.getNumInitialFixedBits(0)); assertEquals(8, noDits.getNumInitialFixedBits(1)); assertEquals(16, noDits.getNumInitialFixedBits(2)); assertEquals(0, noDits.getNumInitialFixedBits(3)); DittedBitSequence someDits = new DittedBitSequence("0.0.0.0.1.1.1.1."); assertEquals(0, someDits.getNumInitialFixedBits(0)); assertEquals(4, someDits.getNumInitialFixedBits(1)); assertEquals(8, someDits.getNumInitialFixedBits(2)); assertEquals(0, someDits.getNumInitialFixedBits(3)); DittedBitSequence allDits = new DittedBitSequence("................"); assertEquals(0, allDits.getNumInitialFixedBits(0)); assertEquals(0, allDits.getNumInitialFixedBits(1)); assertEquals(0, allDits.getNumInitialFixedBits(2)); assertEquals(0, allDits.getNumInitialFixedBits(3)); }