~rbn/neinp

ref: b441da6dea2e963387a86b9d1d57802b77f21b83 neinp/message/wstat_test.go -rw-r--r-- 846 bytes
b441da6dRuben Schuller initial commit 2 years ago
                                                                                
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
48
49
package message

import (
	"github.com/rbns/neinp/qid"
	"github.com/rbns/neinp/stat"
	"bytes"
	"testing"
	"time"
)

func TestTWstatEncodeDecode(t *testing.T) {
	var buf bytes.Buffer
	a := &TWstat{Fid: 1, Stat: stat.Stat{Typ: 1, Dev: 2, Qid: qid.Qid{3, 4, 5}, Mode: 6, Atime: time.Unix(1234567, 0), Mtime: time.Unix(1234567, 0), Length: 6, Name: "deadbeef", Uid: "foo", Gid: "bar", Muid: "baz"}}
	_, err := a.encode(&buf)
	if err != nil {
		t.Error(err)
	}

	b := &TWstat{}
	_, err = b.decode(&buf)
	if err != nil {
		t.Error(err)
	}

	if *a != *b {
		t.Log(a, b)
		t.Fail()
	}
}

func TestRWstatEncodeDecode(t *testing.T) {
	var buf bytes.Buffer
	a := &RWstat{}
	_, err := a.encode(&buf)
	if err != nil {
		t.Error(err)
	}

	b := &RWstat{}
	_, err = b.decode(&buf)
	if err != nil {
		t.Error(err)
	}

	if *a != *b {
		t.Log(a, b)
		t.Fail()
	}
}