Beispiel #1
0
var _ = Describe("StringSlice", func() {
	It("should add one element", func() {
		s := gotility.StringSlice{}
		s.Add("foo")
		Expect(s).To(ConsistOf([]string{"foo"}))
	})

	It("should add all elements", func() {
		s := gotility.StringSlice{}
		s.AddAll("foo", "bar", "baz")
		Expect(s).To(ConsistOf([]string{"foo", "bar", "baz"}))
	})

	It("should delete elements by index", func() {
		s := gotility.StringSlice{}
		Expect(s.DeleteByIndex(0)).To(BeFalse())
		Expect(s.DeleteByIndex(-1)).To(BeFalse())
		Expect(s.DeleteByIndex(42)).To(BeFalse())

		s = gotility.StringSlice{"foo", "bar", "baz"}
		Expect(s).To(ConsistOf([]string{"foo", "bar", "baz"}))
		Expect(s.DeleteByIndex(1)).To(BeTrue())
		Expect(s).To(ConsistOf([]string{"foo", "baz"}))
		Expect(s.DeleteByIndex(0)).To(BeTrue())
		Expect(s).To(ConsistOf([]string{"baz"}))
		Expect(s.DeleteByIndex(0)).To(BeTrue())
		Expect(s).To(ConsistOf([]string{}))
	})

	It("should search and delete elements", func() {
		s := gotility.StringSlice{}