Debian Codegraph @

examples/data/data_test.go

raw symbols SCIP
1 package data
2
3 import (
4 "encoding/binary"
5 "math"
6 "testing"
7 )
8
9 //go:generate go run asm.go -out data.s -stubs stub.go
10
11 func TestDataAt(t *testing.T) {
12 order := binary.LittleEndian
13 expect := make([]byte, 40)
14 order.PutUint64(expect[0:], 0x0011223344556677) // DATA(0, U64(0x0011223344556677))
15 copy(expect[8:], []byte("strconst")) // DATA(8, String("strconst"))
16 order.PutUint32(expect[16:], math.Float32bits(math.Pi)) // DATA(16, F32(math.Pi))
17 order.PutUint64(expect[24:], math.Float64bits(math.Pi)) // DATA(24, F64(math.Pi))
18 order.PutUint32(expect[32:], 0x00112233) // DATA(32, U32(0x00112233))
19 order.PutUint16(expect[36:], 0x4455) // DATA(36, U16(0x4455))
20 expect[38] = 0x66 // DATA(38, U8(0x66))
21 expect[39] = 0x77 // DATA(39, U8(0x77))
22
23 for i, e := range expect {
24 b := DataAt(i)
25 if b != e {
26 t.Errorf("DataAt(%d) = %#02x; expected %#02x", i, b, e)
27 }
28 }
29 }