-
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
10 changed files
with
574 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
63 changes: 63 additions & 0 deletions
63
src/test/java/net/imglib2/img/basictypeaccess/unsafe/BooleanUnsafeTest.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,63 @@ | ||
package net.imglib2.img.basictypeaccess.unsafe; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import net.imglib2.img.basictypelongaccess.unsafe.BooleanUnsafe; | ||
import net.imglib2.img.basictypelongaccess.unsafe.UnsafeUtil; | ||
|
||
/** | ||
* Tests basic {@link BooleanUnsafe} functionality | ||
* | ||
* @author Gabriel Selzer | ||
*/ | ||
public class BooleanUnsafeTest | ||
{ | ||
|
||
private BooleanUnsafe b; | ||
|
||
private long address; | ||
|
||
private final Boolean startingValue = false; | ||
|
||
@Before | ||
public void setup() | ||
{ | ||
// Allocate heap memory for testing | ||
address = UnsafeUtil.UNSAFE.allocateMemory( 8 ); | ||
|
||
b = new BooleanUnsafe( address ); | ||
b.setValue( 0, startingValue ); | ||
} | ||
|
||
@After | ||
public void tearDown() | ||
{ | ||
// Free heap memory | ||
UnsafeUtil.UNSAFE.freeMemory( b.getAddres() ); | ||
} | ||
|
||
@Test | ||
public void testBooleanUnsafeGetValue() | ||
{ | ||
assertEquals( startingValue, b.getValue( 0 ) ); | ||
} | ||
|
||
@Test | ||
public void testBooleanUnsafeSetValue() | ||
{ | ||
boolean newValue = true; | ||
b.setValue( 0, newValue ); | ||
assertEquals( newValue, b.getValue( 0 ) ); | ||
} | ||
|
||
@Test | ||
public void testBooleanUnsafeGetAddress() | ||
{ | ||
assertEquals( address, b.getAddres() ); | ||
} | ||
|
||
} |
62 changes: 62 additions & 0 deletions
62
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,62 @@ | ||
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; | ||
|
||
/** | ||
* Tests basic {@link ByteUnsafe} functionality | ||
* | ||
* @author Gabriel Selzer | ||
*/ | ||
public class ByteUnsafeTest | ||
{ | ||
|
||
private ByteUnsafe b; | ||
|
||
private long address; | ||
|
||
private final Byte startingValue = 5; | ||
|
||
@Before | ||
public void setup() | ||
{ | ||
// Allocate heap memory for testing | ||
address = UnsafeUtil.UNSAFE.allocateMemory( 8 ); | ||
|
||
b = new ByteUnsafe( address ); | ||
b.setValue( 0, startingValue ); | ||
} | ||
|
||
@After | ||
public void tearDown() | ||
{ | ||
// Free heap memory | ||
UnsafeUtil.UNSAFE.freeMemory( b.getAddres() ); | ||
} | ||
|
||
@Test | ||
public void testByteUnsafeGetValue() | ||
{ | ||
assertEquals( ( long ) startingValue, b.getValue( 0 ) ); | ||
} | ||
|
||
@Test | ||
public void testByteUnsafeSetValue() | ||
{ | ||
byte newValue = 6; | ||
b.setValue( 0, newValue ); | ||
assertEquals( newValue, b.getValue( 0 ) ); | ||
} | ||
|
||
@Test | ||
public void testByteUnsafeGetAddress() | ||
{ | ||
assertEquals( address, b.getAddres() ); | ||
} | ||
|
||
} |
63 changes: 63 additions & 0 deletions
63
src/test/java/net/imglib2/img/basictypeaccess/unsafe/CharUnsafeTest.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,63 @@ | ||
package net.imglib2.img.basictypeaccess.unsafe; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import net.imglib2.img.basictypelongaccess.unsafe.CharUnsafe; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import net.imglib2.img.basictypelongaccess.unsafe.UnsafeUtil; | ||
|
||
/** | ||
* Tests basic {@link CharUnsafe} functionality | ||
* | ||
* @author Gabriel Selzer | ||
*/ | ||
public class CharUnsafeTest | ||
{ | ||
|
||
private CharUnsafe c; | ||
|
||
private long address; | ||
|
||
private final Character startingValue = 'a'; | ||
|
||
@Before | ||
public void setup() | ||
{ | ||
// Allocate heap memory for testing | ||
address = UnsafeUtil.UNSAFE.allocateMemory( 8 ); | ||
|
||
c = new CharUnsafe( address ); | ||
c.setValue( 0, startingValue ); | ||
} | ||
|
||
@After | ||
public void tearDown() | ||
{ | ||
// Free heap memory | ||
UnsafeUtil.UNSAFE.freeMemory( c.getAddres() ); | ||
} | ||
|
||
@Test | ||
public void testCharUnsafeGetValue() | ||
{ | ||
assertEquals( ( long ) startingValue, c.getValue( 0 ) ); | ||
} | ||
|
||
@Test | ||
public void testCharUnsafeSetValue() | ||
{ | ||
char newValue = 'b'; | ||
c.setValue( 0, newValue ); | ||
assertEquals( newValue, c.getValue( 0 ) ); | ||
} | ||
|
||
@Test | ||
public void testCharUnsafeGetAddress() | ||
{ | ||
assertEquals( address, c.getAddres() ); | ||
} | ||
|
||
} |
63 changes: 63 additions & 0 deletions
63
src/test/java/net/imglib2/img/basictypeaccess/unsafe/DoubleUnsafeTest.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,63 @@ | ||
package net.imglib2.img.basictypeaccess.unsafe; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import net.imglib2.img.basictypelongaccess.unsafe.DoubleUnsafe; | ||
import net.imglib2.img.basictypelongaccess.unsafe.UnsafeUtil; | ||
|
||
/** | ||
* Tests basic {@link DoubleUnsafe} functionality | ||
* | ||
* @author Gabriel Selzer | ||
*/ | ||
public class DoubleUnsafeTest | ||
{ | ||
|
||
private DoubleUnsafe d; | ||
|
||
private long address; | ||
|
||
private final Double startingValue = 5d; | ||
|
||
@Before | ||
public void setup() | ||
{ | ||
// Allocate heap memory for testing | ||
address = UnsafeUtil.UNSAFE.allocateMemory( 8 ); | ||
|
||
d = new DoubleUnsafe( address ); | ||
d.setValue( 0, startingValue ); | ||
} | ||
|
||
@After | ||
public void tearDown() | ||
{ | ||
// Free heap memory | ||
UnsafeUtil.UNSAFE.freeMemory( d.getAddres() ); | ||
} | ||
|
||
@Test | ||
public void testDoubleUnsafeGetValue() | ||
{ | ||
assertEquals( startingValue, d.getValue( 0 ), 1e-6 ); | ||
} | ||
|
||
@Test | ||
public void testDoubleUnsafeSetValue() | ||
{ | ||
double newValue = 6d; | ||
d.setValue( 0, newValue ); | ||
assertEquals( newValue, d.getValue( 0 ), 1e-6 ); | ||
} | ||
|
||
@Test | ||
public void testDoubleUnsafeGetAddress() | ||
{ | ||
assertEquals( address, d.getAddres() ); | ||
} | ||
|
||
} |
63 changes: 63 additions & 0 deletions
63
src/test/java/net/imglib2/img/basictypeaccess/unsafe/FloatUnsafeTest.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,63 @@ | ||
package net.imglib2.img.basictypeaccess.unsafe; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import net.imglib2.img.basictypelongaccess.unsafe.FloatUnsafe; | ||
import net.imglib2.img.basictypelongaccess.unsafe.UnsafeUtil; | ||
|
||
/** | ||
* Tests basic {@link FloatUnsafe} functionality | ||
* | ||
* @author Gabriel Selzer | ||
*/ | ||
public class FloatUnsafeTest | ||
{ | ||
|
||
private FloatUnsafe f; | ||
|
||
private long address; | ||
|
||
private final Float startingValue = 5f; | ||
|
||
@Before | ||
public void setup() | ||
{ | ||
// Allocate heap memory for testing | ||
address = UnsafeUtil.UNSAFE.allocateMemory( 8 ); | ||
|
||
f = new FloatUnsafe( address ); | ||
f.setValue( 0, startingValue ); | ||
} | ||
|
||
@After | ||
public void tearDown() | ||
{ | ||
// Free heap memory | ||
UnsafeUtil.UNSAFE.freeMemory( f.getAddres() ); | ||
} | ||
|
||
@Test | ||
public void testFloatUnsafeGetValue() | ||
{ | ||
assertEquals( startingValue, f.getValue( 0 ), 1e-6 ); | ||
} | ||
|
||
@Test | ||
public void testFloatUnsafeSetValue() | ||
{ | ||
float newValue = 6f; | ||
f.setValue( 0, newValue ); | ||
assertEquals( newValue, f.getValue( 0 ), 1e-6 ); | ||
} | ||
|
||
@Test | ||
public void testFloatUnsafeGetAddress() | ||
{ | ||
assertEquals( address, f.getAddres() ); | ||
} | ||
|
||
} |
63 changes: 63 additions & 0 deletions
63
src/test/java/net/imglib2/img/basictypeaccess/unsafe/IntUnsafeTest.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,63 @@ | ||
package net.imglib2.img.basictypeaccess.unsafe; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import net.imglib2.img.basictypelongaccess.unsafe.IntUnsafe; | ||
import net.imglib2.img.basictypelongaccess.unsafe.UnsafeUtil; | ||
|
||
/** | ||
* Tests basic {@link IntUnsafe} functionality | ||
* | ||
* @author Gabriel Selzer | ||
*/ | ||
public class IntUnsafeTest | ||
{ | ||
|
||
private IntUnsafe i; | ||
|
||
private long address; | ||
|
||
private final Integer startingValue = 5; | ||
|
||
@Before | ||
public void setup() | ||
{ | ||
// Allocate heap memory for testing | ||
address = UnsafeUtil.UNSAFE.allocateMemory( 8 ); | ||
|
||
i = new IntUnsafe( address ); | ||
i.setValue( 0, startingValue ); | ||
} | ||
|
||
@After | ||
public void tearDown() | ||
{ | ||
// Free heap memory | ||
UnsafeUtil.UNSAFE.freeMemory( i.getAddres() ); | ||
} | ||
|
||
@Test | ||
public void testIntUnsafeGetValue() | ||
{ | ||
assertEquals( ( long ) startingValue, i.getValue( 0 ) ); | ||
} | ||
|
||
@Test | ||
public void testIntUnsafeSetValue() | ||
{ | ||
int newValue = 6; | ||
i.setValue( 0, newValue ); | ||
assertEquals( newValue, i.getValue( 0 ) ); | ||
} | ||
|
||
@Test | ||
public void testIntUnsafeGetAddress() | ||
{ | ||
assertEquals( address, i.getAddres() ); | ||
} | ||
|
||
} |
Oops, something went wrong.