Debian Codegraph @

vsock_test.go

raw
1 package vsock
2
3 import (
4 "testing"
5 )
6
7 func TestAddr_fileName(t *testing.T) {
8 tests := []struct {
9 cid uint32
10 port uint32
11 s string
12 }{
13 {
14 cid: Hypervisor,
15 port: 10,
16 s: "vsock:hypervisor(0):10",
17 },
18 {
19 cid: Local,
20 port: 20,
21 s: "vsock:local(1):20",
22 },
23 {
24 cid: Host,
25 port: 30,
26 s: "vsock:host(2):30",
27 },
28 {
29 cid: 3,
30 port: 40,
31 s: "vsock:vm(3):40",
32 },
33 }
34
35 for _, tt := range tests {
36 t.Run(tt.s, func(t *testing.T) {
37 addr := &Addr{
38 ContextID: tt.cid,
39 Port: tt.port,
40 }
41
42 if want, got := tt.s, addr.fileName(); want != got {
43 t.Fatalf("unexpected file name:\n- want: %q\n- got: %q",
44 want, got)
45 }
46 })
47 }
48 }