MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / TestMatrixCopyEmpty

Function TestMatrixCopyEmpty

math/matrix/copy_test.go:45–64  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

43}
44
45func 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 == &copyMatrix {
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
66func TestMatrixCopyWithDefaultValues(t *testing.T) {
67 // Create a matrix with default values (zeroes)

Callers

nothing calls this directly

Calls 4

NewFunction · 0.92
CopyMethod · 0.80
RowsMethod · 0.80
ColumnsMethod · 0.80

Tested by

no test coverage detected