public TestSortedSetSubSet(int lobound, int hibound) { super("TestSortedSetSubSet"); //System.out.println("SUBSET"); m_Type = TYPE_SUBSET; m_LowBound = lobound; m_HighBound = hibound; int length = hibound - lobound; //System.out.println("Low=" + lobound + "::High=" + hibound + "::Length=" + length); m_FullElements = new Object[length]; System.arraycopy(AbstractTestSortedSet.this.getFullElements(), lobound, m_FullElements, 0, length); m_OtherElements = new Object[length - 1]; System.arraycopy(//src src_pos dst dst_pos length AbstractTestSortedSet.this.getOtherElements(), lobound, m_OtherElements, 0, length - 1); //System.out.println(new TreeSet(Arrays.asList(m_FullElements))); //System.out.println(new TreeSet(Arrays.asList(m_OtherElements))); }
public boolean isAddSupported() { return AbstractTestSortedSet.this.isAddSupported(); } public boolean isRemoveSupported() {
public boolean isFailFastSupported() { return AbstractTestSortedSet.this.isFailFastSupported(); }
private SortedSet getSubSet(SortedSet set) { Object[] elements = AbstractTestSortedSet.this.getFullElements(); switch (m_Type) { case TYPE_SUBSET : return set.subSet(elements[m_LowBound], elements[m_HighBound]); case TYPE_HEADSET : return set.headSet(elements[m_HighBound]); case TYPE_TAILSET : return set.tailSet(elements[m_LowBound]); default : return null; } }
public boolean isNullSupported() { return AbstractTestSortedSet.this.isNullSupported(); } public boolean isAddSupported() {
public boolean isRemoveSupported() { return AbstractTestSortedSet.this.isRemoveSupported(); } public boolean isFailFastSupported() {
public Set makeEmptySet() { SortedSet s = (SortedSet) AbstractTestSortedSet.this.makeEmptySet(); return getSubSet(s); }
public Set makeFullSet() { SortedSet s = (SortedSet) AbstractTestSortedSet.this.makeFullCollection(); return getSubSet(s); }
/** * Verification extension, will check the order of elements, * the sets should already be verified equal. */ public void verify() { super.verify(); // Check that iterator returns elements in order and first() and last() // are consistent Iterator colliter = collection.iterator(); Iterator confiter = confirmed.iterator(); Object first = null; Object last = null; while (colliter.hasNext()) { if (first == null) { first = colliter.next(); last = first; } else { last = colliter.next(); } assertEquals("Element appears to be out of order.", last, confiter.next()); } if (collection.size() > 0) { assertEquals("Incorrect element returned by first().", first, ((SortedSet) collection).first()); assertEquals("Incorrect element returned by last().", last, ((SortedSet) collection).last()); } }
/** * Bulk test {@link SortedSet#tailSet(Object)}. This method runs through all of * the tests in {@link AbstractTestSortedSet}. * After modification operations, {@link #verify()} is invoked to ensure * that the set and the other collection views are still valid. * * @return a {@link AbstractTestSet} instance for testing a tailset. */ public BulkTest bulkTestSortedSetTailSet() { int length = getFullElements().length; int lobound = length / 3; return new TestSortedSetSubSet(lobound, false); }
m_HighBound = bound; m_FullElements = new Object[bound]; System.arraycopy(AbstractTestSortedSet.this.getFullElements(), 0, m_FullElements, 0, bound); m_OtherElements = new Object[bound - 1]; AbstractTestSortedSet.this.getOtherElements(), 0, m_OtherElements, 0, bound - 1); Object[] allelements = AbstractTestSortedSet.this.getFullElements(); m_OtherElements = new Object[allelements.length - bound - 1]; AbstractTestSortedSet.this.getOtherElements(), bound, m_OtherElements, 0, allelements.length - bound - 1);
/** * Bulk test {@link SortedSet#subSet(Object, Object)}. This method runs through all of * the tests in {@link AbstractTestSortedSet}. * After modification operations, {@link #verify()} is invoked to ensure * that the set and the other collection views are still valid. * * @return a {@link AbstractTestSet} instance for testing a subset. */ public BulkTest bulkTestSortedSetSubSet() { int length = getFullElements().length; int lobound = length / 3; int hibound = lobound * 2; return new TestSortedSetSubSet(lobound, hibound); }
/** * Bulk test {@link SortedSet#headSet(Object)}. This method runs through all of * the tests in {@link AbstractTestSortedSet}. * After modification operations, {@link #verify()} is invoked to ensure * that the set and the other collection views are still valid. * * @return a {@link AbstractTestSet} instance for testing a headset. */ public BulkTest bulkTestSortedSetHeadSet() { int length = getFullElements().length; int lobound = length / 3; int hibound = lobound * 2; return new TestSortedSetSubSet(hibound, true); }