php-parser/internal/scanner/token_pool_test.go

35 lines
609 B
Go
Raw Normal View History

2018-07-12 07:53:36 +00:00
package scanner_test
import (
"reflect"
"testing"
2020-05-12 21:16:36 +00:00
"github.com/z7zmey/php-parser/internal/scanner"
2018-07-12 07:53:36 +00:00
)
func TestTokenPoolGetNew(t *testing.T) {
tp := new(scanner.TokenPool)
newToken := tp.Get()
if newToken == nil {
t.Errorf("*TokenPool.Get() must return new *Token object\n")
}
}
func TestTokenPoolGetFromPool(t *testing.T) {
tp := new(scanner.TokenPool)
expectedToken := &scanner.Token{
2020-05-12 21:16:36 +00:00
Value: []byte("test"),
2018-07-12 07:53:36 +00:00
}
tp.Put(expectedToken)
actualToken := tp.Get()
if !reflect.DeepEqual(expectedToken, actualToken) {
t.Errorf("*TokenPool.Put() must return *Token object from pool\n")
}
}