~moody/ninep

ref: 7b4c0484154111591a670ce6807bfbda3e864f36 ninep/message_test.go -rw-r--r-- 516 bytes
7b4c0484 — Jacob Moody More docs touchup 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")
	}
}