-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add failing test case to show that getMulti fails to ever terminate w…
…hen only a single value is present for a key
- Loading branch information
1 parent
8f3ac34
commit ec7fa4f
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
src/test/java/com/g414/hash/file2/TestHashFile2EdgeCases.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,34 @@ | ||
package com.g414.hash.file2; | ||
|
||
import java.io.File; | ||
import java.util.Iterator; | ||
import org.testng.Assert; | ||
import org.testng.annotations.Test; | ||
|
||
import com.g414.hash.impl.MurmurHash; | ||
|
||
@Test | ||
public class TestHashFile2EdgeCases { | ||
MurmurHash hash = new MurmurHash(); | ||
|
||
public void testSingleEntryMultiGet() throws Exception { | ||
File tmp = File.createTempFile("hhhhhh", "ff"); | ||
tmp.deleteOnExit(); | ||
|
||
HashFile2Builder hashWrite = new HashFile2Builder(tmp.getAbsolutePath(), 1000); | ||
|
||
byte[] key = new byte[] { 1, 2, 3, 4, 5 }; | ||
byte[] value = new byte[] { 5, 4, 3, 2, 1 }; | ||
hashWrite.add(key, value); | ||
|
||
hashWrite.finish(); | ||
|
||
HashFile2 file = new HashFile2(tmp.getAbsolutePath()); | ||
|
||
Iterator<byte[]> iter = file.getMulti(key).iterator(); | ||
|
||
Assert.assertTrue(iter.hasNext()); | ||
Assert.assertEquals(iter.next(), value); | ||
Assert.assertFalse(iter.hasNext()); | ||
} | ||
} |