MCPcopy Create free account
hub / github.com/OpenPrinting/goipp / TestAttributesCopy

Function TestAttributesCopy

attr_test.go:198–237  ·  view source on GitHub ↗

TestAttributesCopy tests Attributes.Clone and Attributes.DeepCopy

(t *testing.T)

Source from the content-addressed store, hash-verified

196
197// TestAttributesCopy tests Attributes.Clone and Attributes.DeepCopy
198func TestAttributesCopy(t *testing.T) {
199 type testData struct {
200 attrs Attributes
201 }
202
203 tests := []testData{
204 {nil},
205 {Attributes{}},
206 {
207 Attributes{
208 MakeAttr("attr1", TagString, String("hello"), String("world")),
209 MakeAttr("attr2", TagInteger, Integer(1), Integer(2), Integer(3)),
210 MakeAttr("attr2", TagBoolean, Boolean(true), Boolean(false)),
211 },
212 },
213 }
214
215 for _, test := range tests {
216 clone := test.attrs.Clone()
217
218 if !test.attrs.Equal(clone) {
219 t.Errorf("testing Attributes.Clone\n"+
220 "expected: %#v\n"+
221 "present: %#v\n",
222 test.attrs,
223 clone,
224 )
225 }
226
227 copy := test.attrs.DeepCopy()
228 if !test.attrs.Equal(copy) {
229 t.Errorf("testing Attributes.DeepCopy\n"+
230 "expected: %#v\n"+
231 "present: %#v\n",
232 test.attrs,
233 copy,
234 )
235 }
236 }
237}
238
239// TestAttributeUnpack tests Attribute.unpack method for all kinds
240// of Value types

Callers

nothing calls this directly

Calls 7

MakeAttrFunction · 0.85
StringTypeAlias · 0.85
IntegerTypeAlias · 0.85
BooleanTypeAlias · 0.85
DeepCopyMethod · 0.65
CloneMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected