use of org.aion.db.impl.mockdb.MockDB in project aion by aionnetwork.
the class TrieTest method testInsertRandomMultipleItems.
/**
* @param pairs
* @implNote By design the keys are distinct due to the use of HashMap.
*/
@Test
@Parameters(method = "keyValuePairsParameters")
public void testInsertRandomMultipleItems(HashMap<String, String> pairs) {
boolean print = false;
if (print) {
System.out.println("Number of pairs = " + pairs.size());
}
TrieImpl trie = new TrieImpl(new MockDB("TestInsertRandomMultipleItems"));
String key, value;
for (Map.Entry<String, String> entry : pairs.entrySet()) {
key = entry.getKey();
value = entry.getValue();
if (print) {
System.out.println("(" + key + "," + value + ")");
}
// insert (key,value)
trie.update(key, value);
assertThat(new String(trie.get(key))).isEqualTo(value);
}
// ensure that everything is still there
for (Map.Entry<String, String> entry : pairs.entrySet()) {
key = entry.getKey();
value = entry.getValue();
assertThat(new String(trie.get(key))).isEqualTo(value);
}
}
Aggregations