Skip to content

Commit

Permalink
Add failing test case to show that getMulti fails to ever terminate w…
Browse files Browse the repository at this point in the history
…hen only a single value is present for a key
  • Loading branch information
stevenschlansker committed Mar 19, 2012
1 parent 8f3ac34 commit ec7fa4f
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/test/java/com/g414/hash/file2/TestHashFile2EdgeCases.java
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());
}
}

0 comments on commit ec7fa4f

Please sign in to comment.