Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added some more test coverage to fold subpackage. #436

Merged
merged 1 commit into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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())
}
}
Loading