Skip to content

Commit

Permalink
add tests for MustParseBytes func
Browse files Browse the repository at this point in the history
  • Loading branch information
nleof committed Jul 25, 2016
1 parent 51cd20d commit 11d8984
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions goyesql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@ func TestMustParseFileNoPanic(t *testing.T) {
MustParseFile("tests/samples/valid.sql")
}

func TestMustParseBytesPanic(t *testing.T) {
defer func() {
if r := recover(); r == nil {
t.Errorf("MustParseBytes should panic if an error occurs, got '%s'", r)
}
}()
MustParseBytes([]byte("I won't work"))
}

func TestMustParseBytesNoPanic(t *testing.T) {
defer func() {
if r := recover(); r != nil {
t.Errorf("MustParseBytes should not panic if an error occurs, got '%s'", r)
}
}()
MustParseBytes([]byte("-- name: byte-me\nSELECT * FROM bytes;"))
}

func BenchmarkMustParseFile(b *testing.B) {
for i := 0; i < b.N; i++ {
MustParseFile("tests/samples/valid.sql")
Expand Down

0 comments on commit 11d8984

Please sign in to comment.