1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
package token
import (
"bytes"
"reflect"
"testing"
)
func TestTokenValue(t *testing.T) {
token := New(ALPHA_NUMERIC, []byte("abc"), 0)
if !bytes.Equal(token.Value(), []byte("abc")) {
t.Logf("Expected Value to return %q, got %q\n", "abc", token.Value())
t.Fail()
}
}
func TestTokenType(t *testing.T) {
token := New(ALPHA_NUMERIC, []byte("abc"), 0)
if !reflect.DeepEqual(token.Type(), ALPHA_NUMERIC) {
t.Logf("Expected Type to return %q, got %q\n", ALPHA_NUMERIC, token.Type())
t.Fail()
}
}
func TestTokenPos(t *testing.T) {
token := New(ALPHA_NUMERIC, []byte("abc"), 0)
if !reflect.DeepEqual(token.Pos(), 0) {
t.Logf("Expected Type to return %d, got %d\n", 0, token.Pos())
t.Fail()
}
}
|