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

Function TestMatrixColumns

math/matrix/matrix_test.go:147–160  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

145}
146
147func TestMatrixColumns(t *testing.T) {
148 // Create a sample matrix
149 data := [][]int{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}
150 matrix, err := matrix.NewFromElements(data)
151 if err != nil {
152 t.Fatalf("Failed to copy matrix: %v", err)
153 }
154 // Check the number of columns
155 expectedColumns := len(data[0])
156 columns := matrix.Columns()
157 if columns != expectedColumns {
158 t.Errorf("Expected %d columns, but got %d", expectedColumns, columns)
159 }
160}
161
162func TestMatrixEmptyRowsAndColumns(t *testing.T) {
163 // Create an empty matrix

Callers

nothing calls this directly

Calls 1

ColumnsMethod · 0.80

Tested by

no test coverage detected