~rbn/neinp

ref: 55b6eee1e78f053b260d845551ee71f4777448c6 neinp/message/create_test.go -rw-r--r-- 672 bytes
55b6eee1Ruben Schuller move to sr.ht and go modulize 1 year, 10 months 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
package message

import (
	"git.sr.ht/~rbn/neinp/qid"
	"bytes"
	"testing"
)

func TestTCreateEncodeDecode(t *testing.T) {
	var buf bytes.Buffer
	a := &TCreate{Fid: 1, Name: "a", Perm: 2, Mode: 3}
	_, err := a.encode(&buf)
	if err != nil {
		t.Error(err)
	}

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

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

func TestRCreateEncodeDecode(t *testing.T) {
	var buf bytes.Buffer
	a := &RCreate{Qid: qid.Qid{1, 2, 3}}
	_, err := a.encode(&buf)
	if err != nil {
		t.Error(err)
	}

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

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