File: lowlevelmsgutil_test.go

package info (click to toggle)
rootlesskit 2.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 636 kB
  • sloc: sh: 433; makefile: 25
file content (34 lines) | stat: -rw-r--r-- 471 bytes parent folder | download
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
package lowlevelmsgutil

import (
	"encoding/hex"
	"testing"
)

func TestMarshal(t *testing.T) {
	emptyStruct := struct{}{}
	fooStruct := struct{ Foo string }{Foo: "hello"}
	testCases := []struct {
		x interface{}
	}{
		{
			x: nil,
		},
		{
			x: 42,
		},
		{
			x: &emptyStruct,
		},
		{
			x: &fooStruct,
		},
	}
	for i, tc := range testCases {
		b, err := Marshal(tc.x)
		if err != nil {
			t.Fatal(err)
		}
		t.Logf("%d: marshal %+v\n%s", i, tc.x, hex.Dump(b))
	}
}