stc.Insert(target, initialMin-1) Ω(stc.MaxDistance()).Should(Equal(initialMin - 1)) stc.Insert(target, initialMin-1) Ω(stc.MaxDistance()).Should(Equal(initialMin - 1)) }) }) }) }) Describe("Vote", func() { var stc knnutilities.SortedTargetCollection Context("When the collection is not empty", func() { var target1, target2, target3 slice.Slice BeforeEach(func() { stc = knnutilities.NewKNNTargetCollection(5) columnTypes, err := columntype.StringsToColumnTypes([]string{"1.0"}) Ω(err).ShouldNot(HaveOccurred()) raw1, err := columnTypes[0].PersistRawFromString("1.0") Ω(err).ShouldNot(HaveOccurred()) raw2, err := columnTypes[0].PersistRawFromString("2.0") Ω(err).ShouldNot(HaveOccurred()) raw3, err := columnTypes[0].PersistRawFromString("3.0") Ω(err).ShouldNot(HaveOccurred())
rawValues := []float64{1.2, invalidColumn1RawValue, 0, col3val1raw, 4.9, 2.2} s, err = slice.SliceFromRawValues(false, columnIndices, columnTypes, rawValues) }) It("Returns an error", func() { Ω(err).Should(HaveOccurred()) }) }) }) }) }) Describe("SliceFromRawValues and Equals", func() { var columnTypes []columntype.ColumnType var err error var s1, s2 slice.Slice Context("Given slices of different lengths", func() { BeforeEach(func() { columnTypes, err = columntype.StringsToColumnTypes([]string{"1.0", "1.0"}) Ω(err).ShouldNot(HaveOccurred()) }) It("returns false", func() { s1, _ = slice.SliceFromRawValues(true, []int{}, columnTypes, []float64{0.0, 1.0}) s2, _ = slice.SliceFromRawValues(true, []int{0}, columnTypes, []float64{0.0, 1.0}) Ω(s1.Equals(s2)).Should(BeFalse()) }) })