BoundedSetFactory { public BoundedSet<V> top() { return top; } BoundedSetFactory(int limit); BoundedSet<V> empty(); BoundedSet<V> singleton(V el); BoundedSet<V> top();  }
@Test public void testUnsaturatedAdd() { for(int i : TEST_BOUNDS) { BoundedSetFactory<String> bsf = new BoundedSetFactory<String>(i); BoundedSet<String> bs = boundedSet(bsf,0,i-1); String t = getElement(i-1); bs.add(t); assert(bs.isSaturated() == false); assert(bs.getSize() == i); assert(! bsf.top().equals(bs)); } }
@Test public void testUnsaturatedAddAll() { for(int i : TEST_BOUNDS) { BoundedSetFactory<String> bsf = new BoundedSetFactory<String>(i); BoundedSet<String> bs1 = boundedSet(bsf,0,i/2+1); BoundedSet<String> bs2 = boundedSet(bsf,i/2-1,i-1); bs1.addAll(bs2); assert(bs1.isSaturated() == false); assert(bs1.getSize() == i); assert(! bsf.top().equals(bs1)); } }
@Test public void testSaturatedAdd() { for(int i : TEST_BOUNDS) { BoundedSetFactory<String> bsf = new BoundedSetFactory<String>(i); BoundedSet<String> bs = boundedSet(bsf,0,i-1); String t = getElement(i); bs.add(t); assert(bs.isSaturated() == true); assert(bs.getSize() == i+1); assert(bsf.top().equals(bs)); BoundedSet<String> top = bsf.top(); String t2 = getElement(i+1); top.add(t2); assert(top.equals(bs)); assert(bs.equals(top)); } }
@Test public void testSaturatedAddAll() { for(int i : TEST_BOUNDS) { BoundedSetFactory<String> bsf = new BoundedSetFactory<String>(i); BoundedSet<String> bs1 = boundedSet(bsf,0,i/2); BoundedSet<String> bs2 = boundedSet(bsf,i/2,i); BoundedSet<String> top = bsf.top(); bs1.addAll(bs2); top.addAll(bs1); assert(bs1.isSaturated() == true); assert(bs1.getSize() == i+1); assert(top.equals(bs1)); assert(bs1.equals(top)); } }
@Test public void testTop() { for(int i : TEST_BOUNDS) { BoundedSetFactory<String> bsf = new BoundedSetFactory<String>(i); assert(bsf.top().isSaturated()); assert(bsf.top().getSize() == i+1); try { bsf.top().getSet(); fail("Expected failure: top().getSet()"); } catch(Error e) { } } }