github.com/mvdan/u-root-coreutils@v0.0.0-20230122170626-c2eef2898555/pkg/smbios/header_test.go (about)

     1  // Copyright 2016-2021 the u-root Authors. All rights reserved
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  package smbios
     5  
     6  import "testing"
     7  
     8  var (
     9  	validTableHeaderRaw = []byte{0x0, 0xFF, 0xBE, 0xEF}
    10  )
    11  
    12  func TestParseTableHeader(t *testing.T) {
    13  	var h Header
    14  	if err := h.Parse(validTableHeaderRaw); err != nil {
    15  		t.Error(err)
    16  	}
    17  }
    18  
    19  func TestHeaderToString(t *testing.T) {
    20  	h := Header{
    21  		Type:   0x1,
    22  		Length: 0xFF,
    23  		Handle: 0xBEEF,
    24  	}
    25  
    26  	expect := `Handle 0xBEEF, DMI type 1, 255 bytes
    27  System Information`
    28  
    29  	gotString := h.String()
    30  
    31  	if gotString != expect {
    32  		t.Errorf("Header.String(): %v, want %v", gotString, expect)
    33  	}
    34  }