TestGroupsCopy tests Groups.Clone and Groups.DeepCopy
(t *testing.T)
| 308 | |
| 309 | // TestGroupsCopy tests Groups.Clone and Groups.DeepCopy |
| 310 | func TestGroupsCopy(t *testing.T) { |
| 311 | g1 := Group{ |
| 312 | TagJobGroup, |
| 313 | Attributes{MakeAttr("attr1", TagInteger, Integer(1))}, |
| 314 | } |
| 315 | |
| 316 | g2 := Group{ |
| 317 | TagJobGroup, |
| 318 | Attributes{MakeAttr("attr2", TagInteger, Integer(2))}, |
| 319 | } |
| 320 | |
| 321 | g3 := Group{ |
| 322 | TagPrinterGroup, |
| 323 | Attributes{MakeAttr("attr2", TagInteger, Integer(2))}, |
| 324 | } |
| 325 | |
| 326 | type testData struct { |
| 327 | groups Groups |
| 328 | } |
| 329 | |
| 330 | tests := []testData{ |
| 331 | {nil}, |
| 332 | {Groups{}}, |
| 333 | {Groups{g1, g2, g3}}, |
| 334 | } |
| 335 | |
| 336 | for _, test := range tests { |
| 337 | clone := test.groups.Clone() |
| 338 | |
| 339 | if !test.groups.Equal(clone) { |
| 340 | t.Errorf("testing Groups.Clone\n"+ |
| 341 | "expected: %#v\n"+ |
| 342 | "present: %#v\n", |
| 343 | test.groups, |
| 344 | clone, |
| 345 | ) |
| 346 | } |
| 347 | |
| 348 | copy := test.groups.DeepCopy() |
| 349 | if !test.groups.Equal(copy) { |
| 350 | t.Errorf("testing Groups.DeepCopy\n"+ |
| 351 | "expected: %#v\n"+ |
| 352 | "present: %#v\n", |
| 353 | test.groups, |
| 354 | copy, |
| 355 | ) |
| 356 | } |
| 357 | } |
| 358 | } |