aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/stats/sample_test.go
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2024-06-13 20:30:13 +0200
committerAleksandr Nogikh <nogikh@google.com>2024-06-14 08:29:50 +0000
commit286c38bd1ae34870c40986e8ddebfd65d6e5049e (patch)
tree6d183001c80bf66a4f079a3399e6d140480b36ca /pkg/stats/sample_test.go
parenta9616ff57d4ef2794b54e02c26315c739ca8bc85 (diff)
pkg/stats: split out pkg/stats/sample
This will reduce the number of dependencies needed for the main syzkaller tools.
Diffstat (limited to 'pkg/stats/sample_test.go')
-rw-r--r--pkg/stats/sample_test.go66
1 files changed, 0 insertions, 66 deletions
diff --git a/pkg/stats/sample_test.go b/pkg/stats/sample_test.go
deleted file mode 100644
index 9e88e9f93..000000000
--- a/pkg/stats/sample_test.go
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright 2021 syzkaller project authors. All rights reserved.
-// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
-
-package stats
-
-import (
- "reflect"
- "testing"
-)
-
-func TestMedian(t *testing.T) {
- tests := []struct {
- input []float64
- minMedian float64
- maxMedian float64
- }{
- {
- input: []float64{1, 2, 3},
- minMedian: 1.99, // we cannot do exact floating point equality comparison
- maxMedian: 2.01,
- },
- {
- input: []float64{0, 1, 2, 3},
- minMedian: 1.0,
- maxMedian: 2.0,
- },
- }
- for _, test := range tests {
- sample := Sample{Xs: test.input}
- median := sample.Median()
- if median < test.minMedian || median > test.maxMedian {
- t.Errorf("sample %v, median got %v, median expected [%v;%v]",
- test.input, median, test.minMedian, test.maxMedian)
- }
- }
-}
-
-func TestRemoveOutliers(t *testing.T) {
- // Some tests just to check the overall sanity of the method.
- tests := []struct {
- input []float64
- output []float64
- }{
- {
- input: []float64{-20, 1, 2, 3, 4, 5},
- output: []float64{1, 2, 3, 4, 5},
- },
- {
- input: []float64{1, 2, 3, 4, 25},
- output: []float64{1, 2, 3, 4},
- },
- {
- input: []float64{-10, -5, 0, 5, 10, 15},
- output: []float64{-10, -5, 0, 5, 10, 15},
- },
- }
- for _, test := range tests {
- sample := Sample{Xs: test.input}
- result := sample.RemoveOutliers()
- result.Sort()
- if !reflect.DeepEqual(result.Xs, test.output) {
- t.Errorf("input: %v, expected no outliers: %v, got: %v",
- test.input, test.output, result.Xs)
- }
- }
-}