(t *testing.T)
| 68 | } |
| 69 | |
| 70 | func TestNonSquareMatrix(t *testing.T) { |
| 71 | // Creating non-square matrix for testing. |
| 72 | initialValue := 0 |
| 73 | initialRows := 4 |
| 74 | initialCols := 2 |
| 75 | |
| 76 | nonSquareMatrix := matrix.New(initialRows, initialCols, initialValue) |
| 77 | |
| 78 | determinant, err := nonSquareMatrix.Determinant() |
| 79 | // Check if non square matrix returns an error. |
| 80 | if err == nil { |
| 81 | t.Fatalf("No error was returned for a non-square matrix") |
| 82 | } |
| 83 | |
| 84 | // Check if the correct error was returned. |
| 85 | expectedError := errors.New("Matrix rows and columns must equal in order to find the determinant.") |
| 86 | |
| 87 | if err.Error() != expectedError.Error() { |
| 88 | t.Errorf("Error returned from non-square matrix was \n\"%v\"; \nwanted \n\"%v\"", err, expectedError) |
| 89 | } |
| 90 | |
| 91 | // Check if the determinant of the non-square matrix is 0. |
| 92 | if determinant != 0 { |
| 93 | t.Errorf("Determinant of non-square matrix was not 0 but was %d", determinant) |
| 94 | } |
| 95 | |
| 96 | } |
| 97 | |
| 98 | // Test matrix returned from matrix.New |
| 99 | func TestDefaultMatrix(t *testing.T) { |
nothing calls this directly
no test coverage detected