MCPcopy Index your code
hub / github.com/TheAlgorithms/Go / TestMatrixMatchDimensions

Function TestMatrixMatchDimensions

math/matrix/matchdimensions_test.go:9–27  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestMatrixMatchDimensions(t *testing.T) {
10 // Create two matrices with the same dimensions
11 m1 := matrix.New(2, 3, 0)
12 m2 := matrix.New(2, 3, 0)
13
14 // Test case 1: Same dimensions
15 if !m1.MatchDimensions(m2) {
16 t.Errorf("m1.MatchDimensions(m2) returned %t, expected 1 (same dimensions)", m1.MatchDimensions(m2))
17 }
18
19 // Create two matrices with different dimensions
20 m3 := matrix.New(2, 3, 0)
21 m4 := matrix.New(3, 2, 0)
22
23 // Test case 2: Different dimensions
24 if m3.MatchDimensions(m4) {
25 t.Errorf("m3.MatchDimensions(m4) returned : %v, expected: %v", m3.MatchDimensions(m4), false)
26 }
27}
28
29// BenchmarkMatchDimensions benchmarks the MatchDimensions method.
30func BenchmarkMatchDimensions(b *testing.B) {

Callers

nothing calls this directly

Calls 2

NewFunction · 0.92
MatchDimensionsMethod · 0.80

Tested by

no test coverage detected