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

Function TestEmptyMatrix

math/matrix/determinant_test.go:48–68  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

46}
47
48func TestEmptyMatrix(t *testing.T) {
49 emptyElements := [][]int{}
50 matrix, err := matrix.NewFromElements(emptyElements)
51
52 if err != nil {
53 t.Fatalf("Error creating Matrix with empty elements: %v", err)
54 }
55
56 determinant, err := matrix.Determinant()
57
58 if err != nil {
59 t.Fatalf("Determinant returned an error for empty matrix: %v", err)
60 }
61
62 // Check that 0 is returned from an empty matrix.
63 expectedValue := 0
64 if determinant != expectedValue {
65 t.Errorf("Determinant returned from empty matrix was %d; wanted %d", determinant, expectedValue)
66 }
67
68}
69
70func TestNonSquareMatrix(t *testing.T) {
71 // Creating non-square matrix for testing.

Callers

nothing calls this directly

Calls 1

DeterminantMethod · 0.80

Tested by

no test coverage detected