package oneLiners;

import binaryMatrixFile.BinaryMatrixFile;
import junit.framework.TestCase;


public class BMFTests extends TestCase {

	public void testBMF() {
		String path = System.getProperty("java.io.tmpdir");

		double x[] = new double[]{ 1, 2, 3, 4 };
		double y[] = new double[]{ 10, 20, 30 };
		double data[][] = new double[][]{ 
				{ 0.1, 0.2, 0.3, 0.4 }, 
				{ 1.1, 1.2, 1.3, 1.4 }, 
				{ 2.1, 2.2, 2.3, 2.4 }, 
			};

		BinaryMatrixFile.mustWrite(path + "/d.bin", x, y, data, false);
		BinaryMatrixFile.mustWrite(path + "/dt.bin", x, y, data, true);
		
		double d[][] = BinaryMatrixFile.mustLoad(path + "/d.bin", false);
		OneLiners.dumpArray(d);
		
		for(int j=0; j < x.length; j++){
			assertEquals(d[0][j+1], x[j]);
		}
			
		for(int i=0; i < y.length; i++){
			assertEquals(d[i+1][0], y[i]);
			for(int j=0; j < x.length; j++){
				assertEquals(d[i+1][j+1], data[i][j]);
			}
		}
		
	}
}
