Skip to content

Commit

Permalink
Test runner tweak, for coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
Catenocrypt committed Oct 27, 2020
1 parent ca5808e commit dd24152
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions test_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,19 @@ func RunTestsEncode(t *testing.T, coinType uint32, tests []TestcaseEncode) {
}
}

func errorString(err error) string {
if err != nil {
return err.Error()
}
return "(no error)"
}

func RunTestEncode(coinType uint32, tt TestcaseEncode) error {
testfun, _ := toBytesMap[coinType]

got, err := testfun(tt.input)

var goterror string = "(no error)"
if err != nil {
goterror = err.Error()
}
goterror := errorString(err)
if tt.err != nil {
if !strings.HasPrefix(goterror, tt.err.Error()) {
return fmt.Errorf("%v %v: ToBytes() error = %v, wantErr %v", coinType, tt.name, goterror, tt.err)
Expand Down Expand Up @@ -75,10 +79,7 @@ func RunTestDecode(coinType uint32, tt TestcaseDecode) error {

got, err := testfun(decoded)

var goterror string = "(no error)"
if err != nil {
goterror = err.Error()
}
goterror := errorString(err)
if tt.err != nil {
if goterror != tt.err.Error() {
return fmt.Errorf("%v %v: ToString() error = %v, wantErr %v", coinType, tt.name, goterror, tt.err)
Expand Down

0 comments on commit dd24152

Please sign in to comment.