/**
 * 2402Assignment1.java
 *
 * Caitlin Ross
 * 100735219
 */
 
class SparseMatrixTest {
	
	public static void test(){
		//Testing first constructor
		System.out.println("First matrix");
		System.out.println("==============\n");
		
		int[][] arr = new int[2][4];
		arr[0][2] = 3;
		arr[0][0] = 90;
		HyperlistMatrix matrix1 = new HyperlistMatrix(arr);
		
		//Testing getNumberOfRows and getNumberOfColumns methods
		System.out.println("Number of Rows: " + matrix1.getNumberOfRows());
		System.out.println("Number of Columns: " + matrix1.getNumberOfColumns());
		
		//Testing getEntry method
		System.out.println("Entry [0][0]: " + matrix1.getEntry(1, 1));
		System.out.println("Entry [1][0]: " + matrix1.getEntry(2, 1));
		
		System.out.println();
		matrix1.listView();
		System.out.println("\n" + matrix1);
		
		//Testing setEntry method, as well as removeRow and removeEntry methods
		matrix1.setEntry(1, 1, 0);
		matrix1.setEntry(2, 2, 333);
		matrix1.setEntry(1, 3, 0);
		matrix1.setEntry(1, 2, 4);
		matrix1.setEntry(1, 2, 3);
		
		System.out.println();
		matrix1.listView();
		System.out.println("\n" + matrix1);
		
		//Testing Matrix interface, and second constructor
		System.out.println("Second matrix");
		System.out.println("===============\n");
		
		Matrix matrix2 = new HyperlistMatrix(3,3);
		System.out.println("Number of Rows: " + matrix2.getNumberOfRows());
		System.out.println("Number of Columns: " + matrix2.getNumberOfColumns());
		
		//Test methods in the Matrix interface
		matrix2.setEntry(1, 2, 78);
		matrix2.setEntry(1, 3, 34);
		matrix2.setEntry(2, 3, 19);
		System.out.println("\n" + matrix2);
		
		//Testing third constructor
		System.out.println("Third matrix");
		System.out.println("==============\n");
		
		HyperlistMatrix matrix3 = new HyperlistMatrix(matrix1);
		matrix3.listView();
		System.out.println("\n" + matrix3);
		
		//Change elements referred to in first matrix, then set to null
		//If pointers in matrix3 refer to Entries or Rows in matrix1, it will not display properly
		matrix1.setEntry(2, 3, 40);
		matrix1 = null;
		
		matrix3.listView();
		System.out.println("\n" + matrix3);
		
		//Test IndexOutOfBoundsException thrown by getEntry and setEntry methods
		try{
		matrix3.getEntry(4, 5);
		}catch(IndexOutOfBoundsException e){
			System.out.println("getEntry method call failed");
		}
		
		try{
			matrix3.setEntry(4, 5, 2);
		}catch(IndexOutOfBoundsException e){
			System.out.println("setEntry method call failed");
		}
		
		matrix3.listView();
	}
	
}
