|
38 | 38 | * @author Christoph Strobl
|
39 | 39 | * @author Thomas Darimont
|
40 | 40 | * @author Mark Paluch
|
| 41 | + * @author Mingi Lee |
41 | 42 | */
|
42 | 43 | @ParameterizedClass
|
43 | 44 | @MethodSource("testParams")
|
@@ -329,6 +330,38 @@ void intersectAndStoreShouldReturnNumberOfElementsInDestination() {
|
329 | 330 | assertThat(setOps.intersectAndStore(Arrays.asList(sourceKey1, sourceKey2), destinationKey)).isEqualTo(2L);
|
330 | 331 | }
|
331 | 332 |
|
| 333 | + @Test // GH-2906 |
| 334 | + @EnabledOnCommand("SINTERCARD") |
| 335 | + void intersectSizeShouldReturnIntersectionCardinality() { |
| 336 | + |
| 337 | + K sourceKey1 = keyFactory.instance(); |
| 338 | + K sourceKey2 = keyFactory.instance(); |
| 339 | + K sourceKey3 = keyFactory.instance(); |
| 340 | + |
| 341 | + V v1 = valueFactory.instance(); |
| 342 | + V v2 = valueFactory.instance(); |
| 343 | + V v3 = valueFactory.instance(); |
| 344 | + V v4 = valueFactory.instance(); |
| 345 | + V v5 = valueFactory.instance(); |
| 346 | + |
| 347 | + setOps.add(sourceKey1, v1, v2, v3); |
| 348 | + setOps.add(sourceKey2, v2, v3, v4); |
| 349 | + setOps.add(sourceKey3, v3, v4, v5); |
| 350 | + |
| 351 | + // Test two keys intersection |
| 352 | + assertThat(setOps.intersectSize(sourceKey1, sourceKey2)).isEqualTo(2L); |
| 353 | + |
| 354 | + // Test key and collection intersection |
| 355 | + assertThat(setOps.intersectSize(sourceKey1, Arrays.asList(sourceKey2, sourceKey3))).isEqualTo(1L); |
| 356 | + |
| 357 | + // Test collection intersection |
| 358 | + assertThat(setOps.intersectSize(Arrays.asList(sourceKey1, sourceKey2, sourceKey3))).isEqualTo(1L); |
| 359 | + |
| 360 | + // Test empty intersection |
| 361 | + K emptyKey = keyFactory.instance(); |
| 362 | + assertThat(setOps.intersectSize(sourceKey1, emptyKey)).isEqualTo(0L); |
| 363 | + } |
| 364 | + |
332 | 365 | @Test // GH-2037
|
333 | 366 | @EnabledOnCommand("SMISMEMBER")
|
334 | 367 | void isMember() {
|
|
0 commit comments