~moody/ninep

ref: d394458419b1bc3ea43eb8426ccecfc427352ab9 ninep/message_test.go -rw-r--r-- 518 bytes
d3944584 — Jacob Moody Rework api 2 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
package ninep

import (
	"bytes"
	"testing"
)

func TestVersion(t *testing.T) {
	v := &_Tversion{rf: nil, tg: 0, Msize: 8192, Version: Ninep2000}
	b := make([]byte, v.size())
	v.encode(b)

	samVers1 := []byte{0x00, 0x20, 0x00, 0x00, 0x06, 0x00, 0x39, 0x50, 0x32, 0x30, 0x30, 0x30}
	if bytes.Compare(samVers1, b) != 0 {
		t.Log(samVers1)
		t.Log(b)
		t.Fatal("mismatch from plan9 generated")
	}

	v2 := &_Rversion{}
	v2.decode(b)

	if v.Version != v2.Version {
		t.Log(v)
		t.Log(v2)
		t.Fatal("Version mismatch")
	}
}