github.com/cnboonhan/delve@v0.0.0-20230908061759-363f2388c2fb/pkg/dwarf/leb128/decode_test.go (about)

     1  package leb128
     2  
     3  import (
     4  	"bytes"
     5  	"testing"
     6  )
     7  
     8  func TestDecodeUnsigned(t *testing.T) {
     9  	leb128 := bytes.NewBuffer([]byte{0xE5, 0x8E, 0x26})
    10  
    11  	n, c := DecodeUnsigned(leb128)
    12  	if n != 624485 {
    13  		t.Fatal("Number was not decoded properly, got: ", n, c)
    14  	}
    15  
    16  	if c != 3 {
    17  		t.Fatal("Count not returned correctly")
    18  	}
    19  }
    20  
    21  func TestDecodeSigned(t *testing.T) {
    22  	sleb128 := bytes.NewBuffer([]byte{0x9b, 0xf1, 0x59})
    23  
    24  	n, c := DecodeSigned(sleb128)
    25  	if n != -624485 {
    26  		t.Fatal("Number was not decoded properly, got: ", n, c)
    27  	}
    28  }