Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test case exhibiting infinite getMulti bug #9

Merged
merged 2 commits into from Mar 19, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/test/java/com/g414/hash/file2/TestHashFile2EdgeCases.java
@@ -0,0 +1,30 @@
package com.g414.hash.file2;

import java.io.File;
import java.util.Iterator;
import org.testng.Assert;
import org.testng.annotations.Test;

@Test
public class TestHashFile2EdgeCases {
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());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expect this to be false, but the iterator says it has more values. It continues to produce the same value forever.

}
}