1 // Copyright 2019 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
12 func TestParseErrorMessage(t *testing.T) {
16 expectedFileName string
21 name: "from go list output",
22 in: "\nattributes.go:13:1: expected 'package', found 'type'",
23 expectedFileName: "attributes.go",
29 for _, tt := range tests {
30 t.Run(tt.name, func(t *testing.T) {
31 spn := parseGoListError(tt.in)
32 fn := spn.URI().Filename()
34 if !strings.HasSuffix(fn, tt.expectedFileName) {
35 t.Errorf("expected filename with suffix %v but got %v", tt.expectedFileName, fn)
38 if !spn.HasPosition() {
39 t.Fatalf("expected span to have position")
43 if pos.Line() != tt.expectedLine {
44 t.Errorf("expected line %v but got %v", tt.expectedLine, pos.Line())
47 if pos.Column() != tt.expectedColumn {
48 t.Errorf("expected line %v but got %v", tt.expectedLine, pos.Line())