Update test coverage

This commit is contained in:
2023-06-30 21:41:03 -04:00
parent 96fec9d7c2
commit 7efca4a154
9 changed files with 88 additions and 56 deletions

View File

@@ -1,7 +1,7 @@
//Matrix/src/main/java/com/mattrixwv/BigIntegerMatrix.java //Matrix/src/main/java/com/mattrixwv/BigIntegerMatrix.java
//Mattrixwv //Mattrixwv
// Created: 02-10-22 // Created: 02-10-22
//Modified: 06-30-22 //Modified: 06-30-23
package com.mattrixwv.matrix; package com.mattrixwv.matrix;
@@ -68,14 +68,14 @@ public class BigIntegerMatrix{
} }
//Returns a matrix with the supplied row and column removed //Returns a matrix with the supplied row and column removed
protected BigIntegerMatrix laplaceExpansionHelper(int row, int col){ protected BigIntegerMatrix laplaceExpansionHelper(int row, int col){
//Make sure the matrix is square
if(!isSquare()){
throw new InvalidGeometryException("A matrix must be square for you to perform Laplace Expansion");
}
//Make sure the matrix is large enough to have this operation performed //Make sure the matrix is large enough to have this operation performed
if((getNumRows() <= 1) || (getNumCols() <= 1)){ if((getNumRows() <= 1) || (getNumCols() <= 1)){
throw new InvalidGeometryException("A matrix must be at least 2x2 for you to perform Laplace Expansion: " + getNumRows() + "x" + getNumCols()); throw new InvalidGeometryException("A matrix must be at least 2x2 for you to perform Laplace Expansion: " + getNumRows() + "x" + getNumCols());
} }
//Make sure the matrix is square
if(!isSquare()){
throw new InvalidGeometryException("A matrix must be square for you to perform Laplace Expansion");
}
//Make sure the row is valid //Make sure the row is valid
if((row < 0) || (row >= getNumRows())){ if((row < 0) || (row >= getNumRows())){
throw new InvalidCoordinatesException("An invalid row number was supplied: " + row + ". The matrix contains " + getNumRows() + " rows"); throw new InvalidCoordinatesException("An invalid row number was supplied: " + row + ". The matrix contains " + getNumRows() + " rows");

View File

@@ -1,7 +1,7 @@
//Matrix/src/main/java/com/mattrixwv/matrix/DoubleMatrix.java //Matrix/src/main/java/com/mattrixwv/matrix/DoubleMatrix.java
//Mattrixwv //Mattrixwv
// Created: 02-07-22 // Created: 02-07-22
//Modified: 06-30-22 //Modified: 06-30-23
package com.mattrixwv.matrix; package com.mattrixwv.matrix;
@@ -68,14 +68,14 @@ public class DoubleMatrix{
} }
//Returns a matrix with the supplied row and column removed //Returns a matrix with the supplied row and column removed
protected DoubleMatrix laplaceExpansionHelper(int row, int col){ protected DoubleMatrix laplaceExpansionHelper(int row, int col){
//Make sure the matrix is square
if(!isSquare()){
throw new InvalidGeometryException("A matrix must be square for you to perform Laplace Expansion");
}
//Make sure the matrix is large enough to have this operation performed //Make sure the matrix is large enough to have this operation performed
if((getNumRows() <= 1) || (getNumCols() <= 1)){ if((getNumRows() <= 1) || (getNumCols() <= 1)){
throw new InvalidGeometryException("A matrix must be at least 2x2 for you to perform Laplace Expansion: " + getNumRows() + "x" + getNumCols()); throw new InvalidGeometryException("A matrix must be at least 2x2 for you to perform Laplace Expansion: " + getNumRows() + "x" + getNumCols());
} }
//Make sure the matrix is square
if(!isSquare()){
throw new InvalidGeometryException("A matrix must be square for you to perform Laplace Expansion");
}
//Make sure the row is valid //Make sure the row is valid
if((row < 0) || (row >= getNumRows())){ if((row < 0) || (row >= getNumRows())){
throw new InvalidCoordinatesException("An invalid row number was supplied: " + row + ". The matrix contains " + getNumRows() + " rows"); throw new InvalidCoordinatesException("An invalid row number was supplied: " + row + ". The matrix contains " + getNumRows() + " rows");

View File

@@ -1,7 +1,7 @@
//Matrix/src/main/java/com/mattrixwv/IntegerMatrix.java //Matrix/src/main/java/com/mattrixwv/IntegerMatrix.java
//Mattrixwv //Mattrixwv
// Created: 02-01-22 // Created: 02-01-22
//Modified: 06-30-22 //Modified: 06-30-23
package com.mattrixwv.matrix; package com.mattrixwv.matrix;
@@ -67,14 +67,14 @@ public class IntegerMatrix{
} }
//Returns a matrix with the supplied row and column removed //Returns a matrix with the supplied row and column removed
protected IntegerMatrix laplaceExpansionHelper(int row, int col){ protected IntegerMatrix laplaceExpansionHelper(int row, int col){
//Make sure the matrix is square
if(!isSquare()){
throw new InvalidGeometryException("A matrix must be square for you to perform Laplace Expansion");
}
//Make sure the matrix is large enough to have this operation performed //Make sure the matrix is large enough to have this operation performed
if((getNumRows() <= 1) || (getNumCols() <= 1)){ if((getNumRows() <= 1) || (getNumCols() <= 1)){
throw new InvalidGeometryException("A matrix must be at least 2x2 for you to perform Laplace Expansion: " + getNumRows() + "x" + getNumCols()); throw new InvalidGeometryException("A matrix must be at least 2x2 for you to perform Laplace Expansion: " + getNumRows() + "x" + getNumCols());
} }
//Make sure the matrix is square
if(!isSquare()){
throw new InvalidGeometryException("A matrix must be square for you to perform Laplace Expansion");
}
//Make sure the row is valid //Make sure the row is valid
if((row < 0) || (row >= getNumRows())){ if((row < 0) || (row >= getNumRows())){
throw new InvalidCoordinatesException("An invalid row number was supplied: " + row + ". The matrix contains " + getNumRows() + " rows"); throw new InvalidCoordinatesException("An invalid row number was supplied: " + row + ". The matrix contains " + getNumRows() + " rows");

View File

@@ -1,7 +1,7 @@
//Matrix/src/main/java/com/mattrixwv/matrix/LongMatrix.java //Matrix/src/main/java/com/mattrixwv/matrix/LongMatrix.java
//Mattrixwv //Mattrixwv
// Created: 02-10-22 // Created: 02-10-22
//Modified: 07-01-22 //Modified: 06-30-23
package com.mattrixwv.matrix; package com.mattrixwv.matrix;
@@ -67,14 +67,14 @@ public class LongMatrix{
} }
//Returns a matrix with the supplied row and column removed //Returns a matrix with the supplied row and column removed
protected LongMatrix laplaceExpansionHelper(int row, int col){ protected LongMatrix laplaceExpansionHelper(int row, int col){
//Make sure the matrix is square
if(!isSquare()){
throw new InvalidGeometryException("A matrix must be square for you to perform Laplace Expansion");
}
//Make sure the matrix is large enough to have this operation performed //Make sure the matrix is large enough to have this operation performed
if((getNumRows() <= 1) || (getNumCols() <= 1)){ if((getNumRows() <= 1) || (getNumCols() <= 1)){
throw new InvalidGeometryException("A matrix must be at least 2x2 for you to perform Laplace Expansion: " + getNumRows() + "x" + getNumCols()); throw new InvalidGeometryException("A matrix must be at least 2x2 for you to perform Laplace Expansion: " + getNumRows() + "x" + getNumCols());
} }
//Make sure the matrix is square
if(!isSquare()){
throw new InvalidGeometryException("A matrix must be square for you to perform Laplace Expansion");
}
//Make sure the row is valid //Make sure the row is valid
if((row < 0) || (row >= getNumRows())){ if((row < 0) || (row >= getNumRows())){
throw new InvalidCoordinatesException("An invalid row number was supplied: " + row + ". The matrix contains " + getNumRows() + " rows"); throw new InvalidCoordinatesException("An invalid row number was supplied: " + row + ". The matrix contains " + getNumRows() + " rows");

View File

@@ -1,7 +1,7 @@
//Matrix/src/test/java/com/mattrixwv/matrix/TestBigBigIntegerMatrix.java //Matrix/src/test/java/com/mattrixwv/matrix/TestBigBigIntegerMatrix.java
//Mattrixwv //Mattrixwv
// Created: 02-10-22 // Created: 02-10-22
//Modified: 04-13-23 //Modified: 06-30-23
package com.mattrixwv.matrix; package com.mattrixwv.matrix;
@@ -1861,19 +1861,19 @@ public class TestBigIntegerMatrix{
@Test @Test
public void testLaplaceExpansionHelper(){ public void testLaplaceExpansionHelper(){
BigIntegerMatrixPublic matrix = new BigIntegerMatrixPublic(); BigIntegerMatrix matrix = new BigIntegerMatrix();
matrix.addRow(grid2[0]); matrix.addRow(grid2[0]);
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, () -> {
matrix.laplaceExpansionHelper(0, 0); matrix.laplaceExpansionHelper(0, 0);
}); });
BigIntegerMatrixPublic matrix2 = new BigIntegerMatrixPublic(); BigIntegerMatrix matrix2 = new BigIntegerMatrix();
matrix2.setGrid(grid1); matrix2.setGrid(grid1);
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, () -> {
matrix2.laplaceExpansionHelper(0, 0); matrix2.laplaceExpansionHelper(0, 0);
}); });
BigIntegerMatrixPublic matrix3 = new BigIntegerMatrixPublic(); BigIntegerMatrix matrix3 = new BigIntegerMatrix();
matrix3.setGrid(grid2); matrix3.setGrid(grid2);
assertThrows(InvalidCoordinatesException.class, () -> { assertThrows(InvalidCoordinatesException.class, () -> {
matrix3.laplaceExpansionHelper(-1, 0); matrix3.laplaceExpansionHelper(-1, 0);
@@ -1887,9 +1887,16 @@ public class TestBigIntegerMatrix{
assertThrows(InvalidCoordinatesException.class, () -> { assertThrows(InvalidCoordinatesException.class, () -> {
matrix3.laplaceExpansionHelper(0, 2); matrix3.laplaceExpansionHelper(0, 2);
}); });
}
BigIntegerMatrix matrix4 = new BigIntegerMatrix();
private class BigIntegerMatrixPublic extends BigIntegerMatrix{ matrix4.addCol(grid2[0]);
assertThrows(InvalidGeometryException.class, () -> {
matrix4.laplaceExpansionHelper(0, 0);
});
matrix4.addCol(grid2[1]);
matrix4.addCol(grid2[0]);
assertThrows(InvalidGeometryException.class, () -> {
matrix4.laplaceExpansionHelper(0, 0);
});
} }
} }

View File

@@ -1,7 +1,7 @@
//Matrix/src/test/java/com/mattrixwv/matrix/TestDoubleMatrix.java //Matrix/src/test/java/com/mattrixwv/matrix/TestDoubleMatrix.java
//Mattrixwv //Mattrixwv
// Created: 02-07-22 // Created: 02-07-22
//Modified: 04-13-23 //Modified: 06-30-23
package com.mattrixwv.matrix; package com.mattrixwv.matrix;
@@ -1853,19 +1853,19 @@ public class TestDoubleMatrix{
@Test @Test
public void testLaplaceExpansionHelper(){ public void testLaplaceExpansionHelper(){
DoubleMatrixPublic matrix = new DoubleMatrixPublic(); DoubleMatrix matrix = new DoubleMatrix();
matrix.addRow(grid2[0]); matrix.addRow(grid2[0]);
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, () -> {
matrix.laplaceExpansionHelper(0, 0); matrix.laplaceExpansionHelper(0, 0);
}); });
DoubleMatrixPublic matrix2 = new DoubleMatrixPublic(); DoubleMatrix matrix2 = new DoubleMatrix();
matrix2.setGrid(grid1); matrix2.setGrid(grid1);
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, () -> {
matrix2.laplaceExpansionHelper(0, 0); matrix2.laplaceExpansionHelper(0, 0);
}); });
DoubleMatrixPublic matrix3 = new DoubleMatrixPublic(); DoubleMatrix matrix3 = new DoubleMatrix();
matrix3.setGrid(grid2); matrix3.setGrid(grid2);
assertThrows(InvalidCoordinatesException.class, () -> { assertThrows(InvalidCoordinatesException.class, () -> {
matrix3.laplaceExpansionHelper(-1, 0); matrix3.laplaceExpansionHelper(-1, 0);
@@ -1879,9 +1879,16 @@ public class TestDoubleMatrix{
assertThrows(InvalidCoordinatesException.class, () -> { assertThrows(InvalidCoordinatesException.class, () -> {
matrix3.laplaceExpansionHelper(0, 2); matrix3.laplaceExpansionHelper(0, 2);
}); });
}
DoubleMatrix matrix4 = new DoubleMatrix();
private class DoubleMatrixPublic extends DoubleMatrix{ matrix4.addCol(grid2[0]);
assertThrows(InvalidGeometryException.class, () -> {
matrix4.laplaceExpansionHelper(0, 0);
});
matrix4.addCol(grid2[1]);
matrix4.addCol(grid2[0]);
assertThrows(InvalidGeometryException.class, () -> {
matrix4.laplaceExpansionHelper(0, 0);
});
} }
} }

View File

@@ -1,7 +1,7 @@
//Matrix/src/test/java/com/mattrixwv/matrix/TestIntegerMatrix.java //Matrix/src/test/java/com/mattrixwv/matrix/TestIntegerMatrix.java
//Mattrixwv //Mattrixwv
// Created: 02-01-22 // Created: 02-01-22
//Modified: 04-13-23 //Modified: 06-30-23
package com.mattrixwv.matrix; package com.mattrixwv.matrix;
@@ -1852,19 +1852,19 @@ public class TestIntegerMatrix{
@Test @Test
public void testLaplaceExpansionHelper(){ public void testLaplaceExpansionHelper(){
IntegerMatrixPublic matrix = new IntegerMatrixPublic(); IntegerMatrix matrix = new IntegerMatrix();
matrix.addRow(grid2[0]); matrix.addRow(grid2[0]);
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, () -> {
matrix.laplaceExpansionHelper(0, 0); matrix.laplaceExpansionHelper(0, 0);
}); });
IntegerMatrixPublic matrix2 = new IntegerMatrixPublic(); IntegerMatrix matrix2 = new IntegerMatrix();
matrix2.setGrid(grid1); matrix2.setGrid(grid1);
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, () -> {
matrix2.laplaceExpansionHelper(0, 0); matrix2.laplaceExpansionHelper(0, 0);
}); });
IntegerMatrixPublic matrix3 = new IntegerMatrixPublic(); IntegerMatrix matrix3 = new IntegerMatrix();
matrix3.setGrid(grid2); matrix3.setGrid(grid2);
assertThrows(InvalidCoordinatesException.class, () -> { assertThrows(InvalidCoordinatesException.class, () -> {
matrix3.laplaceExpansionHelper(-1, 0); matrix3.laplaceExpansionHelper(-1, 0);
@@ -1878,9 +1878,16 @@ public class TestIntegerMatrix{
assertThrows(InvalidCoordinatesException.class, () -> { assertThrows(InvalidCoordinatesException.class, () -> {
matrix3.laplaceExpansionHelper(0, 2); matrix3.laplaceExpansionHelper(0, 2);
}); });
}
IntegerMatrix matrix4 = new IntegerMatrix();
private class IntegerMatrixPublic extends IntegerMatrix{ matrix4.addCol(grid2[0]);
assertThrows(InvalidGeometryException.class, () -> {
matrix4.laplaceExpansionHelper(0, 0);
});
matrix4.addCol(grid2[1]);
matrix4.addCol(grid2[0]);
assertThrows(InvalidGeometryException.class, () -> {
matrix4.laplaceExpansionHelper(0, 0);
});
} }
} }

View File

@@ -1852,19 +1852,19 @@ public class TestLongMatrix{
@Test @Test
public void testLaplaceExpansionHelper(){ public void testLaplaceExpansionHelper(){
LongMatrixPublic matrix = new LongMatrixPublic(); LongMatrix matrix = new LongMatrix();
matrix.addRow(grid2[0]); matrix.addRow(grid2[0]);
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, () -> {
matrix.laplaceExpansionHelper(0, 0); matrix.laplaceExpansionHelper(0, 0);
}); });
LongMatrixPublic matrix2 = new LongMatrixPublic(); LongMatrix matrix2 = new LongMatrix();
matrix2.setGrid(grid1); matrix2.setGrid(grid1);
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, () -> {
matrix2.laplaceExpansionHelper(0, 0); matrix2.laplaceExpansionHelper(0, 0);
}); });
LongMatrixPublic matrix3 = new LongMatrixPublic(); LongMatrix matrix3 = new LongMatrix();
matrix3.setGrid(grid2); matrix3.setGrid(grid2);
assertThrows(InvalidCoordinatesException.class, () -> { assertThrows(InvalidCoordinatesException.class, () -> {
matrix3.laplaceExpansionHelper(-1, 0); matrix3.laplaceExpansionHelper(-1, 0);
@@ -1878,9 +1878,16 @@ public class TestLongMatrix{
assertThrows(InvalidCoordinatesException.class, () -> { assertThrows(InvalidCoordinatesException.class, () -> {
matrix3.laplaceExpansionHelper(0, 2); matrix3.laplaceExpansionHelper(0, 2);
}); });
}
LongMatrix matrix4 = new LongMatrix();
private class LongMatrixPublic extends LongMatrix{ matrix4.addCol(grid2[0]);
assertThrows(InvalidGeometryException.class, () -> {
matrix4.laplaceExpansionHelper(0, 0);
});
matrix4.addCol(grid2[1]);
matrix4.addCol(grid2[0]);
assertThrows(InvalidGeometryException.class, () -> {
matrix4.laplaceExpansionHelper(0, 0);
});
} }
} }

View File

@@ -1840,19 +1840,19 @@ public class TestModMatrix{
@Test @Test
public void testLaplaceExpansionHelper(){ public void testLaplaceExpansionHelper(){
ModMatrixPublic matrix = new ModMatrixPublic(); ModMatrix matrix = new ModMatrix(Integer.MAX_VALUE);
matrix.addRow(grid2[0]); matrix.addRow(grid2[0]);
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, () -> {
matrix.laplaceExpansionHelper(0, 0); matrix.laplaceExpansionHelper(0, 0);
}); });
ModMatrixPublic matrix2 = new ModMatrixPublic(); ModMatrix matrix2 = new ModMatrix(Integer.MAX_VALUE);
matrix2.setGrid(grid1); matrix2.setGrid(grid1);
assertThrows(InvalidGeometryException.class, () -> { assertThrows(InvalidGeometryException.class, () -> {
matrix2.laplaceExpansionHelper(0, 0); matrix2.laplaceExpansionHelper(0, 0);
}); });
ModMatrixPublic matrix3 = new ModMatrixPublic(); ModMatrix matrix3 = new ModMatrix(Integer.MAX_VALUE);
matrix3.setGrid(grid2); matrix3.setGrid(grid2);
assertThrows(InvalidCoordinatesException.class, () -> { assertThrows(InvalidCoordinatesException.class, () -> {
matrix3.laplaceExpansionHelper(-1, 0); matrix3.laplaceExpansionHelper(-1, 0);
@@ -1866,12 +1866,16 @@ public class TestModMatrix{
assertThrows(InvalidCoordinatesException.class, () -> { assertThrows(InvalidCoordinatesException.class, () -> {
matrix3.laplaceExpansionHelper(0, 2); matrix3.laplaceExpansionHelper(0, 2);
}); });
}
ModMatrix matrix4 = new ModMatrix(Integer.MAX_VALUE);
private class ModMatrixPublic extends ModMatrix{ matrix4.addCol(grid2[0]);
public ModMatrixPublic(){ assertThrows(InvalidGeometryException.class, () -> {
super(Integer.MAX_VALUE); matrix4.laplaceExpansionHelper(0, 0);
} });
matrix4.addCol(grid2[1]);
matrix4.addCol(grid2[0]);
assertThrows(InvalidGeometryException.class, () -> {
matrix4.laplaceExpansionHelper(0, 0);
});
} }
} }