(t *testing.T)
| 8 | ) |
| 9 | |
| 10 | func 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 | |
| 63 | func TestEncodeMapStringInterface(t *testing.T) { |
| 64 | val := map[string]any{"foo": "bar"} |
nothing calls this directly
no test coverage detected
searching dependent graphs…