Skip to content

Commit

Permalink
Added TEsts for VectorConstantTranspose object
Browse files Browse the repository at this point in the history
  • Loading branch information
kwesiRutledge committed Feb 28, 2024
1 parent 4508c7f commit 01047eb
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions testing/optim/vector_constant_transposed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package optim_test
import (
"fmt"
"github.com/MatProGo-dev/MatProInterface.go/optim"
"github.com/MatProGo-dev/SymbolicMath.go/symbolic"
"gonum.org/v1/gonum/mat"
"strings"
"testing"
Expand All @@ -14,6 +15,23 @@ Description:
Tests the new type KVectorTranspose which represents a constant vector.
*/

/*
TestKVectorTranspose_Check1
Description:
Tests that the Check() method returns nil.
*/
func TestKVectorTranspose_Check1(t *testing.T) {
// Create a KVectorTranspose
desLength := 4
var vec1 = optim.KVectorTranspose(optim.OnesVector(desLength))

// Check
if vec1.Check() != nil {
t.Errorf("The Check() method should return nil; received %v", vec1.Check())
}
}

/*
TestKVectorTranspose_At1
Description:
Expand Down Expand Up @@ -1187,3 +1205,28 @@ func TestKVectorTranspose_Transpose1(t *testing.T) {
)
}
}

/*
TestKVectorTranspose_ToSymbolic1
Description:
Tests that the ToSymbolic function works as expected.
Expects for the error to be nil and for the result to be a symbolic.KMatrix
*/
func TestKVectorTranspose_ToSymbolic1(t *testing.T) {
// Constants
desLength := 10

// Algorithm
vec1 := optim.KVectorTranspose(optim.OnesVector(desLength))
symVec, err := vec1.ToSymbolic()
if err != nil {
t.Errorf("Unexpected error in ToSymbolic: %v", err)
}

// Check type
_, ok := symVec.(symbolic.KMatrix)
if !ok {
t.Errorf("Expected symVec to be of type symbolic.KVector; received %T", symVec)
}
}

0 comments on commit 01047eb

Please sign in to comment.