TLongCollection values = map.valueCollection();
assertEquals( map.size(), values.size() );
assertFalse( values.isEmpty() );
assertEquals( values, values );
TLongList values_list = new TLongArrayList( values );
assertFalse( "collections should not be equal: " + values + ", " + values_list,
values.equals( values_list ) );
TLongList list = new TLongArrayList( vals );
values_list.sort();
list.sort();
assertTrue( "collections incorrectly not equal: " + values_list + ", " + list,
values_list.equals( list ) );
assertTrue( "collections incorrectly not equal: " + values_list + ", " + list,
values_list.equals( list ) );
long[] mismatched = {72, 49, 53, 1024, 999};
TLongCollection unequal = new TLongArrayList();
unequal.addAll( mismatched );
assertFalse( "collections incorrectly equal: " + values_list + ", " + unequal,
values_list.equals( unequal ) );
// Change length, different code branch
unequal.add( 1 );
assertFalse( "collections incorrectly equal: " + values_list + ", " + unequal,
values_list.equals( unequal ) );
assertFalse( "values incorrectly equals a random object",
values_list.equals( new Object() ) );
// value in map twice, in list twice.
list = new TLongArrayList( vals );
map.put( 1, vals[0] );
values_list = new TLongArrayList( map.valueCollection() );
list.add( vals[0] );
values_list.sort();
list.sort();
assertTrue( "collections incorrectly not equal: " + values_list + ", " + list,
values_list.equals( list ) );
// value in the map twice, same length list, but value only in list once.
list = new TLongArrayList( vals );
list.add( -1 );
list.sort();
assertFalse( "collections incorrectly equal: " + values_list + ", " + list,
values_list.equals( list ) );
}