Skip to content

Commit

Permalink
added some more test coverage to fold subpackage. (#436)
Browse files Browse the repository at this point in the history
  • Loading branch information
TimothyStiles authored Jan 5, 2024
1 parent 43c015b commit 27c7d28
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
11 changes: 11 additions & 0 deletions fold/fold_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package fold

import (
"fmt"
"math"
"strings"
"testing"
Expand Down Expand Up @@ -201,3 +202,13 @@ func TestFold(t *testing.T) {
assert.InDelta(t, struc.energy, -4.2, 0.2)
})
}
func TestZuker_ErrorCreatingFoldingContext(t *testing.T) {
seq := "ATGGATTTAGATAGATADFQ#(RSDOFIA)"
temp := 4000.0

expectedErr := fmt.Errorf("error creating folding context: the sequence ATGGATTTAGATAGATADFQ#(RSDOFIA) is not RNA or DNA")

_, err := Zuker(seq, temp)
require.Error(t, err)
assert.Equal(t, expectedErr.Error(), err.Error())
}
43 changes: 43 additions & 0 deletions fold/seqfold_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package fold

import (
"fmt"
"math"
"testing"
)

func TestResult_MinimumFreeEnergy_LengthZero(t *testing.T) {
result := Result{} // Create a Result instance with empty structs

expectedEnergy := math.Inf(1)
actualEnergy := result.MinimumFreeEnergy()

if actualEnergy != expectedEnergy {
t.Errorf("expected energy to be %f, but got %f", expectedEnergy, actualEnergy)
}
}

func TestResult_DotBracket_LengthZero(t *testing.T) {
result := Result{} // Create a Result instance with empty structs

expectedDotBracket := ""
actualDotBracket := result.DotBracket()

if actualDotBracket != expectedDotBracket {
t.Errorf("expected dot bracket to be %s, but got %s", expectedDotBracket, actualDotBracket)
}
}

func TestNewFoldingContext_InvalidSequence(t *testing.T) {
seq := "XYZ"
temp := 37.0

_, err := newFoldingContext(seq, temp)
if err == nil {
t.Errorf("expected error, but got nil")
}
expectedError := fmt.Errorf("the sequence %s is not RNA or DNA", seq)
if err.Error() != expectedError.Error() {
t.Errorf("expected error message to be %q, but got %q", expectedError.Error(), err.Error())
}
}

0 comments on commit 27c7d28

Please sign in to comment.