Skip to content

Commit

Permalink
Add TestParseFailures for more coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
dolmen committed Mar 26, 2024
1 parent 830fd07 commit d355476
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions codegen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"log"
"os"
"testing"

"github.com/dolmen-go/codegen"
)

func TestExample(t *testing.T) {
Expand All @@ -25,3 +27,22 @@ func TestExample(t *testing.T) {

Example()
}

// TestParseFailures to reach full coverage.
func TestParseFailures(t *testing.T) {
_, err := codegen.Parse("{{")
if err == nil {
t.Fatal("Parse should fail.")
}

err = func() (r error) {
defer func() {
r = recover().(error)
}()
codegen.MustParse("{{")
return
}()
if err == nil {
t.Fatal("MustParse should panic.")
}
}

0 comments on commit d355476

Please sign in to comment.