aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/pipewire/pod_test.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-11-27 02:15:44 +0900
committerOphestra <cat@gensokyo.uk>2025-11-27 02:17:38 +0900
commit73987be7d4c850f8b95babb8f68e6ccb6cafcee4 (patch)
treec46e77b552fe508b7970be199699b07ae86cb288 /internal/pipewire/pod_test.go
parent563b5e66fc0dfe0abc4a4b8c96f0f89ef71c3422 (diff)
internal/pipewire: size without serialisation
This is required to achieve zero allocation (other than reflect). Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/pipewire/pod_test.go')
-rw-r--r--internal/pipewire/pod_test.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/internal/pipewire/pod_test.go b/internal/pipewire/pod_test.go
index a39f9614..28e789f5 100644
--- a/internal/pipewire/pod_test.go
+++ b/internal/pipewire/pod_test.go
@@ -5,11 +5,14 @@ import (
"encoding/json"
"reflect"
"testing"
+
+ "hakurei.app/internal/pipewire"
)
type encodingTestCases[V any, S interface {
encoding.BinaryMarshaler
encoding.BinaryUnmarshaler
+
*V
}] []struct {
// Uninterpreted name of subtest.
@@ -51,6 +54,14 @@ func (testCases encodingTestCases[V, S]) run(t *testing.T) {
t.Fatalf("MarshalBinary: %#v, want %#v", gotData, tc.wantData)
}
})
+
+ if s, ok := any(&tc.value).(pipewire.KnownSize); ok {
+ t.Run("size", func(t *testing.T) {
+ if got := int(s.Size()); got != len(tc.wantData) {
+ t.Errorf("Size: %d, want %d", got, len(tc.wantData))
+ }
+ })
+ }
})
}
}