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

Function TestWriteStructOn64bitArch

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

Source from the content-addressed store, hash-verified

139}
140
141func TestWriteStructOn64bitArch(t *testing.T) {
142 arch := device.Big64
143 values := encodableStruct{0x12, BytePtr(0xbeefdeaddeadbeef), 0x3456, 0x8888888899999999}
144
145 buf := &bytes.Buffer{}
146 e := NewEncoder(endian.Writer(buf, arch.GetEndian()), arch)
147 Write(e, values)
148
149 got := buf.Bytes()
150 expected := []byte{
151 0x12, // uint8
152 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // padding before pointer
153 0xbe, 0xef, 0xde, 0xad, 0xde, 0xad, 0xbe, 0xef, // pointer
154 0x34, 0x56, // int16
155 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // padding before uint64
156 0x88, 0x88, 0x88, 0x88,
157 0x99, 0x99, 0x99, 0x99,
158 }
159
160 if !bytes.Equal(got, expected) {
161 t.Errorf("Bytes were not as expected.\nExpected: % x\nGot: % x", expected, got)
162 }
163}

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