186 lines
6.7 KiB
Java
186 lines
6.7 KiB
Java
|
|
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.nio.ByteBuffer;
|
|
|
|
import org.junit.Test;
|
|
|
|
import electrosphere.FluidSim;
|
|
import electrosphere.Main;
|
|
|
|
/**
|
|
* Tests stepping a single chunk by a single frame
|
|
*/
|
|
public class ShortRunTest {
|
|
|
|
// @Test
|
|
// public void test1by1Chunk1Step(){
|
|
|
|
// int dim = 1;
|
|
// 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 test1by1Chunk50Step(){
|
|
|
|
// int dim = 1;
|
|
// 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 test1by1Chunk100Step(){
|
|
|
|
// int dim = 1;
|
|
// 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 test1by1Chunk500Step(){
|
|
|
|
// int dim = 1;
|
|
// 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");
|
|
|
|
// }
|
|
|
|
}
|