-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3f1f844
commit 2cd8f2a
Showing
5 changed files
with
117 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/test/java/com/trivago/fastutilconcurrentwrapper/ConcurrentLongIntMapBuilderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.trivago.fastutilconcurrentwrapper; | ||
|
||
import com.trivago.fastutilconcurrentwrapper.map.ConcurrentBusyWaitingLongIntMap; | ||
import com.trivago.fastutilconcurrentwrapper.map.ConcurrentLongIntMap; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class ConcurrentLongIntMapBuilderTest { | ||
private final int DEFAULT_VALUE = -1; | ||
|
||
@Test | ||
public void buildsBusyWaitingMap() { | ||
ConcurrentLongIntMapBuilder b = ConcurrentLongIntMapBuilder.newBuilder() | ||
.withBuckets(2) | ||
.withDefaultValue(DEFAULT_VALUE) | ||
.withInitialCapacity(100) | ||
.withMode(ConcurrentLongIntMapBuilder.MapMode.BUSY_WAITING) | ||
.withLoadFactor(0.9f); | ||
|
||
LongIntMap map = b.build(); | ||
|
||
map.put(1L, 10); | ||
int v = map.get(1L); | ||
|
||
assertTrue(map instanceof ConcurrentBusyWaitingLongIntMap); | ||
assertEquals(10, v); | ||
assertEquals(map.get(2L), map.getDefaultValue()); | ||
} | ||
|
||
@Test | ||
public void buildsBlockingMap() { | ||
ConcurrentLongIntMapBuilder b = ConcurrentLongIntMapBuilder.newBuilder() | ||
.withBuckets(2) | ||
.withDefaultValue(DEFAULT_VALUE) | ||
.withInitialCapacity(100) | ||
.withMode(ConcurrentLongIntMapBuilder.MapMode.BLOCKING) | ||
.withLoadFactor(0.9f); | ||
|
||
LongIntMap map = b.build(); | ||
|
||
map.put(1L, 10); | ||
long v = map.get(1L); | ||
|
||
assertTrue(map instanceof ConcurrentLongIntMap); | ||
assertEquals(10, v); | ||
assertEquals(map.get(2L), map.getDefaultValue()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters