github.com/Benchkram/bob@v0.0.0-20220321080157-7c8f3876e225/bob/run_test.go (about)

     1  package bob
     2  
     3  import (
     4  	"reflect"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/assert"
     8  )
     9  
    10  func TestNormalize(t *testing.T) {
    11  
    12  	type test struct {
    13  		input    []string
    14  		expected []string
    15  	}
    16  
    17  	tests := []test{
    18  
    19  		{
    20  			// 1 - 2 - 3
    21  			input:    []string{"1", "2", "3"},
    22  			expected: []string{"1", "2", "3"},
    23  		},
    24  
    25  		{
    26  			// 1 - 2 - 3
    27  			//   \
    28  			//     3 - 4
    29  			input:    []string{"1", "2", "3", "3", "4"},
    30  			expected: []string{"1", "2", "3", "4"},
    31  		},
    32  
    33  		{
    34  			// 1 - 2 - 5 - 4
    35  			// | \
    36  			// |   3 - 4
    37  			//  \
    38  			//    5 - 4
    39  			input:    []string{"1", "2", "5", "4", "3", "4", "5", "4"},
    40  			expected: []string{"1", "2", "3", "5", "4"},
    41  		},
    42  	}
    43  
    44  	for _, test := range tests {
    45  		result := normalize(test.input)
    46  		assert.True(t, reflect.DeepEqual(test.expected, result))
    47  	}
    48  }