-
Notifications
You must be signed in to change notification settings - Fork 3
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 #49 from clEsperanto/create-tests
Create tests
- Loading branch information
Showing
17 changed files
with
1,400 additions
and
44 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
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,20 @@ | ||
name: ClesperantoJ tests | ||
|
||
on: [push] | ||
|
||
jobs: | ||
test: | ||
runs-on: macos-13 | ||
strategy: | ||
matrix: | ||
java: [8, 11, 17, 21] | ||
name: Test with Java ${{ matrix.java }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Setup java | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: ${{ matrix.java }} | ||
distribution: 'zulu' | ||
- name: Execute the tests | ||
run: mvn clean test -X |
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
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
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
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
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
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
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,49 @@ | ||
import org.junit.jupiter.api.Test; | ||
|
||
import net.clesperanto.kernels.Tier1; | ||
import net.clesperanto.core.MemoryJ; | ||
import net.clesperanto.core.ArrayJ; | ||
import net.clesperanto.core.DeviceJ; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import java.nio.IntBuffer; | ||
import java.util.Arrays; | ||
|
||
public class TestAbsolute { | ||
|
||
@Test | ||
public void testAbsolute() { | ||
DeviceJ device = DeviceJ.getDefaultDevice(); | ||
ArrayJ in = MemoryJ.makeIntBuffer(device, 2, 2, 0, 2, "buffer"); | ||
in.fillMemory(-1); | ||
ArrayJ out = MemoryJ.makeIntBuffer(device, 2, 2, 0, 2, "buffer"); | ||
out.fillMemory(-1); | ||
Tier1.absolute(device, in, out); | ||
|
||
int[] result = new int[4]; | ||
IntBuffer resultBuff = IntBuffer.wrap(result); | ||
MemoryJ.readIntBuffer(out, resultBuff, 4); | ||
|
||
assertEquals(1, Arrays.stream(result).min().getAsInt()); | ||
assertEquals(1, Arrays.stream(result).max().getAsInt()); | ||
assertEquals(1, Arrays.stream(result).average().getAsDouble()); | ||
} | ||
|
||
@Test | ||
public void testAbsolute1() { | ||
DeviceJ device = DeviceJ.getDefaultDevice(); | ||
ArrayJ in = MemoryJ.makeIntBuffer(device, 2, 2, 0, 2, "buffer"); | ||
in.fillMemory(-1); | ||
ArrayJ out = Tier1.absolute(device, in, null); | ||
|
||
int[] result = new int[4]; | ||
IntBuffer resultBuff = IntBuffer.wrap(result); | ||
MemoryJ.readIntBuffer(out, resultBuff, 4); | ||
|
||
for (int val : result) | ||
assertEquals(1, val); | ||
in = null; | ||
out = null; | ||
} | ||
} |
Oops, something went wrong.