MCPcopy Create free account
hub / github.com/google/gapid / TestWriteStructOn32bitArch

Function TestWriteStructOn32bitArch

gapis/memory/write_test.go:79–101  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

77}
78
79func TestWriteStructOn32bitArch(t *testing.T) {
80 arch := device.Big32
81 values := encodableStruct{0x12, BytePtr(0xdeadbeef), 0x3456, 0x8888888899999999}
82
83 buf := &bytes.Buffer{}
84 e := NewEncoder(endian.Writer(buf, arch.GetEndian()), arch)
85 Write(e, values)
86
87 got := buf.Bytes()
88 expected := []byte{
89 0x12, // uint8
90 0x00, 0x00, 0x00, // padding before pointer
91 0xde, 0xad, 0xbe, 0xef, // pointer
92 0x34, 0x56, // int16
93 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // padding before uint64
94 0x88, 0x88, 0x88, 0x88,
95 0x99, 0x99, 0x99, 0x99,
96 }
97
98 if !bytes.Equal(got, expected) {
99 t.Errorf("Bytes were not as expected.\nExpected: % x\nGot: % x", expected, got)
100 }
101}
102
103func TestWriteOn64bitArch(t *testing.T) {
104 arch := device.Big64

Callers

nothing calls this directly

Calls 5

BytePtrFunction · 0.85
NewEncoderFunction · 0.85
WriterMethod · 0.80
WriteFunction · 0.70
EqualMethod · 0.45

Tested by

no test coverage detected