github.com/amarpal/go-tools@v0.0.0-20240422043104-40142f59f616/lintcmd/cmd_test.go (about) 1 package lintcmd 2 3 import ( 4 "go/token" 5 "testing" 6 ) 7 8 func TestParsePos(t *testing.T) { 9 var tests = []struct { 10 in string 11 out token.Position 12 }{ 13 { 14 "/tmp/gopackages280076669/go-build/net/cgo_linux.cgo1.go:1", 15 token.Position{ 16 Filename: "/tmp/gopackages280076669/go-build/net/cgo_linux.cgo1.go", 17 Line: 1, 18 Column: 0, 19 }, 20 }, 21 { 22 "/tmp/gopackages280076669/go-build/net/cgo_linux.cgo1.go:1:", 23 token.Position{ 24 Filename: "/tmp/gopackages280076669/go-build/net/cgo_linux.cgo1.go", 25 Line: 1, 26 Column: 0, 27 }, 28 }, 29 { 30 "/tmp/gopackages280076669/go-build/net/cgo_linux.cgo1.go:23:43", 31 token.Position{ 32 Filename: "/tmp/gopackages280076669/go-build/net/cgo_linux.cgo1.go", 33 Line: 23, 34 Column: 43, 35 }, 36 }, 37 } 38 39 for _, tt := range tests { 40 res, _, _ := parsePos(tt.in) 41 if res != tt.out { 42 t.Errorf("failed to parse %q correctly", tt.in) 43 } 44 } 45 }