@Test
public void testRemove() {

        IntegerUnion mergeTool = new IntegerUnion(0, 50);
        Assert.assertTrue(mergeTool.remove(0));
        check(mergeTool, new Integer[]{1, 50});
        Assert.assertTrue(mergeTool.remove(50));
        check(mergeTool, new Integer[]{1, 49});
        Assert.assertTrue(mergeTool.remove(2));
        check(mergeTool, new Integer[]{1, 1, 3, 49});
        Assert.assertTrue(mergeTool.remove(1));
        check(mergeTool, new Integer[]{3, 49});
        Assert.assertTrue(mergeTool.remove(48));
        check(mergeTool, new Integer[]{3, 47, 49, 49});
        Assert.assertTrue(mergeTool.remove(49));
        check(mergeTool, new Integer[]{3, 47});
        Assert.assertTrue(mergeTool.remove(44));
        check(mergeTool, new Integer[]{3, 43, 45, 47});
        Assert.assertTrue(mergeTool.remove(43));
        check(mergeTool, new Integer[]{3, 42, 45, 47});
        Assert.assertTrue(mergeTool.remove(46));
        check(mergeTool, new Integer[]{3, 42, 45, 45, 47, 47});
        Assert.assertFalse(mergeTool.remove(46));
        Assert.assertTrue(mergeTool.remove(45));
        check(mergeTool, new Integer[]{3, 42, 47, 47});
        Assert.assertTrue(mergeTool.remove(47));
        check(mergeTool, new Integer[]{3, 42});
        mergeTool = new IntegerUnion(0);
        Assert.assertTrue(mergeTool.remove(0));
        check(mergeTool, new Integer[]{});                
        Assert.assertFalse(mergeTool.remove(0));
        
        
        mergeTool = new IntegerUnion();
        mergeTool.add(51);
        mergeTool.add(49);
        mergeTool.remove(48);
        mergeTool.remove(49);
        mergeTool.remove(50);
        check(mergeTool, new Integer[]{51,51});
        
        mergeTool = new IntegerUnion();
        HashSet<Integer> set = new HashSet<Integer>();
        
                        
        for (int i = 51; i < 60; i+=3) {
                Assert.assertTrue(mergeTool.add(i)==set.add(i));
        }
        for (int i = 45; i < 50; i++) {
                Assert.assertTrue(mergeTool.add(i)==set.add(i));             
        }
        for (int i = 45; i < 65; i+=2) {
                Assert.assertTrue("i="+i,mergeTool.remove(i)==set.remove(i));
        }
        Assert.assertTrue(set.containsAll(mergeTool));
}