-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from saalfeldlab/fix/bufferOverflow
fix: incorrect size when initialized with long[] length 0
- Loading branch information
Showing
2 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
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
46 changes: 46 additions & 0 deletions
46
src/test/java/net/imglib2/type/label/LabelMultisetEntryListTest.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,46 @@ | ||
package net.imglib2.type.label; | ||
|
||
import com.google.common.collect.Streams; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashSet; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
import java.util.Random; | ||
import java.util.Set; | ||
import java.util.stream.Stream; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class LabelMultisetEntryListTest { | ||
|
||
@Test | ||
public void sizeCheck() { | ||
|
||
LabelMultisetEntryList lmel = new LabelMultisetEntryList(); | ||
assertEquals(0, lmel.size()); | ||
|
||
LongMappedAccessData listData = LongMappedAccessData.factory.createStorage(0); | ||
lmel = new LabelMultisetEntryList(listData, 0); | ||
assertEquals(0, lmel.size()); | ||
|
||
listData = LongMappedAccessData.factory.createStorage(16); | ||
lmel = new LabelMultisetEntryList(listData, 0); | ||
assertEquals(0, lmel.size()); | ||
|
||
listData = LongMappedAccessData.factory.createStorage(16); | ||
lmel = new LabelMultisetEntryList(listData, 0); | ||
lmel.add(new LabelMultisetEntry(1, 10)); | ||
assertEquals(1, lmel.size()); | ||
|
||
listData = LongMappedAccessData.factory.createStorage(0); | ||
lmel = new LabelMultisetEntryList(listData, 0); | ||
lmel.add(new LabelMultisetEntry(1, 10)); | ||
lmel.add(new LabelMultisetEntry(1, 10)); | ||
lmel.add(new LabelMultisetEntry(2, 10)); | ||
assertEquals(2, lmel.size()); | ||
} | ||
|
||
} |