common/helpers: add a useless test for how Diff() works with []byte

This commit is contained in:
Vincent Bernat
2025-06-11 22:47:27 +02:00
parent 5b2e122914
commit 322ddbe2ab

View File

@@ -0,0 +1,26 @@
// SPDX-FileCopyrightText: 2025 Free Mobile
// SPDX-License-Identifier: AGPL-3.0-only
package helpers
import "testing"
func TestDiffStringBytes(t *testing.T) {
type TestStruct struct {
A any
B any
}
got := TestStruct{
A: "hello",
B: []byte("bye"),
}
want := TestStruct{
A: "hello",
B: "bye",
}
if diff := Diff(got, want); diff == "" {
// We expect a diff if we have []byte in one case and string in another.
// The test is mostly for self-documentation of this behavior.
t.Fatalf("Diff() (-got, +want):\n%s", diff)
}
}