-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathutil_test.go
More file actions
47 lines (40 loc) · 832 Bytes
/
Copy pathutil_test.go
File metadata and controls
47 lines (40 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"encoding/gob"
"io"
"testing"
)
func TestMsgWrite(t *testing.T) {
tests := []string{"foo", "bar", "baz"}
pr, pw := io.Pipe()
wc := msgWrite(newMsgEncoder(pw), "test")
go func() {
for _, test := range tests {
if _, err := wc.Write([]byte(test)); err != nil {
pw.CloseWithError(err)
return
}
}
wc.Close()
}()
dec := gob.NewDecoder(pr)
for _, test := range tests {
var m msg
if err := dec.Decode(&m); err != nil {
t.Fatal(err)
}
if m.Name != "test" {
t.Fatalf("want %q but %q", "test", m.Name)
}
if string(m.Data) != test {
t.Fatalf("want %q but %q", test, string(m.Data))
}
}
}
func TestMakeCmdLine(t *testing.T) {
got := makeCmdLine([]string{"foo", "bar baz"})
want := `foo "bar baz"`
if got != want {
t.Fatalf("want %q but %q", want, got)
}
}