aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/pipewire/pod_test.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-11-25 03:33:57 +0900
committerOphestra <cat@gensokyo.uk>2025-11-25 04:00:59 +0900
commit827dc9e1ba600622fd93f12f0e96de67e4b1347b (patch)
tree2d8da1aaecd307f2fcdec462936102c3172d4c1f /internal/pipewire/pod_test.go
parentd92de1c70977308c5d9a5c5be325f1b27be2c2f4 (diff)
internal/pipewire: implement string type
This is still NUL terminated strings, and an extra NUL character on an 8-byte string does cause an extra 7 bytes of padding. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/pipewire/pod_test.go')
-rw-r--r--internal/pipewire/pod_test.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/internal/pipewire/pod_test.go b/internal/pipewire/pod_test.go
index a7982865..a39f9614 100644
--- a/internal/pipewire/pod_test.go
+++ b/internal/pipewire/pod_test.go
@@ -2,6 +2,7 @@ package pipewire_test
import (
"encoding"
+ "encoding/json"
"reflect"
"testing"
)
@@ -37,7 +38,7 @@ func (testCases encodingTestCases[V, S]) run(t *testing.T) {
t.Fatalf("UnmarshalBinary: error = %v", err)
}
if !reflect.DeepEqual(&value, &tc.value) {
- t.Fatalf("UnmarshalBinary: %#v, want %#v", value, tc.value)
+ t.Fatalf("UnmarshalBinary:\n%s\nwant\n%s", mustMarshalJSON(value), mustMarshalJSON(tc.value))
}
})
@@ -53,3 +54,12 @@ func (testCases encodingTestCases[V, S]) run(t *testing.T) {
})
}
}
+
+// mustMarshalJSON calls [json.Marshal] and returns the result.
+func mustMarshalJSON(v any) string {
+ if data, err := json.Marshal(v); err != nil {
+ panic(err)
+ } else {
+ return string(data)
+ }
+}