### Question:
GP4Parser implements Parser { protected int getStringIndexFromStringCode(int stringCode, int index) { int tmpIndex = index; for (int i = 0; i < GP4_NUMBER_OF_STRING; i++) { if ((stringCode & (1 << i)) != 0) { if (tmpIndex == 0) { return i; } else { tmpIndex--; } } } return -1; }  void close(); void openFile(File file); @Inject void setListener(GP4ParserListener listener); static final int VERSION_LENGTH; }### Answer:
@Test public void testGetStringIndexFromStringCode() { int stringCode = 0; int index = 0; int stringIndex = 0; stringCode = 2; stringIndex = instance.getStringIndexFromStringCode(stringCode, index); Assert.assertEquals(stringIndex, 1); stringCode = 4; stringIndex = instance.getStringIndexFromStringCode(stringCode, index); Assert.assertEquals(stringIndex, 2); stringCode = 8; stringIndex = instance.getStringIndexFromStringCode(stringCode, index); Assert.assertEquals(stringIndex, 3); stringCode = 64; stringIndex = instance.getStringIndexFromStringCode(stringCode, index); Assert.assertEquals(stringIndex, 6); index = 0; stringCode = 0xC; stringIndex = instance.getStringIndexFromStringCode(stringCode, index); Assert.assertEquals(stringIndex, 2); stringCode = 0xC; index = 1; stringIndex = instance.getStringIndexFromStringCode(stringCode, index); Assert.assertEquals(stringIndex, 3); stringIndex = instance.getStringIndexFromStringCode(2, 1); Assert.assertEquals(stringIndex, -1); }