func TestParser_ParseStatement(t *testing.T) {
	var tests = []struct {
		s    string
		stmt *sql.SelectStatement
		err  string
	}{
		{
			s: `SELECT name FROM tbl`,
			stmt: &sql.SelectStatement{
				Fields:    []string{"name"},
				TableName: "tbl",
			},
		},
		{
			s: `SELECT first_name, last_name, age FROM my_table`,
			stmt: &sql.SelectStatement{
				Fields:    []string{"first_name", "last_name", "age"},
				TableName: "my_table",
			},
		},
		{
			s: `SELECT * FROM my_table`,
			stmt: &sql.SelectStatement{
				Fields:    []string{"*"},
				TableName: "my_table",
			},
		},
		{s: `foo`, err: `found "foo", expected SELECT`},
		{s: `SELECT !`, err: `found "!", expected field`},
		{s: `SELECT field xxx`, err: `found "xxx", expected FROM`},
		{s: `SELECT field FROM *`, err: `found "*", expected table name`},
	}
	for i, tt := range tests {
		stmt, err := sql.NewParser(strings.NewReader(tt.s)).Parse()
		if !reflect.DeepEqual(tt.err, errstring(err)) {
			t.Errorf("%d. %q: error mismatch:\n  exp=%s\n  got=%s\n\n", i, tt.s, tt.err, err)
		} else if tt.err == "" && !reflect.DeepEqual(tt.stmt, stmt) {
			t.Errorf("%d. %q\n\nstmt mismatch:\n\nexp=%#v\n\ngot=%#v\n\n", i, tt.s, tt.stmt, stmt)
		}
	}
}
Ensure the parser can parse strings into Statement ASTs.
package sql_test
import (
	"reflect"
	"strings"
	"testing"
	"github.com/benbjohnson/sql-parser"
)