internal/pipewire: size without serialisation
All checks were successful
Test / Create distribution (push) Successful in 35s
Test / Sandbox (push) Successful in 2m21s
Test / Hakurei (push) Successful in 3m16s
Test / Hpkg (push) Successful in 4m12s
Test / Sandbox (race detector) (push) Successful in 4m29s
Test / Hakurei (race detector) (push) Successful in 5m13s
Test / Flake checks (push) Successful in 1m28s
All checks were successful
Test / Create distribution (push) Successful in 35s
Test / Sandbox (push) Successful in 2m21s
Test / Hakurei (push) Successful in 3m16s
Test / Hpkg (push) Successful in 4m12s
Test / Sandbox (race detector) (push) Successful in 4m29s
Test / Hakurei (race detector) (push) Successful in 5m13s
Test / Flake checks (push) Successful in 1m28s
This is required to achieve zero allocation (other than reflect). Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -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))
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user