mirror of https://github.com/poanetwork/gecko.git
utils: Add test for Packer.Expand
This commit is contained in:
parent
18b7662266
commit
12117b1728
|
@ -43,6 +43,22 @@ func TestPackerCheckSpace(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPackerExpand(t *testing.T) {
|
||||||
|
p := Packer{Bytes: []byte{0x01}, Offset: 2}
|
||||||
|
p.Expand(1)
|
||||||
|
if !p.Errored() {
|
||||||
|
t.Fatal("packer.Expand didn't notice packer had out of bounds offset")
|
||||||
|
}
|
||||||
|
|
||||||
|
p = Packer{Bytes: []byte{0x01, 0x02, 0x03}, Offset: 0}
|
||||||
|
p.Expand(1)
|
||||||
|
if p.Errored() {
|
||||||
|
t.Fatalf("packer.Expand unexpectedly had error %s", p.Err)
|
||||||
|
} else if len(p.Bytes) != 3 {
|
||||||
|
t.Fatalf("packer.Expand modified byte array, when it didn't need to")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestPackerPackByte(t *testing.T) {
|
func TestPackerPackByte(t *testing.T) {
|
||||||
p := Packer{MaxSize: 1}
|
p := Packer{MaxSize: 1}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue