From e6e40484d13e8324f3cf44b71320e8dc9dc50983 Mon Sep 17 00:00:00 2001 From: z7zmey Date: Sun, 18 Feb 2018 12:55:32 +0200 Subject: [PATCH] token test --- token/token_test.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 token/token_test.go diff --git a/token/token_test.go b/token/token_test.go new file mode 100644 index 0000000..5f61365 --- /dev/null +++ b/token/token_test.go @@ -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") + } +}