func TestParseNextErrors(t *testing.T) {
	var testDialect dialect.Dialect
	for _, tcase := range invalidSQL {
		if tcase.excludeMulti {
			continue
		}
		testDialect = tcase.dialect
		if testDialect == nil {
			testDialect = mysql.NewMySQLDialect()
		}
		sql := tcase.input + "; select 1 from t"
		tokens := NewStringTokenizerWithDialect(testDialect, sql)
		_, err := ParseNext(tokens)
		if err == nil || err.Error() != tcase.output {
			t.Fatalf("[0] ParseNext(%q) err: %q, want %q", sql, err, tcase.output)
			continue
		}
		tree, err := ParseNext(tokens)
		if err != nil {
			t.Fatalf("[1] ParseNext(%q) err: %q, want nil", sql, err)
			continue
		}
		want := "select 1 from t"
		if got := String(tree); got != want {
			t.Fatalf("[1] ParseNext(%q) = %q, want %q", sql, got, want)
		}
		if tree, err := ParseNext(tokens); err != io.EOF {
			t.Errorf("ParseNext(tokens) = (%q, %v) want io.EOF", String(tree), err)
		}
	}
}
TestParseNextErrors tests all the error cases, and ensures a valid
SQL statement can be passed afterwards.
package sqlparser
import (
	"bytes"
	"github.com/cossacklabs/acra/sqlparser/dialect"
	"github.com/cossacklabs/acra/sqlparser/dialect/mysql"
	"io"
	"strings"
	"testing"
)
func TestParseNextValid(t *testing.T) {
	var sql bytes.Buffer
	for _, tcase := range validSQL {
		sql.WriteString(strings.TrimSuffix(tcase.input, ";"))
		sql.WriteRune(';')
	}
	var dialect dialect.Dialect
	tokenizer := NewTokenizer(&sql)
	for i, tcase := range validSQL {
		dialect = tcase.dialect
		if dialect == nil {
			dialect = mysql.NewMySQLDialect()
		}
		tokenizer.dialect = dialect
		input := tcase.input + ";"
		want := tcase.output
		if want == "" {
			want = tcase.input
		}
		tree, err := ParseNext(tokenizer)
		if err != nil {
			t.Fatalf("[%d] ParseNext(%q) err: %q, want nil", i, input, err)
			continue
		}
		if got := String(tree); got != want {
			t.Fatalf("[%d] ParseNext(%q) = %q, want %q", i, input, got, want)
		}
	}
	if tree, err := ParseNext(tokenizer); err != io.EOF {
		t.Errorf("ParseNext(tokenizer) = (%q, %v) want io.EOF", String(tree), err)
	}
}