### Question:
BitStringComparator extends LdapComparator<String> { public int compare( String bs1, String bs2 ) { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13743_COMPARING_BITSTRING, bs1, bs2 ) ); } if ( bs1 == bs2 ) { return 0; } if ( ( bs1 == null ) || ( bs2 == null ) ) { return bs1 == null ? -1 : 1; } char[] array1 = bs1.toCharArray(); char[] array2 = bs2.toCharArray(); int pos1 = bs1.indexOf( '1' ); int pos2 = bs2.indexOf( '1' ); if ( pos1 == -1 ) { if ( pos2 == -1 ) { return 0; } else { return -1; } } else if ( pos2 == -1 ) { return 1; } int length1 = array1.length - pos1; int length2 = array2.length - pos2; if ( length1 == length2 ) { for ( int i = 0; i < length1; i++ ) { int i1 = i + pos1; int i2 = i + pos2; if ( array1[i1] < array2[i2] ) { return -1; } else if ( array1[i1] > array2[i2] ) { return 1; } } return 0; } if ( length1 < length2 ) { return -1; } else { return 1; } } BitStringComparator( String oid ); int compare( String bs1, String bs2 );  }### Answer:
@Test public void testNullBitString() { assertEquals( 0, comparator.compare( null, null ) ); assertEquals( -1, comparator.compare( null, "0101B" ) ); assertEquals( -1, comparator.compare( null, "000B" ) ); assertEquals( 1, comparator.compare( "0101B", null ) ); assertEquals( 1, comparator.compare( "111B", null ) ); }
@Test public void testBitStringsEquals() { assertEquals( 0, comparator.compare( "0B", "0B" ) ); assertEquals( 0, comparator.compare( "1B", "1B" ) ); assertEquals( 0, comparator.compare( "101010B", "101010B" ) ); assertEquals( 0, comparator.compare( "00000101010B", "00101010B" ) ); }
@Test public void testBitStringsNotEquals() { assertEquals( -1, comparator.compare( "0B", "1B" ) ); assertEquals( 1, comparator.compare( "1B", "0B" ) ); assertEquals( 1, comparator.compare( "101110B", "101010B" ) ); assertEquals( -1, comparator.compare( "00000101010B", "00111010B" ) ); }