github.com/dahs81/otto@v0.2.1-0.20160126165905-6400716cf085/appfile/detect/sort_test.go (about)

     1  package detect
     2  
     3  import (
     4  	"reflect"
     5  	"sort"
     6  	"testing"
     7  )
     8  
     9  func TestDetectorList_impl(t *testing.T) {
    10  	var _ sort.Interface = new(DetectorList)
    11  }
    12  
    13  func TestDetectorList(t *testing.T) {
    14  	cases := []struct {
    15  		Input  []*Detector
    16  		Output []*Detector
    17  	}{
    18  		{
    19  			Input: []*Detector{
    20  				&Detector{Type: "foo"},
    21  				&Detector{Type: "bar"},
    22  			},
    23  			Output: []*Detector{
    24  				&Detector{Type: "foo"},
    25  				&Detector{Type: "bar"},
    26  			},
    27  		},
    28  
    29  		{
    30  			Input: []*Detector{
    31  				&Detector{Type: "foo"},
    32  				&Detector{Type: "bar", Priority: 10},
    33  			},
    34  			Output: []*Detector{
    35  				&Detector{Type: "bar", Priority: 10},
    36  				&Detector{Type: "foo"},
    37  			},
    38  		},
    39  	}
    40  
    41  	for i, tc := range cases {
    42  		sort.Sort(DetectorList(tc.Input))
    43  		if !reflect.DeepEqual(tc.Input, tc.Output) {
    44  			t.Fatalf("%d\n\nInput: %#v\n\nOutput: %#v", i, tc.Input, tc.Output)
    45  		}
    46  	}
    47  }