spongy

A Unixy IRC client
git clone https://git.woozle.org/neale/spongy.git

spongy / spongyd
Neale Pickett  ·  2016-01-18

readwritecloserwrapper_test.go

 1package main
 2
 3import (
 4	"bytes"
 5	"testing"
 6)
 7
 8func TestRWCWCat(t *testing.T) {
 9	proc, err := StartStdioProcess("cat", []string{})
10	if err != nil {
11		t.Error(err)
12	}
13	
14	out := []byte("Hello, World\n")
15	p := make([]byte, 50)
16	
17	n, err := proc.Write(out)
18	if err != nil {
19		t.Error(err)
20	}
21	if n != len(out) {
22		t.Errorf("Wrong number of bytes in Write: wanted %d, got %d", len(out), n)
23	}
24	
25	n, err = proc.Read(p)
26	if err != nil {
27		t.Error(err)
28	}
29	if n != len(out) {
30		t.Errorf("Wrong number of bytes in Read: wanted %d, got %d", len(out), n)
31	}
32	if 0 != bytes.Compare(p[:n], out) {
33		t.Errorf("Mangled read")
34	}
35	
36	proc.Close()
37}