mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-02-26 23:57:23 +00:00
feat: add unittest to check panic on inexactly overlap
This commit is contained in:
parent
8f9de727bb
commit
04fd64d135
1 changed files with 26 additions and 0 deletions
|
|
@ -104,6 +104,32 @@ func TestOR(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestORBytesInexactOverlap(t *testing.T) {
|
||||
shouldPanic := func(f func()) (ok bool) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
if r.(string) == "ORBytes: invalid overlap" {
|
||||
ok = true
|
||||
}
|
||||
}
|
||||
}()
|
||||
f()
|
||||
return
|
||||
}
|
||||
a := make([]byte, 5)
|
||||
if ok := shouldPanic(func() {
|
||||
ORBytes(a[1:4], a[0:3], make([]byte, 3))
|
||||
}); !ok {
|
||||
t.Error("expected panic on inexact overlap")
|
||||
}
|
||||
|
||||
if ok := shouldPanic(func() {
|
||||
ORBytes(a[1:4], make([]byte, 3), a[0:3])
|
||||
}); !ok {
|
||||
t.Error("expected panic on inexact overlap")
|
||||
}
|
||||
}
|
||||
|
||||
// Tests that bit testing works for various alignments.
|
||||
func TestTest(t *testing.T) {
|
||||
for align := 0; align < 2; align++ {
|
||||
|
|
|
|||
Loading…
Reference in a new issue