feat: Add min and max and try to improve the performance

This commit is contained in:
rjianu
2023-07-17 20:18:16 +03:00
parent f837a1d217
commit 607561b9fe
9 changed files with 37 additions and 5 deletions

View File

@@ -23,11 +23,13 @@ func TestOperations(t *testing.T) {
}{
{"Sum", sum, []float64{300, 85.927, -30, 436}},
{"Avg", avg, []float64{37.5, 6.609769230769231, -15, 72.666666666666666}},
{"Min", min, []float64{10, 2.2, -20, 37}},
{"Max", max, []float64{100, 12.287, -10, 129}},
}
for _, tc := range testCases {
for k, exp := range tc.exp {
name := fmt.Sprintf("%sData%d", tc.name, k)
name := fmt.Sprintf("%s Data %d", tc.name, k)
t.Run(name, func(t *testing.T) {
res := tc.op(data[k])
// comparing floats might not be the best solution