-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
54 additions
and
0 deletions.
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/img/basictypeaccess/unsafe/ByteUnsafeTest.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.img.basictypeaccess.unsafe; | ||
|
||
import net.imglib2.img.basictypelongaccess.unsafe.ByteUnsafe; | ||
import net.imglib2.img.basictypelongaccess.unsafe.UnsafeUtil; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class ByteUnsafeTest | ||
{ | ||
|
||
private ByteUnsafe b; | ||
|
||
private final Byte startingValue = 5; | ||
|
||
@Before | ||
public void setup() | ||
{ | ||
int numBytes = 8; | ||
// Allocate heap memory for testing | ||
long address = UnsafeUtil.UNSAFE.allocateMemory( 8 ); | ||
|
||
b = new ByteUnsafe( address ); | ||
b.setValue( 0, startingValue ); | ||
for ( int i = 1; i < numBytes; i++ ) | ||
{ | ||
b.setValue( i, ( byte ) 0 ); | ||
} | ||
} | ||
|
||
@After | ||
public void tearDown() | ||
{ | ||
// Free heap memory | ||
UnsafeUtil.UNSAFE.freeMemory( b.getAddres() ); | ||
} | ||
|
||
@Test | ||
public void testByteUnsafeGetValue() | ||
{ | ||
assertEquals( ( long ) startingValue, b.getValue( 0 ) ); | ||
} | ||
|
||
} |