@@ -98,6 +98,46 @@ func TestSumBy(t *testing.T) {
9898 is .Equal (result5 , complex128 (6_6 ))
9999}
100100
101+ func TestProduct (t * testing.T ) {
102+ is := assert .New (t )
103+
104+ result1 := Product ([]float32 {2.3 , 3.3 , 4 , 5.3 })
105+ result2 := Product ([]int32 {2 , 3 , 4 , 5 })
106+ result3 := Product ([]int32 {7 , 8 , 9 , 0 })
107+ result4 := Product ([]int32 {7 , - 1 , 9 , 2 })
108+ result5 := Product ([]uint32 {2 , 3 , 4 , 5 })
109+ result6 := Product ([]uint32 {})
110+ result7 := Product ([]complex128 {4_4 , 2_2 })
111+
112+ is .Equal (result1 , float32 (160.908 ))
113+ is .Equal (result2 , int32 (120 ))
114+ is .Equal (result3 , int32 (0 ))
115+ is .Equal (result4 , int32 (- 126 ))
116+ is .Equal (result5 , uint32 (120 ))
117+ is .Equal (result6 , uint32 (0 ))
118+ is .Equal (result7 , complex128 (96_8 ))
119+ }
120+
121+ func TestProductBy (t * testing.T ) {
122+ is := assert .New (t )
123+
124+ result1 := ProductBy ([]float32 {2.3 , 3.3 , 4 , 5.3 }, func (n float32 ) float32 { return n })
125+ result2 := ProductBy ([]int32 {2 , 3 , 4 , 5 }, func (n int32 ) int32 { return n })
126+ result3 := ProductBy ([]int32 {7 , 8 , 9 , 0 }, func (n int32 ) int32 { return n })
127+ result4 := ProductBy ([]int32 {7 , - 1 , 9 , 2 }, func (n int32 ) int32 { return n })
128+ result5 := ProductBy ([]uint32 {2 , 3 , 4 , 5 }, func (n uint32 ) uint32 { return n })
129+ result6 := ProductBy ([]uint32 {}, func (n uint32 ) uint32 { return n })
130+ result7 := ProductBy ([]complex128 {4_4 , 2_2 }, func (n complex128 ) complex128 { return n })
131+
132+ is .Equal (result1 , float32 (160.908 ))
133+ is .Equal (result2 , int32 (120 ))
134+ is .Equal (result3 , int32 (0 ))
135+ is .Equal (result4 , int32 (- 126 ))
136+ is .Equal (result5 , uint32 (120 ))
137+ is .Equal (result6 , uint32 (0 ))
138+ is .Equal (result7 , complex128 (96_8 ))
139+ }
140+
101141func TestMean (t * testing.T ) {
102142 t .Parallel ()
103143 is := assert .New (t )
0 commit comments