Skip to content

Commit 12b73b9

Browse files
author
Eugen
committed
Merge pull request eugenp#67 from Doha2012/master
Modify Class GuavaCollectionTypesTest
2 parents 900dc84 + 532d279 commit 12b73b9

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

‎guava/src/test/java/org/baeldung/guava/GuavaCollectionTypesTest.java‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,15 @@ public void whenCalculateUnion_thenCorrect() {
120120
assertThat(union, containsInAnyOrder('a', 'b', 'c', 'd'));
121121
}
122122

123+
@Test
124+
public void whenCalculateIntersection_thenCorrect() {
125+
final Set<Character> first = ImmutableSet.of('a', 'b', 'c');
126+
final Set<Character> second = ImmutableSet.of('b', 'c', 'd');
127+
128+
final Set<Character> intersection = Sets.intersection(first, second);
129+
assertThat(intersection, containsInAnyOrder('b', 'c'));
130+
}
131+
123132
@Test
124133
public void whenCalculateSetsProduct_thenCorrect() {
125134
final Set<Character> first = ImmutableSet.of('a', 'b');
@@ -137,6 +146,19 @@ public final String apply(final List<Character> input) {
137146
assertThat(joined, containsInAnyOrder("a c", "a d", "b c", "b d"));
138147
}
139148

149+
@Test
150+
public void whenCalculatePowerSet_thenCorrect() {
151+
final Set<Character> chars = ImmutableSet.of('a', 'b');
152+
final Set<Set<Character>> result = Sets.powerSet(chars);
153+
154+
final Set<Character> empty = ImmutableSet.<Character> builder().build();
155+
final Set<Character> a = ImmutableSet.of('a');
156+
final Set<Character> b = ImmutableSet.of('b');
157+
final Set<Character> aB = ImmutableSet.of('a', 'b');
158+
159+
assertThat(result, contains(empty, a, b, aB));
160+
}
161+
140162
@Test
141163
public void whenCreateRangeOfIntegersSet_thenCreated() {
142164
final int start = 10;

0 commit comments

Comments
 (0)