php-parser/pkg/errors/error_test.go
2023-12-10 00:36:22 +01:00

46 lines
796 B
Go

package errors_test
import (
"testing"
"gotest.tools/assert"
"git.maride.cc/maride/php-parser/pkg/errors"
"git.maride.cc/maride/php-parser/pkg/position"
)
func TestConstructor(t *testing.T) {
pos := position.NewPosition(1, 2, 3, 4, 1, 2)
actual := errors.NewError("message", pos)
expected := &errors.Error{
Msg: "message",
Pos: pos,
}
assert.DeepEqual(t, expected, actual)
}
func TestPrint(t *testing.T) {
pos := position.NewPosition(1, 2, 3, 4, 1, 2)
Error := errors.NewError("message", pos)
actual := Error.String()
expected := "message at line 1"
assert.DeepEqual(t, expected, actual)
}
func TestPrintWithotPos(t *testing.T) {
Error := errors.NewError("message", nil)
actual := Error.String()
expected := "message"
assert.DeepEqual(t, expected, actual)
}