aboutsummaryrefslogtreecommitdiff
path: root/pkg/types/encoding_test.go
blob: cbcf3baced2f72c9ca81c7651d6b045f7f9da936 (plain)
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
package types

import (
	"bytes"
	"testing"
)

func TestPutSSHString(t *testing.T) {
	for _, tbl := range []struct {
		desc string
		in   string
	}{
		{
			desc: "valid",
			in:   "ö foo is a bar",
		},
	} {
		b := make([]byte, 4+len(tbl.in))
		i := putSSHString(b[:], tbl.in)

		if got, want := i, len(tbl.in)+4; got != want {
			t.Errorf("%q: len: got %d but wanted %d in test", tbl.desc, got, want)
		}

		if got, want := b[4:4+len(tbl.in)], []byte(tbl.in); !bytes.Equal(got, want) {
			t.Errorf("%q: got %x but wanted %x", tbl.desc, got, want)
		}
	}
}