@Override @Test public void intersect() { Assert.assertEquals( UnifiedSet.<String>newSet(), this.classUnderTest().intersect(UnifiedSet.newSetWith(1, 2, 3))); }
@Override @Test public void symmetricDifference() { Assert.assertEquals( UnifiedSet.newSetWith(999), this.classUnderTest().symmetricDifference(UnifiedSet.newSetWith(999))); }
@Override @Test public void union() { Assert.assertEquals( UnifiedSet.newSetWith(1, 2, 3), this.classUnderTest().union(UnifiedSet.newSetWith(1, 2, 3))); }
@Override @Test public void difference() { ImmutableSet<Integer> set = this.classUnderTest(); ImmutableSet<Integer> difference = set.difference(UnifiedSet.newSetWith(1, 2, 3, 999)); Assert.assertEquals(UnifiedSet.<Integer>newSet(), difference); Assert.assertEquals(set, set.difference(UnifiedSet.newSetWith(999))); }
@Override @Test public void unionInto() { Assert.assertEquals( UnifiedSet.newSetWith(1, 2, 3), this.classUnderTest() .unionInto(UnifiedSet.newSetWith(1, 2, 3), UnifiedSet.<Integer>newSet())); }
@Override @Test public void zipWithIndex() { ImmutableSet<Integer> immutableSet = this.classUnderTest(); ImmutableSet<Pair<Integer, Integer>> pairs = immutableSet.zipWithIndex(); Assert.assertEquals(immutableSet, pairs.transform(Functions.<Integer>firstOfPair())); Assert.assertEquals( UnifiedSet.<Integer>newSet(), pairs.transform(Functions.<Integer>secondOfPair())); Assert.assertEquals( immutableSet.zipWithIndex(), immutableSet.zipWithIndex(UnifiedSet.<Pair<Integer, Integer>>newSet())); }
@Override @Test public void zip() { ImmutableSet<Integer> immutableSet = this.classUnderTest(); List<Object> nulls = Collections.nCopies(immutableSet.size(), null); List<Object> nullsPlusOne = Collections.nCopies(immutableSet.size() + 1, null); ImmutableSet<Pair<Integer, Object>> pairs = immutableSet.zip(nulls); Assert.assertEquals(immutableSet, pairs.transform(Functions.<Integer>firstOfPair())); Assert.assertEquals( UnifiedSet.<Object>newSet(nulls), pairs.transform(Functions.<Object>secondOfPair())); ImmutableSet<Pair<Integer, Object>> pairsPlusOne = immutableSet.zip(nullsPlusOne); Assert.assertEquals(immutableSet, pairsPlusOne.transform(Functions.<Integer>firstOfPair())); Assert.assertEquals( UnifiedSet.<Object>newSet(nulls), pairsPlusOne.transform(Functions.<Object>secondOfPair())); Assert.assertEquals( immutableSet.zip(nulls), immutableSet.zip(nulls, UnifiedSet.<Pair<Integer, Object>>newSet())); }
@Test public void testContainsAll() { Assert.assertTrue(this.classUnderTest().castToSet().containsAll(new HashSet<Object>())); Assert.assertFalse(this.classUnderTest().castToSet().containsAll(UnifiedSet.newSetWith(1))); }