github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/utils/rmbs/rmbs_test.go (about)

     1  package rmbs_test
     2  
     3  import (
     4  	"strings"
     5  	"testing"
     6  
     7  	"github.com/lmorg/murex/test/count"
     8  	"github.com/lmorg/murex/utils/rmbs"
     9  )
    10  
    11  func TestRmBS(t *testing.T) {
    12  	tests := []struct {
    13  		Source   string
    14  		Expected string
    15  	}{
    16  		{
    17  			Source:   "",
    18  			Expected: "",
    19  		},
    20  		{
    21  			Source:   "--ca-bundle",
    22  			Expected: "--ca-bundle",
    23  		},
    24  		{
    25  			Source:   "--88-8-8cc8aa8--8bb8uu8nn8dd8ll8ee8",
    26  			Expected: "ca-bundle",
    27  		},
    28  	}
    29  
    30  	count.Tests(t, len(tests))
    31  
    32  	for i, test := range tests {
    33  		source := strings.ReplaceAll(test.Source, "8", string([]byte{8}))
    34  
    35  		actual := rmbs.Remove(source)
    36  
    37  		if actual != test.Expected {
    38  			t.Errorf("Unexpected result in test %d", i)
    39  			t.Logf("  Source:    '%s'", test.Source)
    40  			t.Logf("  Expected:  '%s'", test.Expected)
    41  			t.Logf("  Actual:    '%s'", actual)
    42  			t.Log("  exp bytes:", []byte(test.Expected))
    43  			t.Log("  act bytes:", []byte(actual))
    44  		}
    45  	}
    46  }