| 43 | } |
| 44 | |
| 45 | func TestMatrixCopyEmpty(t *testing.T) { |
| 46 | // Create an empty matrix |
| 47 | emptyMatrix := matrix.New(0, 0, 0) |
| 48 | |
| 49 | // Make a copy of the empty matrix |
| 50 | copyMatrix, err := emptyMatrix.Copy() |
| 51 | if err != nil { // as empty matrix |
| 52 | t.Fatalf("Failed to copy matrix: %v", err) |
| 53 | } |
| 54 | |
| 55 | // Ensure that the copy is not the same as the original by comparing their addresses |
| 56 | if &emptyMatrix == ©Matrix { |
| 57 | t.Errorf("Copy did not create a new matrix for an empty matrix.") |
| 58 | } |
| 59 | |
| 60 | // Check if the copy is also empty |
| 61 | if copyMatrix.Rows() != 0 || copyMatrix.Columns() != 0 { |
| 62 | t.Errorf("Copy of an empty matrix should also be empty.") |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | func TestMatrixCopyWithDefaultValues(t *testing.T) { |
| 67 | // Create a matrix with default values (zeroes) |