...

Source file src/github.com/Microsoft/hcsshim/pkg/amdsevsnp/report_test.go

Documentation: github.com/Microsoft/hcsshim/pkg/amdsevsnp

     1  //go:build linux
     2  // +build linux
     3  
     4  package amdsevsnp
     5  
     6  import (
     7  	"testing"
     8  )
     9  
    10  func Test_Mirror_NonEmpty_Byte_Slices(t *testing.T) {
    11  	type config struct {
    12  		name     string
    13  		input    []byte
    14  		expected []byte
    15  	}
    16  
    17  	for _, conf := range []config{
    18  		{
    19  			name:     "Length0",
    20  			input:    []byte{},
    21  			expected: []byte{},
    22  		},
    23  		{
    24  			name:     "Length1",
    25  			input:    []byte{100},
    26  			expected: []byte{100},
    27  		},
    28  		{
    29  			name:     "LengthOdd",
    30  			input:    []byte{100, 101, 102, 103, 104},
    31  			expected: []byte{104, 103, 102, 101, 100},
    32  		},
    33  		{
    34  			name:     "LengthEven",
    35  			input:    []byte{100, 101, 102, 103, 104, 105},
    36  			expected: []byte{105, 104, 103, 102, 101, 100},
    37  		},
    38  	} {
    39  		t.Run(conf.name, func(t *testing.T) {
    40  			result := mirrorBytes(conf.input)
    41  			if string(result[:]) != string(conf.expected[:]) {
    42  				t.Fatalf("the ipnut byte array %+v was not mirrored; %+v", conf.input, result)
    43  			}
    44  		})
    45  	}
    46  }
    47  
    48  func Test_Mirror_Nil_Slice(t *testing.T) {
    49  	result := mirrorBytes(nil)
    50  	if result != nil {
    51  		t.Fatalf("expected nil slice, got: %+v", result)
    52  	}
    53  }
    54  

View as plain text