-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only on bit of SparseBitmask is true. But SparseBitmask.region().cursor() seems to have two elements?
- Loading branch information
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
src/test/java/net/imglib2/roi/sparse/GrowableTreeTest.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,14 @@ | ||
package net.imglib2.roi.sparse; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class GrowableTreeTest | ||
{ | ||
@Test | ||
public void testCreate() { | ||
GrowableTree tree = new GrowableTree( new int[] { 8, 8, 8 } ); | ||
assertEquals(0, tree.height()); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
src/test/java/net/imglib2/roi/sparse/SparseBitmaskTest.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,50 @@ | ||
package net.imglib2.roi.sparse; | ||
|
||
import net.imglib2.Cursor; | ||
import net.imglib2.RandomAccess; | ||
import net.imglib2.roi.IterableRegion; | ||
import net.imglib2.type.logic.NativeBoolType; | ||
import net.imglib2.util.Localizables; | ||
import org.junit.Test; | ||
|
||
import static junit.framework.TestCase.assertTrue; | ||
import static org.junit.Assert.assertArrayEquals; | ||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
|
||
public class SparseBitmaskTest | ||
{ | ||
@Test | ||
public void testCreate() { | ||
new SparseBitmask( 3 ); | ||
} | ||
|
||
@Test | ||
public void testRandomAccess() { | ||
SparseBitmask bitmask = new SparseBitmask( 3 ); | ||
RandomAccess< NativeBoolType > ra = bitmask.randomAccess(); | ||
ra.get().set( true ); | ||
assertTrue( ra.get().get() ); | ||
ra.get().set( false ); | ||
assertFalse( ra.get().get() ); | ||
} | ||
|
||
|
||
@Test | ||
public void testRegion() { | ||
SparseBitmask bitmask = new SparseBitmask( 3 ); | ||
RandomAccess< NativeBoolType > ra = bitmask.randomAccess(); | ||
final long[] position = { 1, 2, 3 }; | ||
ra.setPosition( position ); | ||
ra.get().set( true ); | ||
final IterableRegion< NativeBoolType > region = bitmask.region(); | ||
Cursor< Void > cursor = region.cursor(); | ||
assertEquals(1, region.size()); | ||
assertTrue( cursor.hasNext() ); | ||
cursor.next(); | ||
assertArrayEquals( position, Localizables.asLongArray( cursor ) ); | ||
assertFalse( cursor.hasNext() ); | ||
} | ||
|
||
|
||
} |