github.com/safing/portbase@v0.19.5/utils/safe_test.go (about)

     1  package utils
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  )
     8  
     9  func TestSafeFirst16(t *testing.T) {
    10  	t.Parallel()
    11  
    12  	assert.Equal(t,
    13  		"47 6f 20 69 73 20 61 6e  20 6f 70 65 6e 20 73 6f  |Go is an open so|",
    14  		SafeFirst16Bytes([]byte("Go is an open source programming language.")),
    15  	)
    16  	assert.Equal(t,
    17  		"47 6f 20 69 73 20 61 6e  20 6f 70 65 6e 20 73 6f  |Go is an open so|",
    18  		SafeFirst16Chars("Go is an open source programming language."),
    19  	)
    20  
    21  	assert.Equal(t,
    22  		"<empty>",
    23  		SafeFirst16Bytes(nil),
    24  	)
    25  	assert.Equal(t,
    26  		"<empty>",
    27  		SafeFirst16Chars(""),
    28  	)
    29  }