TestAttributesCopy tests Attributes.Clone and Attributes.DeepCopy
(t *testing.T)
| 196 | |
| 197 | // TestAttributesCopy tests Attributes.Clone and Attributes.DeepCopy |
| 198 | func 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 |