mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Java-Lang -> Chronicle-Bytes, Chronicle-Values
This commit is contained in:
@@ -16,10 +16,9 @@
|
||||
|
||||
package net.openhft.chronicle.map;
|
||||
|
||||
import net.openhft.lang.model.Byteable;
|
||||
import net.openhft.lang.model.DataValueClasses;
|
||||
import net.openhft.lang.values.IntValue;
|
||||
import net.openhft.lang.values.LongValue;
|
||||
import net.openhft.chronicle.core.values.IntValue;
|
||||
import net.openhft.chronicle.core.values.LongValue;
|
||||
import net.openhft.chronicle.values.Values;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -31,25 +30,23 @@ public class DataKeyValueTest {
|
||||
ChronicleMap<IntValue, LongValue> map =
|
||||
ChronicleMapBuilder.of(IntValue.class, LongValue.class)
|
||||
.entries(1000).create();
|
||||
IntValue heapKey = DataValueClasses.newInstance(IntValue.class);
|
||||
IntValue directKey = DataValueClasses.newDirectInstance(IntValue.class);
|
||||
LongValue heapValue = DataValueClasses.newInstance(LongValue.class);
|
||||
LongValue directValue = DataValueClasses.newDirectInstance(LongValue.class);
|
||||
IntValue heapKey = Values.newHeapInstance(IntValue.class);
|
||||
LongValue heapValue = Values.newHeapInstance(LongValue.class);
|
||||
LongValue directValue = Values.newNativeReference(LongValue.class);
|
||||
|
||||
heapKey.setValue(1);
|
||||
heapValue.setValue(1);
|
||||
map.put(heapKey, heapValue);
|
||||
assertEquals(1, map.get(heapKey).getValue());
|
||||
assertEquals(1, map.getUsing(heapKey, directValue).getValue());
|
||||
assertEquals(1, map.getUsing(heapKey, heapValue).getValue());
|
||||
|
||||
((Byteable) directValue).bytes(null, 0L);
|
||||
directKey.setValue(1);
|
||||
map.getUsing(directKey, directValue).addValue(1);
|
||||
assertEquals(2, map.getUsing(directKey, heapValue).getValue());
|
||||
heapKey.setValue(1);
|
||||
map.getUsing(heapKey, directValue).addValue(1);
|
||||
assertEquals(2, map.getUsing(heapKey, heapValue).getValue());
|
||||
|
||||
directKey.setValue(2);
|
||||
heapKey.setValue(2);
|
||||
heapValue.setValue(3);
|
||||
map.put(directKey, heapValue);
|
||||
assertEquals(3, map.get(directKey).getValue());
|
||||
map.put(heapKey, heapValue);
|
||||
assertEquals(3, map.get(heapKey).getValue());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user