From 73987be7d4c850f8b95babb8f68e6ccb6cafcee4 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Thu, 27 Nov 2025 02:15:44 +0900 Subject: internal/pipewire: size without serialisation This is required to achieve zero allocation (other than reflect). Signed-off-by: Ophestra --- internal/pipewire/pod_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'internal/pipewire/pod_test.go') 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)) + } + }) + } }) } } -- cgit v1.3.1