github.com/imgk/caddy-trojan@v0.0.0-20221206043256-2631719e16c8/utils/utils_test.go (about)

     1  package utils
     2  
     3  import (
     4  	"bytes"
     5  	"testing"
     6  )
     7  
     8  func TestByteSliceToString(t *testing.T) {
     9  	for _, v := range []string{
    10  		"test1234",
    11  	} {
    12  		if ByteSliceToString([]byte(v)) != v {
    13  			t.Errorf("convert error: %v", v)
    14  		}
    15  	}
    16  }
    17  
    18  func TestStringToByteSlice(t *testing.T) {
    19  	for _, v := range []string{
    20  		"test1234",
    21  	} {
    22  		if !bytes.Equal([]byte(v), StringToByteSlice(v)) {
    23  			t.Errorf("convert error: %v", v)
    24  		}
    25  	}
    26  }