package soql

import (
	"testing"
)

func TestNextToken(t *testing.T) {
	input := `SELECT name, id FROM Account WHERE name = 'Te"st' AND age > 10`

	tests := []struct {
		expectedType    TokenType
		expectedLiteral string
	}{
		{TokenKeyword, "SELECT"},
		{TokenIdentifier, "name"},
		{TokenPunctuation, ","},
		{TokenIdentifier, "id"},
		{TokenKeyword, "FROM"},
		{TokenIdentifier, "Account"},
		{TokenKeyword, "WHERE"},
		{TokenIdentifier, "name"},
		{TokenOperator, "="},
		{TokenString, "Te\"st"},
		{TokenOperator, "AND"},
		{TokenIdentifier, "age"},
		{TokenOperator, ">"},
		{TokenNumber, "10"},
		{TokenEOF, ""},
	}

	l := NewLexer(input)

	for i, tt := range tests {
		tok := l.NextToken()

		if tok.Type != tt.expectedType {
			t.Errorf("tests[%d] - token type wrong. expected=%q, got=%q",
				i, tt.expectedType, tok.Type)
		}

		if tok.Literal != tt.expectedLiteral {
			t.Errorf("tests[%d] - literal wrong. expected=%q, got=%q",
				i, tt.expectedLiteral, tok.Literal)
		}
	}
}
