...
1
2
3
4
5 package dwarf
6
7 import (
8 "reflect"
9 "testing"
10 )
11
12 func TestSevenBitEnc128(t *testing.T) {
13 t.Run("unsigned", func(t *testing.T) {
14 for v := int64(-255); v < 255; v++ {
15 s := sevenBitU(v)
16 if s == nil {
17 continue
18 }
19 b := AppendUleb128(nil, uint64(v))
20 if !reflect.DeepEqual(b, s) {
21 t.Errorf("sevenBitU(%d) = %v but AppendUleb128(%d) = %v", v, s, v, b)
22 }
23 }
24 })
25
26 t.Run("signed", func(t *testing.T) {
27 for v := int64(-255); v < 255; v++ {
28 s := sevenBitS(v)
29 if s == nil {
30 continue
31 }
32 b := AppendSleb128(nil, v)
33 if !reflect.DeepEqual(b, s) {
34 t.Errorf("sevenBitS(%d) = %v but AppendSleb128(%d) = %v", v, s, v, b)
35 }
36 }
37 })
38 }
39
View as plain text