github.com/mook-as/cf-cli@v7.0.0-beta.28.0.20200120190804-b91c115fae48+incompatible/util/sorting/alphabetic_test.go (about) 1 package sorting_test 2 3 import ( 4 "sort" 5 6 . "code.cloudfoundry.org/cli/util/sorting" 7 8 . "github.com/onsi/ginkgo" 9 . "github.com/onsi/ginkgo/extensions/table" 10 . "github.com/onsi/gomega" 11 ) 12 13 var _ = Describe("SortAlphabeticFunc", func() { 14 DescribeTable("sorts strings alphabetically when", 15 func(input []string, expected []string) { 16 sort.Slice(input, SortAlphabeticFunc(input)) 17 Expect(input).To(Equal(expected)) 18 }, 19 20 Entry("the slice is empty", 21 []string{}, 22 []string{}), 23 24 Entry("the slice contains one element", 25 []string{"a"}, 26 []string{"a"}), 27 28 Entry("the slice contains duplicates", 29 []string{"blurb", "a", "blurb"}, 30 []string{"a", "blurb", "blurb"}), 31 32 Entry("there are mixed cases and numbers", 33 []string{ 34 "sister", 35 "Father", 36 "Mother", 37 "brother", 38 "3-twins", 39 }, 40 []string{ 41 "3-twins", 42 "brother", 43 "Father", 44 "Mother", 45 "sister", 46 }), 47 48 Entry("capitals come before lowercase", 49 []string{ 50 "Stack2", 51 "stack3", 52 "stack1", 53 }, 54 []string{ 55 "stack1", 56 "Stack2", 57 "stack3", 58 }), 59 60 Entry("the strings are already sorted", 61 []string{ 62 "sb0", 63 "sb1", 64 "sb2", 65 }, 66 []string{ 67 "sb0", 68 "sb1", 69 "sb2", 70 }), 71 ) 72 })