v0.4.1_hotfix

This commit is contained in:
Mateusz Gruszczyński committed 2026-11-05 13:49:33 +01:00
1 parent e0b80d8304
commit 7fa646c904
5 files changed
+165 -42

No files matched your search

+14 -3
View File
@@ -33,14 +33,14 @@ func TestDownsampleAveragesBuckets(t *testing.T) {
}
}
func TestDownsampleSkipsNulls(t *testing.T) {
func TestDownsampleTreatsNullsAsZeroInsideNonEmptyBucket(t *testing.T) {
in := []Point{{T: 1, V: f(2)}, {T: 2, V: nil}, {T: 3, V: f(4)}, {T: 4, V: nil}}
out := downsample(in, 1)
if len(out) != 1 {
t.Fatalf("expected 1 bucket, got %d", len(out))
}
if out[0].V == nil || *out[0].V != 3 {
t.Fatalf("expected average of non-null values (3), got %v", out[0].V)
if out[0].V == nil || *out[0].V != 1.5 {
t.Fatalf("expected NULL-as-zero bucket average (1.5), got %v", out[0].V)
}
}
@@ -54,3 +54,14 @@ func TestDownsampleAllNullBucketStaysNull(t *testing.T) {
t.Fatalf("expected nil for an all-null bucket, got %v", *out[0].V)
}
}
func TestDownsampleMaxKeepsPeak(t *testing.T) {
in := []Point{{T: 1, V: f(1)}, {T: 2, V: f(7)}, {T: 3, V: nil}, {T: 4, V: f(3)}}
out := downsampleMax(in, 1)
if len(out) != 1 {
t.Fatalf("expected 1 bucket, got %d", len(out))
}
if out[0].V == nil || *out[0].V != 7 {
t.Fatalf("expected bucket peak 7, got %v", out[0].V)
}
}