@Test
public void testDecoderAncestors() {
HierarchyEncoder encoder = new HierarchyEncoderImpl();
encoder.encode( "Thing", Collections.EMPTY_LIST );
encoder.encode( "A", Arrays.asList( "Thing" ) );
encoder.encode( "Z", Arrays.asList( "Thing" ) );
encoder.encode( "B", Arrays.asList( "A", "Z" ) );
encoder.encode( "C", Arrays.asList( "A", "Z" ) );
encoder.encode( "N", Arrays.asList( "B", "C" ) );
encoder.encode( "P", Arrays.asList( "Thing" ) );
encoder.encode( "Q", Arrays.asList( "Thing" ) );
encoder.encode( "R", Arrays.asList( "Thing" ) );
encoder.encode( "S", Arrays.asList( "R" ) );
encoder.encode( "T", Arrays.asList( "C", "Q" ) );
encoder.encode( "M", Arrays.asList( "R", "Q" ) );
encoder.encode( "O", Arrays.asList( "M", "P" ) );
System.out.println( encoder );
BitSet b;
Collection x;
b = parseBitSet( "1100111" );
x = encoder.upperAncestors(b);
System.out.println( "ANC " + x );
assertTrue( x.contains( "A" ) );
assertTrue( x.contains( "Z" ) );
assertTrue( x.contains( "C" ) );
assertTrue( x.contains( "Q" ) );
assertTrue( x.contains( "T" ) );
assertTrue( x.contains( "R" ) );
assertTrue( x.contains( "S" ) );
assertTrue( x.contains( "M" ) );
assertTrue( x.contains( "Thing" ) );
assertEquals( 9, x.size() );
b = parseBitSet( "100000" );
x = encoder.upperAncestors(b);
System.out.println( "ANC " + x );
assertEquals( 2, x.size() );
assertTrue( x.contains( "Q" ) );
assertTrue( x.contains( "Thing" ) );
b = parseBitSet( "1111" );
x = encoder.upperAncestors(b);
System.out.println( "ANC " + x );
assertEquals( 6, x.size() );
assertTrue( x.contains( "A" ) );
assertTrue( x.contains( "Z" ) );
assertTrue( x.contains( "B" ) );
assertTrue( x.contains( "C" ) );
assertTrue( x.contains( "N" ) );
assertTrue( x.contains( "Thing" ) );
b = parseBitSet( "111" );
x = encoder.upperAncestors(b);
System.out.println( "ANC " + x );
assertEquals( 4, x.size() );
assertTrue( x.contains( "A" ) );
assertTrue( x.contains( "Z" ) );
assertTrue( x.contains( "C" ) );
assertTrue( x.contains( "Thing" ) );
b = parseBitSet( "1" );
x = encoder.upperAncestors(b);
System.out.println( "ANC " + x );
assertEquals( 2, x.size() );
assertTrue( x.contains( "A" ) );
assertTrue( x.contains( "Thing" ) );
b = parseBitSet( "10" );
x = encoder.upperAncestors(b);
System.out.println( "ANC " + x );
assertEquals( 2, x.size() );
assertTrue( x.contains( "Z" ) );
assertTrue( x.contains( "Thing" ) );
b = parseBitSet( "0" );
x = encoder.upperAncestors(b);
System.out.println( "ANC " + x );
assertEquals( 1, x.size() );
assertTrue( x.contains( "Thing" ) );
b = parseBitSet( "1011" );
x = encoder.upperAncestors(b);
System.out.println( "ANC " + x );
assertEquals( 4, x.size() );
assertTrue( x.contains( "Thing" ) );
assertTrue( x.contains( "A" ) );