MCPcopy Index your code
hub / github.com/godbus/dbus / TestEncodeArrayOfMaps

Function TestEncodeArrayOfMaps

encoder_test.go:10–61  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestEncodeArrayOfMaps(t *testing.T) {
11 tests := []struct {
12 name string
13 vs []any
14 }{
15 {
16 "aligned at 8 at start of array",
17 []any{
18 "12345",
19 []map[string]Variant{
20 {
21 "abcdefg": MakeVariant("foo"),
22 "cdef": MakeVariant(uint32(2)),
23 },
24 },
25 },
26 },
27 {
28 "not aligned at 8 for start of array",
29 []any{
30 "1234567890",
31 []map[string]Variant{
32 {
33 "abcdefg": MakeVariant("foo"),
34 "cdef": MakeVariant(uint32(2)),
35 },
36 },
37 },
38 },
39 }
40 for _, order := range []binary.ByteOrder{binary.LittleEndian, binary.BigEndian} {
41 for _, tt := range tests {
42 buf := new(bytes.Buffer)
43 fds := make([]int, 0)
44 enc := newEncoder(buf, order, fds)
45 if err := enc.Encode(tt.vs...); err != nil {
46 t.Fatal(err)
47 }
48
49 dec := newDecoder(buf, order, enc.fds)
50 v, err := dec.Decode(SignatureOf(tt.vs...))
51 if err != nil {
52 t.Errorf("%q: decode (%v) failed: %v", tt.name, order, err)
53 continue
54 }
55 if !reflect.DeepEqual(v, tt.vs) {
56 t.Errorf("%q: (%v) not equal: got '%v', want '%v'", tt.name, order, v, tt.vs)
57 continue
58 }
59 }
60 }
61}
62
63func TestEncodeMapStringInterface(t *testing.T) {
64 val := map[string]any{"foo": "bar"}

Callers

nothing calls this directly

Calls 6

MakeVariantFunction · 0.85
newEncoderFunction · 0.85
newDecoderFunction · 0.85
SignatureOfFunction · 0.85
EncodeMethod · 0.80
DecodeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…