1 // Copyright 2020 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.
9 func TestListenParsing(t *testing.T) {
11 input, wantNetwork, wantAddr string
13 {"127.0.0.1:0", "tcp", "127.0.0.1:0"},
14 {"unix;/tmp/sock", "unix", "/tmp/sock"},
16 {"auto;foo", "auto", "foo"},
19 for _, test := range tests {
20 gotNetwork, gotAddr := parseAddr(test.input)
21 if gotNetwork != test.wantNetwork {
22 t.Errorf("network = %q, want %q", gotNetwork, test.wantNetwork)
24 if gotAddr != test.wantAddr {
25 t.Errorf("addr = %q, want %q", gotAddr, test.wantAddr)