github.com/billybanfield/evergreen@v0.0.0-20170525200750-eeee692790f7/util/slice_test.go (about)

     1  package util
     2  
     3  import (
     4  	"testing"
     5  
     6  	. "github.com/smartystreets/goconvey/convey"
     7  )
     8  
     9  func TestStringSliceIntersection(t *testing.T) {
    10  	Convey("With two test string arrays [A B C D], [C D E]", t, func() {
    11  		a := []string{"A", "B", "C", "D"}
    12  		b := []string{"C", "D", "E"}
    13  
    14  		Convey("intersection [C D] should be returned", func() {
    15  			So(len(StringSliceIntersection(a, b)), ShouldEqual, 2)
    16  			So(StringSliceIntersection(a, b), ShouldContain, "C")
    17  			So(StringSliceIntersection(a, b), ShouldContain, "D")
    18  		})
    19  	})
    20  }
    21  
    22  func TestUniqueStrings(t *testing.T) {
    23  	Convey("With a test string slice ", t, func() {
    24  		Convey("[a b c a a d d e] should become [a b c d e]", func() {
    25  			in := []string{"a", "b", "c", "a", "a", "d", "d", "e"}
    26  			out := UniqueStrings(in)
    27  			So(out, ShouldResemble, []string{"a", "b", "c", "d", "e"})
    28  		})
    29  		Convey("[a b c] should remain [a b c]", func() {
    30  			in := []string{"a", "b", "c"}
    31  			out := UniqueStrings(in)
    32  			So(out, ShouldResemble, []string{"a", "b", "c"})
    33  		})
    34  	})
    35  }