func TestReencode(t *testing.T) {
	tests := []struct {
		in Codec
	}{
		{
			&Qid{
				Type:    QTDIR,
				Version: 0x12340987,
				Path:    0x10293874FFFFFF,
			},
		}, {
			&Stat{
				Type:   0xDEAD,
				Dev:    0xABCDEF08,
				Qid:    Qid{},
				Mode:   FileMode(OTRUNC),
				Atime:  90870987,
				Mtime:  1234124,
				Length: 0x23ABDDF8,
				Name:   "hello",
				UID:    "someone",
				GID:    "over the",
				MUID:   "rainbow",
			},
		}, {
			&VersionRequest{
				Tag:     45,
				MaxSize: 9384,
				Version: "9P2000",
			},
		}, {
			&VersionResponse{
				Tag:     45,
				MaxSize: 9384,
				Version: "9P2000",
			},
		}, {
			&AuthRequest{
				Tag:      45,
				AuthFid:  Fid(1234),
				Username: "someone",
				Service:  "something",
			},
		}, {
			&AuthResponse{
				Tag:     45,
				AuthQid: Qid{},
			},
		}, {
			&AttachRequest{
				Tag:      45,
				Fid:      35243,
				AuthFid:  90872354,
				Username: "",
				Service:  "weee",
			},
		}, {
			&AttachResponse{
				Tag: 45,
				Qid: Qid{},
			},
		}, {
			&ErrorResponse{
				Tag:   45,
				Error: "something something something",
			},
		}, {
			&FlushRequest{
				Tag:    45,
				OldTag: 23453,
			},
		}, {
			&FlushResponse{
				Tag: 45,
			},
		}, {
			&WalkRequest{
				Tag:    45,
				Fid:    1234,
				NewFid: 3452345,
				Names: []string{
					"ongo",
					"bongo",
					"filliyonko",
					"megatronko",
				},
			},
		}, {
			&WalkResponse{
				Tag: 45,
				Qids: []Qid{
					{},
					{},
					{},
				},
			},
		}, {
			&OpenRequest{
				Tag:  45,
				Fid:  21343,
				Mode: 4,
			},
		}, {
			&OpenResponse{
				Tag:    45,
				Qid:    Qid{},
				IOUnit: 1234123,
			},
		}, {
			&CreateRequest{
				Tag:         45,
				Fid:         12343,
				Name:        "wakakaaka",
				Permissions: DMDIR,
				Mode:        4,
			},
		}, {
			&CreateResponse{
				Tag:    45,
				Qid:    Qid{},
				IOUnit: 433535,
			},
		}, {
			&ReadRequest{
				Tag:    45,
				Fid:    5343,
				Offset: 359842382234,
				Count:  23423,
			},
		}, {
			&ReadResponse{
				Tag:  45,
				Data: []byte("ooooh nooo it's full of data"),
			},
		}, {
			&WriteRequest{
				Tag:    45,
				Fid:    254334,
				Offset: 21304978234,
				Data:   []byte("something to write"),
			},
		}, {
			&WriteResponse{
				Tag:   45,
				Count: 12,
			},
		}, {
			&ClunkRequest{
				Tag: 45,
				Fid: 23123,
			},
		}, {
			&ClunkResponse{
				Tag: 45,
			},
		}, {
			&RemoveRequest{
				Tag: 45,
				Fid: 1234,
			},
		}, {
			&RemoveResponse{
				Tag: 45,
			},
		}, {
			&StatRequest{
				Tag: 45,
				Fid: 12341234,
			},
		}, {
			&StatResponse{
				Tag:  45,
				Stat: Stat{},
			},
		}, {
			&WriteStatRequest{
				Tag:  45,
				Fid:  12342134,
				Stat: Stat{},
			},
		}, {
			&WriteStatResponse{
				Tag: 45,
			},
		},
	}
	for i, tt := range tests {
		reencode(i, tt.in, t)
	}
}
// This test does NOT guarantee proper 9P2000 spec coding, but ensures at least
// that all codecs are compatible with themselves.
This test does NOT guarantee proper 9P2000 spec coding, but ensures at least
that all codecs are compatible with themselves.
// This test does NOT guarantee proper 9P2000 spec coding but ensures at least // that all codecs are compatible with themselves .
func TestReencode(t *testing.T) {
	tests := []struct {
		in Codec
	}{
		{
			&Qid{
				Type:    QTDIR,
				Version: 0x12340987,
				Path:    0x10293874FFFFFF,
			},
		}, {
			&Stat{
				Type:   0xDEAD,
				Dev:    0xABCDEF08,
				Qid:    Qid{},
				Mode:   FileMode(OTRUNC),
				Atime:  90870987,
				Mtime:  1234124,
				Length: 0x23ABDDF8,
				Name:   "hello",
				UID:    "someone",
				GID:    "over the",
				MUID:   "rainbow",
			},
		}, {
			&VersionRequest{
				Tag:     45,
				MaxSize: 9384,
				Version: "9P2000",
			},
		}, {
			&VersionResponse{
				Tag:     45,
				MaxSize: 9384,
				Version: "9P2000",
			},
		}, {
			&AuthRequest{
				Tag:      45,
				AuthFid:  Fid(1234),
				Username: "someone",
				Service:  "something",
			},
		}, {
			&AuthResponse{
				Tag:     45,
				AuthQid: Qid{},
			},
		}, {
			&AttachRequest{
				Tag:      45,
				Fid:      35243,
				AuthFid:  90872354,
				Username: "",
				Service:  "weee",
			},
		}, {
			&AttachResponse{
				Tag: 45,
				Qid: Qid{},
			},
		}, {
			&ErrorResponse{
				Tag:   45,
				Error: "something something something",
			},
		}, {
			&FlushRequest{
				Tag:    45,
				OldTag: 23453,
			},
		}, {
			&FlushResponse{
				Tag: 45,
			},
		}, {
			&WalkRequest{
				Tag:    45,
				Fid:    1234,
				NewFid: 3452345,
				Names: []string{
					"ongo",
					"bongo",
					"filliyonko",
					"megatronko",
				},
			},
		}, {
			&WalkResponse{
				Tag: 45,
				Qids: []Qid{
					{},
					{},
					{},
				},
			},
		}, {
			&OpenRequest{
				Tag:  45,
				Fid:  21343,
				Mode: 4,
			},
		}, {
			&OpenResponse{
				Tag:    45,
				Qid:    Qid{},
				IOUnit: 1234123,
			},
		}, {
			&CreateRequest{
				Tag:         45,
				Fid:         12343,
				Name:        "wakakaaka",
				Permissions: DMDIR,
				Mode:        4,
			},
		}, {
			&CreateResponse{
				Tag:    45,
				Qid:    Qid{},
				IOUnit: 433535,
			},
		}, {
			&ReadRequest{
				Tag:    45,
				Fid:    5343,
				Offset: 359842382234,
				Count:  23423,
			},
		}, {
			&ReadResponse{
				Tag:  45,
				Data: []byte("ooooh nooo it's full of data"),
			},
		}, {
			&WriteRequest{
				Tag:    45,
				Fid:    254334,
				Offset: 21304978234,
				Data:   []byte("something to write"),
			},
		}, {
			&WriteResponse{
				Tag:   45,
				Count: 12,
			},
		}, {
			&ClunkRequest{
				Tag: 45,
				Fid: 23123,
			},
		}, {
			&ClunkResponse{
				Tag: 45,
			},
		}, {
			&RemoveRequest{
				Tag: 45,
				Fid: 1234,
			},
		}, {
			&RemoveResponse{
				Tag: 45,
			},
		}, {
			&StatRequest{
				Tag: 45,
				Fid: 12341234,
			},
		}, {
			&StatResponse{
				Tag:  45,
				Stat: Stat{},
			},
		}, {
			&WriteStatRequest{
				Tag:  45,
				Fid:  12342134,
				Stat: Stat{},
			},
		}, {
			&WriteStatResponse{
				Tag: 45,
			},
		},
	}
	for i, tt := range tests {
		reencode(i, tt.in, t)
	}
}
func TestReencode ( t * testing . T ) { tests := [ ] struct { in Codec } { { & Qid { Type : QTDIR , Version : 0x12340987 , Path : 0x10293874FFFFFF , } , } , { & Stat { Type : 0xDEAD , Dev : 0xABCDEF08 , Qid : Qid { } , Mode : FileMode ( OTRUNC ) , Atime : 90870987 , Mtime : 1234124 , Length : 0x23ABDDF8 , Name : " " , UID : " " , GID : " " , MUID : " " , } , } , { & VersionRequest { Tag : 45 , MaxSize : 9384 , Version : " " , } , } , { & VersionResponse { Tag : 45 , MaxSize : 9384 , Version : " " , } , } , { & AuthRequest { Tag : 45 , AuthFid : Fid ( 1234 ) , Username : " " , Service : " " , } , } , { & AuthResponse { Tag : 45 , AuthQid : Qid { } , } , } , { & AttachRequest { Tag : 45 , Fid : 35243 , AuthFid : 90872354 , Username : " " , Service : " " , } , } , { & AttachResponse { Tag : 45 , Qid : Qid { } , } , } , { & ErrorResponse { Tag : 45 , Error : " " , } , } , { & FlushRequest { Tag : 45 , OldTag : 23453 , } , } , { & FlushResponse { Tag : 45 , } , } , { & WalkRequest { Tag : 45 , Fid : 1234 , NewFid : 3452345 , Names : [ ] string { " " , " " , " " , " " , } , } , } , { & WalkResponse { Tag : 45 , Qids : [ ] Qid { { } , { } , { } , } , } , } , { & OpenRequest { Tag : 45 , Fid : 21343 , Mode : 4 , } , } , { & OpenResponse { Tag : 45 , Qid : Qid { } , IOUnit : 1234123 , } , } , { & CreateRequest { Tag : 45 , Fid : 12343 , Name : " " , Permissions : DMDIR , Mode : 4 , } , } , { & CreateResponse { Tag : 45 , Qid : Qid { } , IOUnit : 433535 , } , } , { & ReadRequest { Tag : 45 , Fid : 5343 , Offset : 359842382234 , Count : 23423 , } , } , { & ReadResponse { Tag : 45 , Data : [ ] byte ( " " ) , } , } , { & WriteRequest { Tag : 45 , Fid : 254334 , Offset : 21304978234 , Data : [ ] byte ( " " ) , } , } , { & WriteResponse { Tag : 45 , Count : 12 , } , } , { & ClunkRequest { Tag : 45 , Fid : 23123 , } , } , { & ClunkResponse { Tag : 45 , } , } , { & RemoveRequest { Tag : 45 , Fid : 1234 , } , } , { & RemoveResponse { Tag : 45 , } , } , { & StatRequest { Tag : 45 , Fid : 12341234 , } , } , { & StatResponse { Tag : 45 , Stat : Stat { } , } , } , { & WriteStatRequest { Tag : 45 , Fid : 12342134 , Stat : Stat { } , } , } , { & WriteStatResponse { Tag : 45 , } , } , } for i , tt := range tests { reencode ( i , tt . in , t ) } }
This test does NOT guarantee proper 9P2000 spec coding, but ensures at least
that all codecs are compatible with themselves.
This test does NOT guarantee proper 9P2000 spec coding but ensures at least that all codecs are compatible with themselves .