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

Function TestNewMatrix

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

Source from the content-addressed store, hash-verified

8)
9
10func TestNewMatrix(t *testing.T) {
11
12 nullMatrix := matrix.New(0, 0, 0)
13 if nullMatrix.Rows() != 0 || nullMatrix.Columns() != 0 {
14 t.Errorf("matrix.New( 0, 0, 0) returned nil, expected a matrix")
15 }
16 // Test creating a matrix of integers
17 intMatrix := matrix.New(3, 4, 0)
18 if intMatrix.Rows() != 3 || intMatrix.Columns() != 4 {
19 t.Errorf("matrix.New( 3, 4, 0) returned nil, expected a matrix")
20 }
21
22}
23
24func TestNewFromElements(t *testing.T) {
25 // Test case 1: Valid matrix

Callers

nothing calls this directly

Calls 3

NewFunction · 0.92
RowsMethod · 0.80
ColumnsMethod · 0.80

Tested by

no test coverage detected