Debian Codegraph @

unmarshal_test.go

raw symbols SCIP
1 package barescip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/
2
3 import (
4 "testingscip-go gomod github.com/golang/go/src go1.14 testing/"
5
6 "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/"
7 )
8
9 func TestUnmarshalValuescip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/TestUnmarshalValue().(t *testingscip-go gomod github.com/golang/go/src go1.14 testing/.Tscip-go gomod github.com/golang/go/src go1.14 testing/T#) {
10 var (
11 err error
12
13 u8 uint8
14 u16 uint16
15 u32 uint32
16 u64 uint64
17 u uint
18 vu Uintscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Uint#
19 i8 int8
20 i16 int16
21 i32 int32
22 i64 int64
23 i int
24 vi Intscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Int#
25 f32 float32
26 f64 float64
27 b bool
28 str string
29 )
30
31 payloads := [][]byte{
32 []byte{0x42},
33 []byte{0xFE, 0xCA},
34 []byte{0xEF, 0xBE, 0xAD, 0xDE},
35 []byte{0xEF, 0xBE, 0xAD, 0xDE, 0xBE, 0xBA, 0xFE, 0xCA},
36 []byte{0xEF, 0xFD, 0xB6, 0xF5, 0x0D},
37 []byte{0xD6},
38 []byte{0x2E, 0xFB},
39 []byte{0xB2, 0x9E, 0x43, 0xFF},
40 []byte{0x4F, 0x0B, 0x6E, 0x9D, 0xAB, 0x23, 0xD4, 0xFF},
41 []byte{0x9B, 0x85, 0xE3, 0x0B},
42 []byte{0x71, 0x2D, 0xA7, 0x44},
43 []byte{0x9B, 0x6C, 0xC9, 0x20, 0xF0, 0x21, 0x3F, 0x42},
44 []byte{0x00, 0x01, 0x02},
45 []byte{0x1B, 0xE3, 0x81, 0x93, 0xE3, 0x82, 0x93, 0xE3, 0x81, 0xAB,
46 0xE3, 0x81, 0xA1, 0xE3, 0x81, 0xAF, 0xE3, 0x80, 0x81, 0xE4, 0xB8,
47 0x96, 0xE7, 0x95, 0x8C, 0xEF, 0xBC, 0x81},
48 }
49
50 err = Unmarshalscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Unmarshal().(payloads[0], &u8)
51 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Nil().(t, err, "Expected Unmarshal to return without error")
52 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, uint8(0x42), u8, "Expected Unmarshal to read 0x42")
53
54 err = Unmarshalscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Unmarshal().(payloads[1], &u16)
55 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Nil().(t, err, "Expected Unmarshal to return without error")
56 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, uint16(0xCAFE), u16, "Expected Unmarshal to read 0xCAFE")
57
58 err = Unmarshalscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Unmarshal().(payloads[2], &u32)
59 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Nil().(t, err, "Expected Unmarshal to return without error")
60 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, uint32(0xDEADBEEF), u32, "Expected Unmarshal to read 0xDEADBEEF")
61
62 err = Unmarshalscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Unmarshal().(payloads[3], &u64)
63 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Nil().(t, err, "Expected Unmarshal to return without error")
64 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, uint64(0xCAFEBABEDEADBEEF), u64, "Expected Unmarshal to read 0xCAFEBABEDEADBEEF")
65
66 err = Unmarshalscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Unmarshal().(payloads[4], &u)
67 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Nil().(t, err, "Expected Unmarshal to return without error")
68 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, uint(0xDEADBEEF), u, "Expected Unmarshal to read 0xDEADBEEF")
69
70 err = Unmarshalscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Unmarshal().(payloads[4], &vu)
71 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Nil().(t, err, "Expected Unmarshal to return without error")
72 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, Uintscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Uint#(0xDEADBEEF), vu, "Expected Unmarshal to read 0xDEADBEEF")
73
74 err = Unmarshalscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Unmarshal().(payloads[5], &i8)
75 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Nil().(t, err, "Expected Unmarshal to return without error")
76 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, int8(-42), i8, "Expected Unmarshal to read -42")
77
78 err = Unmarshalscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Unmarshal().(payloads[6], &i16)
79 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Nil().(t, err, "Expected Unmarshal to return without error")
80 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, int16(-1234), i16, "Expected Unmarshal to read -1234")
81
82 err = Unmarshalscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Unmarshal().(payloads[7], &i32)
83 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Nil().(t, err, "Expected Unmarshal to return without error")
84 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, int32(-12345678), i32, "Expected Unmarshal to read -12345678")
85
86 err = Unmarshalscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Unmarshal().(payloads[8], &i64)
87 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Nil().(t, err, "Expected Unmarshal to return without error")
88 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, int64(-12345678987654321), i64, "Expected Unmarshal to read -12345678987654321")
89
90 err = Unmarshalscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Unmarshal().(payloads[9], &i)
91 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Nil().(t, err, "Expected Unmarshal to return without error")
92 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, int(-12345678), i, "Expected Unmarshal to read -12345678")
93
94 err = Unmarshalscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Unmarshal().(payloads[9], &vi)
95 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Nil().(t, err, "Expected Unmarshal to return without error")
96 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, Intscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Int#(-12345678), vi, "Expected Unmarshal to read -12345678")
97
98 err = Unmarshalscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Unmarshal().(payloads[10], &f32)
99 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Nil().(t, err, "Expected Unmarshal to return without error")
100 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, float32(1337.42), f32, "Expected Unmarshal to read 1337.42")
101
102 err = Unmarshalscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Unmarshal().(payloads[11], &f64)
103 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Nil().(t, err, "Expected Unmarshal to return without error")
104 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, float64(133713371337.42424242), f64, "Expected Unmarshal to read 133713371337.42424242")
105
106 err = Unmarshalscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Unmarshal().(payloads[12][0:], &b)
107 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Nil().(t, err, "Expected Unmarshal to return without error")
108 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Falsescip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/False().(t, b, "Expected Unmarshal to read false")
109
110 err = Unmarshalscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Unmarshal().(payloads[12][1:], &b)
111 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Nil().(t, err, "Expected Unmarshal to return without error")
112 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Truescip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/True().(t, b, "Expected Unmarshal to read true")
113
114 err = Unmarshalscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Unmarshal().(payloads[12][2:], &b)
115 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.EqualErrorscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/EqualError().(t, err, "Invalid bool value: 0x2")
116
117 err = Unmarshalscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Unmarshal().(payloads[13], &str)
118 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Nil().(t, err, "Expected Unmarshal to return without error")
119 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, "こんにちは、世界!", str, "Expected Unmarshal to read 'こんにちは、世界!'")
120 }
121
122 func TestUnmarshalOptionalscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/TestUnmarshalOptional().(t *testingscip-go gomod github.com/golang/go/src go1.14 testing/.Tscip-go gomod github.com/golang/go/src go1.14 testing/T#) {
123 var val *uint32
124 err := Unmarshalscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Unmarshal().([]byte{0x00}, &val)
125 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Nil().(t, err, "Expected Unmarshal to return without error")
126 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Nil().(t, val, "Expected Unmarshal to read nil")
127
128 err = Unmarshalscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Unmarshal().([]byte{0x01, 0xEF, 0xBE, 0xAD, 0xDE}, &val)
129 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Nil().(t, err, "Expected Unmarshal to return without error")
130 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.NotNilscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/NotNil().(t, val, "Expected Unmarshal to read non-nil value")
131 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, uint32(0xDEADBEEF), *val, "Expected Unmarshal to read 0xDEADBEEF")
132
133 err = Unmarshalscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Unmarshal().([]byte{0x02}, &val)
134 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.EqualErrorscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/EqualError().(t, err, "Invalid optional value: 0x2")
135 }
136
137 func TestUnmarshalStructscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/TestUnmarshalStruct().(t *testingscip-go gomod github.com/golang/go/src go1.14 testing/.Tscip-go gomod github.com/golang/go/src go1.14 testing/T#) {
138 type Coordinates struct{ X, Y, Z uint }
139 payload := []byte{0x01, 0x02, 0x03}
140 var coords Coordinates
141 err := Unmarshalscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Unmarshal().(payload, &coords)
142 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Nil().(t, err, "Expected Unmarshal to return without error")
143 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, uint(1), coords.X, "Expected Unmarshal to read {1, 2, 3}")
144 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, uint(2), coords.Y, "Expected Unmarshal to read {1, 2, 3}")
145 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, uint(3), coords.Z, "Expected Unmarshal to read {1, 2, 3}")
146 }
147
148 func TestUnmarshalOmittedFieldsscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/TestUnmarshalOmittedFields().(t *testingscip-go gomod github.com/golang/go/src go1.14 testing/.Tscip-go gomod github.com/golang/go/src go1.14 testing/T#) {
149 type Coordinates struct {
150 X uint
151 Y uint
152 Z uint `bare:"-"`
153 }
154 payload := []byte{0x01, 0x02}
155 var coords Coordinates
156 err := Unmarshalscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Unmarshal().(payload, &coords)
157 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Nil().(t, err, "Expected Unmarshal to return without error")
158 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, uint(1), coords.X, "Expected Unmarshal to read {1, 2}")
159 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, uint(2), coords.Y, "Expected Unmarshal to read {1, 2}")
160 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, uint(0), coords.Z, "Expected Unmarshal to ignore field")
161 }
162
163 func TestUnmarshalArrayscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/TestUnmarshalArray().(t *testingscip-go gomod github.com/golang/go/src go1.14 testing/.Tscip-go gomod github.com/golang/go/src go1.14 testing/T#) {
164 var val [4]uint8
165 err := Unmarshalscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Unmarshal().([]byte{0x11, 0x22, 0x33, 0x44}, &val)
166 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Nil().(t, err, "Expected Unmarshal to return without error")
167 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, uint8(0x11), val[0], "Expected Unmarshal to read 0x11")
168 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, uint8(0x22), val[1], "Expected Unmarshal to read 0x22")
169 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, uint8(0x33), val[2], "Expected Unmarshal to read 0x33")
170 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, uint8(0x44), val[3], "Expected Unmarshal to read 0x44")
171 }
172
173 func TestUnmarshalSlicescip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/TestUnmarshalSlice().(t *testingscip-go gomod github.com/golang/go/src go1.14 testing/.Tscip-go gomod github.com/golang/go/src go1.14 testing/T#) {
174 var val []uint8
175 err := Unmarshalscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Unmarshal().([]byte{0x04, 0x11, 0x22, 0x33, 0x44}, &val)
176 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Nil().(t, err, "Expected Unmarshal to return without error")
177 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, 4, len(val), "Expected Unmarshal to read slice of length 4")
178 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, uint8(0x11), val[0], "Expected Unmarshal to read 0x11")
179 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, uint8(0x22), val[1], "Expected Unmarshal to read 0x22")
180 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, uint8(0x33), val[2], "Expected Unmarshal to read 0x33")
181 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, uint8(0x44), val[3], "Expected Unmarshal to read 0x44")
182
183 MaxArrayLengthscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/MaxArrayLength().(64)
184 err = Unmarshalscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Unmarshal().([]byte{100}, &val)
185 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.EqualErrorscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/EqualError().(t, err, "Array length 100 exceeds configured limit of 64")
186 }
187
188 func TestUnmarshalMapscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/TestUnmarshalMap().(t *testingscip-go gomod github.com/golang/go/src go1.14 testing/.Tscip-go gomod github.com/golang/go/src go1.14 testing/T#) {
189 var val map[uint8]uint8
190 payload := []byte{
191 0x03,
192 0x01, 0x11,
193 0x02, 0x22,
194 0x03, 0x33,
195 }
196 err := Unmarshalscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Unmarshal().(payload, &val)
197 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Nil().(t, err, "Expected Unmarshal to return without error")
198 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, 3, len(val), "Expected Unmarshal to read map of length 3")
199 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, uint8(0x11), val[uint8(0x01)], "Expected Unmarshal to read 0x01 -> 0x11")
200 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, uint8(0x22), val[uint8(0x02)], "Expected Unmarshal to read 0x02 -> 0x22")
201 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, uint8(0x33), val[uint8(0x03)], "Expected Unmarshal to read 0x03 -> 0x33")
202
203 t.Runscip-go gomod github.com/golang/go/src go1.14 testing/T#Run().("rejects duplicate keys", func(t *testingscip-go gomod github.com/golang/go/src go1.14 testing/.Tscip-go gomod github.com/golang/go/src go1.14 testing/T#) {
204 payload = []byte{
205 0x02,
206 0x01, 0x13,
207 0x01, 0x37,
208 }
209 err = Unmarshalscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Unmarshal().(payload, &val)
210 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.EqualErrorscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/EqualError().(t, err, "Encountered duplicate map key: 1")
211 })
212
213 t.Runscip-go gomod github.com/golang/go/src go1.14 testing/T#Run().("respects size limits", func(t *testingscip-go gomod github.com/golang/go/src go1.14 testing/.Tscip-go gomod github.com/golang/go/src go1.14 testing/T#) {
214 MaxMapSizescip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/MaxMapSize().(64)
215 payload = []byte{100}
216 err = Unmarshalscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Unmarshal().(payload, &val)
217 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.EqualErrorscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/EqualError().(t, err, "Map size 100 exceeds configured limit of 64")
218 })
219 }
220
221 func TestUnmarshalUnionscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/TestUnmarshalUnion().(t *testingscip-go gomod github.com/golang/go/src go1.14 testing/.Tscip-go gomod github.com/golang/go/src go1.14 testing/T#) {
222 var val NameAgescip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/NameAge#
223 payload := []byte{0x00, 0x04, 0x4d, 0x61, 0x72, 0x79}
224 err := Unmarshalscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Unmarshal().(payload, &val)
225 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Nil().(t, err, "Expected Unmarshal to return without error")
226
227 name, ok := val.(*Namescip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Name#)
228 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Truescip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/True().(t, ok)
229 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, Namescip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Name#("Mary"), *name)
230
231 payload = []byte{0x01, 0x30}
232 err = Unmarshalscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Unmarshal().(payload, &val)
233 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Nil().(t, err, "Expected Unmarshal to return without error")
234
235 age, ok := val.(*Agescip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Age#)
236 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Truescip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/True().(t, ok)
237 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, Agescip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Age#(24), *age)
238
239 payload = []byte{0x13, 0x37}
240 err = Unmarshalscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Unmarshal().(payload, &val)
241 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.EqualErrorscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/EqualError().(t, err, "Invalid union tag 19 for type NameAge")
242 }
243
244 func TestUnmarshalCustomscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/TestUnmarshalCustom().(t *testingscip-go gomod github.com/golang/go/src go1.14 testing/.Tscip-go gomod github.com/golang/go/src go1.14 testing/T#) {
245 var val Customscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Custom#
246 payload := []byte{0x0, 0x42}
247
248 err := Unmarshalscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Unmarshal().(payload, &val)
249 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Nil().(t, err, "Expected Unmarshal to return without error")
250 assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, Customscip-go gomod git.sr.ht/~sircmpwn/go-bare . `git.sr.ht/~sircmpwn/go-bare`/Custom#(0x42), val)
251 }