token test

This commit is contained in:
z7zmey 2018-02-18 12:55:32 +02:00
parent ca6ee77850
commit e6e40484d1

32
token/token_test.go Normal file
View File

@ -0,0 +1,32 @@
package token_test
import (
"reflect"
"testing"
"github.com/z7zmey/php-parser/comment"
"github.com/z7zmey/php-parser/token"
)
func TestToken(t *testing.T) {
tkn := token.NewToken([]byte(`foo`), 1, 1, 0, 3)
c := []comment.Comment{
comment.NewPlainComment("test comment"),
}
tkn.SetComments(c)
if reflect.DeepEqual(tkn.Comments(), c) {
t.Errorf("comments are not equal\n")
}
if tkn.String() != `foo` {
t.Errorf("token value is not equal\n")
}
if tkn.StartLine != 1 || tkn.EndLine != 1 || tkn.StartPos != 0 || tkn.EndPos != 3 {
t.Errorf("token position is not equal\n")
}
}