add method isEmpty to PersistentMap
This commit is contained in:
@@ -375,6 +375,29 @@ public class PersistentMapTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsEmpty() throws IOException {
|
||||
final Path file = dataDirectory.resolve("map.db");
|
||||
try (final PersistentMap<Long, Long> map = new PersistentMap<>(file, dataDirectory, PersistentMap.LONG_CODER,
|
||||
PersistentMap.LONG_CODER)) {
|
||||
Assertions.assertTrue(map.isEmpty(), "new created map is empty");
|
||||
}
|
||||
|
||||
try (final PersistentMap<Long, Long> map = new PersistentMap<>(file, dataDirectory, PersistentMap.LONG_CODER,
|
||||
PersistentMap.LONG_CODER)) {
|
||||
Assertions.assertTrue(map.isEmpty(), "map is empty after reading an empty map from disk");
|
||||
|
||||
map.putValue(1L, 2L);
|
||||
|
||||
Assertions.assertFalse(map.isEmpty(), "map is empty after putting a value");
|
||||
}
|
||||
|
||||
try (final PersistentMap<Long, Long> map = new PersistentMap<>(file, dataDirectory, PersistentMap.LONG_CODER,
|
||||
PersistentMap.LONG_CODER)) {
|
||||
Assertions.assertFalse(map.isEmpty(), "map is empty when reading a non empty map from disk");
|
||||
}
|
||||
}
|
||||
|
||||
private void assertValuesInMap(final Map<Long, Long> insertedValues, final PersistentMap<Long, Long> map) {
|
||||
final AtomicInteger counter = new AtomicInteger();
|
||||
final AtomicInteger maxDepth = new AtomicInteger();
|
||||
|
||||
Reference in New Issue
Block a user