File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ package matrix_test
2
2
3
3
import (
4
4
"errors"
5
+ "math"
6
+ "math/rand"
5
7
"testing"
6
8
7
9
"github.com/TheAlgorithms/Go/math/matrix"
@@ -24,6 +26,23 @@ func TestMatrixDeterminant(t *testing.T) {
24
26
if determinant != - 14 {
25
27
t .Fatalf ("Determinant returned for a 3 by 3 matrix was %d; wanted -14" , determinant )
26
28
}
29
+
30
+ // Find Dertminant of a 1 by 1 matrix
31
+ expectedValue := rand .Intn (math .MaxInt )
32
+ matrix2 , err := matrix .NewFromElements ([][]int {
33
+ {expectedValue },
34
+ })
35
+ if err != nil {
36
+ t .Fatalf ("Error creating 1 by 1 matrix: %v" , err )
37
+ }
38
+ determinant , err = matrix2 .Determinant ()
39
+ if err != nil {
40
+ t .Fatalf ("Error returned from 1 by 1 matrix: %v" , err )
41
+ }
42
+ if determinant != expectedValue {
43
+ t .Fatalf ("Determinant returned for a 1 by 1 matrix was %d; wanted %d" , determinant , expectedValue )
44
+ }
45
+
27
46
}
28
47
29
48
func TestEmptyMatrix (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments