MCPcopy Create free account
hub / github.com/DNAProject/DNA / TestReadWriteInt

Function TestReadWriteInt

common/serialization/serialize_test.go:160–186  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

158}
159
160func TestReadWriteInt(t *testing.T) {
161 b3 := new(bytes.Buffer)
162 b4 := new(bytes.Buffer)
163 b5 := new(bytes.Buffer)
164 b6 := new(bytes.Buffer)
165
166 a3 := uint8(100)
167 a4 := uint16(65535)
168 a5 := uint32(4294967295)
169 a6 := uint64(18446744073709551615)
170
171 WriteUint8(b3, a3)
172 WriteUint16(b4, a4)
173 WriteUint32(b5, a5)
174 WriteUint64(b6, a6)
175
176 fmt.Printf("uint8 %x\n", b3.Bytes())
177 fmt.Printf("uint16 %x\n", b4.Bytes())
178 fmt.Printf("uint32 %x\n", b5.Bytes())
179 fmt.Printf("uint63 %x\n", b6.Bytes())
180
181 fmt.Println(ReadUint8(b3))
182 fmt.Println(ReadUint16(b4))
183 fmt.Println(ReadUint32(b5))
184 fmt.Println(ReadUint64(b6))
185
186}
187
188func TestReadVarBytesMemAllocAttack(t *testing.T) {
189 buff := bytes.NewBuffer([]byte{1, 2, 3})

Callers

nothing calls this directly

Calls 9

WriteUint8Function · 0.85
WriteUint16Function · 0.85
WriteUint32Function · 0.85
WriteUint64Function · 0.85
ReadUint8Function · 0.85
ReadUint16Function · 0.85
ReadUint32Function · 0.85
ReadUint64Function · 0.85
BytesMethod · 0.45

Tested by

no test coverage detected