MCPcopy Create free account
hub / github.com/aws/smithy-go / TestEncode_KitchenSink

Function TestEncode_KitchenSink

document/cbor/encode_test.go:13–115  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestEncode_KitchenSink(t *testing.T) {
14 type subtarget struct {
15 Int8 int8
16 Int16 int16
17 }
18 type target struct {
19 Int8 int8
20 Int16 int16
21 Int32 int32
22 Int64 int64
23 Uint8 uint8
24 Uint16 uint16
25 Uint32 uint32
26 Uint64 uint64
27 String string
28 List []subtarget
29 Map map[string]subtarget
30 UintptrNil *uint
31 UintptrNonnil *uint
32 Bool bool
33 Float float64
34 BigInt *big.Int
35 BigNegInt *big.Int
36 }
37
38 in := target{
39 Int8: -8,
40 Int16: -16,
41 Int32: -32,
42 Int64: -64,
43 Uint8: 8,
44 Uint16: 16,
45 Uint32: 32,
46 Uint64: 64,
47 String: "foo",
48 List: []subtarget{
49 {Int8: -8},
50 },
51 Map: map[string]subtarget{
52 "k0": {Int8: -8},
53 },
54 UintptrNil: nil,
55 UintptrNonnil: ptr.Uint(4),
56 Bool: true,
57 Float: math.Inf(1),
58 BigInt: new(big.Int).SetBytes([]byte{1, 0, 0, 0, 0, 0, 0, 0, 0}),
59 BigNegInt: new(big.Int).Sub(
60 big.NewInt(-1),
61 new(big.Int).SetBytes([]byte{1, 0, 0, 0, 0, 0, 0, 0, 0}),
62 ),
63 }
64
65 expect := cbor.Map{
66 "Int8": cbor.NegInt(8),
67 "Int16": cbor.NegInt(16),
68 "Int32": cbor.NegInt(32),
69 "Int64": cbor.NegInt(64),
70 "Uint8": cbor.Uint(8),

Callers

nothing calls this directly

Calls 9

EncodeMethod · 0.95
UintFunction · 0.92
NegIntTypeAlias · 0.92
UintTypeAlias · 0.92
StringTypeAlias · 0.92
BoolTypeAlias · 0.92
Float64TypeAlias · 0.92
DecodeFunction · 0.92
ErrorfMethod · 0.80

Tested by

no test coverage detected