Some checks failed
studiorailgun/fluid-sim/pipeline/head There was a failure building this commit
181 lines
6.2 KiB
Java
181 lines
6.2 KiB
Java
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.nio.ByteBuffer;
|
|
|
|
import org.junit.Test;
|
|
|
|
import electrosphere.FluidSim;
|
|
import electrosphere.Main;
|
|
|
|
public class MediumRunTests {
|
|
|
|
@Test
|
|
public void test3by3Chunk1Step(){
|
|
|
|
int dim = 3;
|
|
int maxTimestep = 1;
|
|
|
|
System.out.println("TEST: " + dim + "x" + dim + "x" + dim + " for " + maxTimestep + " steps");
|
|
|
|
//init chunk array
|
|
FluidSim[][][] simArray = FluidSim.initFluidSim(dim,dim,dim);
|
|
|
|
//simulate the chunk
|
|
for(int i = 0; i < maxTimestep; i++){
|
|
FluidSim.simChunks(simArray, i, Main.TIMESTEP);
|
|
}
|
|
|
|
for(int x = 0; x < dim; x++){
|
|
for(int y = 0; y < dim; y++){
|
|
for(int z = 0; z < dim; z++){
|
|
InputStream testFileIS = this.getClass().getResourceAsStream("./testdata/" + dim + "by" + dim + "/" + maxTimestep + "steps/chunk_" + x + "_" + y + "_" + z + "_" + dim + "by" + dim + "Chunk" + maxTimestep + "Step.data");
|
|
byte[] bytes;
|
|
try {
|
|
bytes = testFileIS.readAllBytes();
|
|
ByteBuffer densityBytes = simArray[x][y][z].getDensityBuffer();
|
|
int i = 0;
|
|
while(densityBytes.hasRemaining()){
|
|
boolean pass = bytes[i] == densityBytes.get();
|
|
assert(pass);
|
|
i++;
|
|
}
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
assert(false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
System.out.println("PASSED");
|
|
|
|
}
|
|
|
|
@Test
|
|
public void test3by3Chunk50Step(){
|
|
|
|
int dim = 3;
|
|
int maxTimestep = 50;
|
|
|
|
System.out.println("TEST: " + dim + "x" + dim + "x" + dim + " for " + maxTimestep + " steps");
|
|
|
|
//init chunk array
|
|
FluidSim[][][] simArray = FluidSim.initFluidSim(dim,dim,dim);
|
|
|
|
//simulate the chunk
|
|
for(int i = 0; i < maxTimestep; i++){
|
|
FluidSim.simChunks(simArray, i, Main.TIMESTEP);
|
|
}
|
|
|
|
for(int x = 0; x < dim; x++){
|
|
for(int y = 0; y < dim; y++){
|
|
for(int z = 0; z < dim; z++){
|
|
InputStream testFileIS = this.getClass().getResourceAsStream("./testdata/" + dim + "by" + dim + "/" + maxTimestep + "steps/chunk_" + x + "_" + y + "_" + z + "_" + dim + "by" + dim + "Chunk" + maxTimestep + "Step.data");
|
|
byte[] bytes;
|
|
try {
|
|
bytes = testFileIS.readAllBytes();
|
|
ByteBuffer densityBytes = simArray[x][y][z].getDensityBuffer();
|
|
int i = 0;
|
|
while(densityBytes.hasRemaining()){
|
|
boolean pass = bytes[i] == densityBytes.get();
|
|
assert(pass);
|
|
i++;
|
|
}
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
assert(false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
System.out.println("PASSED");
|
|
|
|
}
|
|
|
|
@Test
|
|
public void test3by3Chunk100Step(){
|
|
|
|
int dim = 3;
|
|
int maxTimestep = 100;
|
|
|
|
System.out.println("TEST: " + dim + "x" + dim + "x" + dim + " for " + maxTimestep + " steps");
|
|
|
|
//init chunk array
|
|
FluidSim[][][] simArray = FluidSim.initFluidSim(dim,dim,dim);
|
|
|
|
//simulate the chunk
|
|
for(int i = 0; i < maxTimestep; i++){
|
|
FluidSim.simChunks(simArray, i, Main.TIMESTEP);
|
|
}
|
|
|
|
for(int x = 0; x < dim; x++){
|
|
for(int y = 0; y < dim; y++){
|
|
for(int z = 0; z < dim; z++){
|
|
InputStream testFileIS = this.getClass().getResourceAsStream("./testdata/" + dim + "by" + dim + "/" + maxTimestep + "steps/chunk_" + x + "_" + y + "_" + z + "_" + dim + "by" + dim + "Chunk" + maxTimestep + "Step.data");
|
|
byte[] bytes;
|
|
try {
|
|
bytes = testFileIS.readAllBytes();
|
|
ByteBuffer densityBytes = simArray[x][y][z].getDensityBuffer();
|
|
int i = 0;
|
|
while(densityBytes.hasRemaining()){
|
|
boolean pass = bytes[i] == densityBytes.get();
|
|
assert(pass);
|
|
i++;
|
|
}
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
assert(false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
System.out.println("PASSED");
|
|
|
|
}
|
|
|
|
@Test
|
|
public void test3by3Chunk500Step(){
|
|
|
|
int dim = 3;
|
|
int maxTimestep = 500;
|
|
|
|
System.out.println("TEST: " + dim + "x" + dim + "x" + dim + " for " + maxTimestep + " steps");
|
|
|
|
//init chunk array
|
|
FluidSim[][][] simArray = FluidSim.initFluidSim(dim,dim,dim);
|
|
|
|
//simulate the chunk
|
|
for(int i = 0; i < maxTimestep; i++){
|
|
FluidSim.simChunks(simArray, i, Main.TIMESTEP);
|
|
}
|
|
|
|
for(int x = 0; x < dim; x++){
|
|
for(int y = 0; y < dim; y++){
|
|
for(int z = 0; z < dim; z++){
|
|
InputStream testFileIS = this.getClass().getResourceAsStream("./testdata/" + dim + "by" + dim + "/" + maxTimestep + "steps/chunk_" + x + "_" + y + "_" + z + "_" + dim + "by" + dim + "Chunk" + maxTimestep + "Step.data");
|
|
byte[] bytes;
|
|
try {
|
|
bytes = testFileIS.readAllBytes();
|
|
ByteBuffer densityBytes = simArray[x][y][z].getDensityBuffer();
|
|
int i = 0;
|
|
while(densityBytes.hasRemaining()){
|
|
boolean pass = bytes[i] == densityBytes.get();
|
|
assert(pass);
|
|
i++;
|
|
}
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
assert(false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
System.out.println("PASSED");
|
|
|
|
}
|
|
|
|
}
|