github.com/GeniusesGroup/libgo@v0.0.0-20220929090155-5ff932cb408e/binary/binary_test.go (about)

     1  package binary
     2  
     3  import "testing"
     4  
     5  func TestUint8(t *testing.T) {
     6  	var expected uint8 = 0x01
     7  	if got := Uint8([]byte{0x01}); got != expected {
     8  		t.Errorf("Uint8(): got %x, want %x", got, expected)
     9  	}
    10  }
    11  
    12  func TestBool(t *testing.T) {
    13  	var expected bool = true
    14  	if got := Bool([]byte{0x01}); got != expected {
    15  		t.Errorf("Bool(): got %t, want %t", got, expected)
    16  	}
    17  }
    18  
    19  func TestPutUint8(t *testing.T) {
    20  	var got = [1]byte{0x00}
    21  	var expected = [1]byte{0x10}
    22  	if PutUint8(got[:], 0x10); got != expected {
    23  		t.Errorf("Uint8(): got %v, want %v", got, expected)
    24  	}
    25  }
    26  
    27  func TestPutBool(t *testing.T) {
    28  	var got = [1]byte{0x00}
    29  	var expected = [1]byte{0x01}
    30  	if PutBool(got[:], true); got != expected {
    31  		t.Errorf("PutBool(): got %v, want %v", got, expected)
    32  	}
    33  }