package iterator import ( "reflect" "testing" ) func TestUniqueIteratorBasics(t *testing.T) { allIt := NewFixed(Identity) allIt.Add(1) allIt.Add(2) allIt.Add(3) allIt.Add(3) allIt.Add(2) u := NewUnique(allIt) expect := []int{1, 2, 3} for i := 0; i < 2; i++ { if got := iterated(u); !reflect.DeepEqual(got, expect) { t.Errorf("Failed to iterate Unique correctly on repeat %d: got:%v expected:%v", i, got, expect) } u.Reset() } for _, v := range []int{1, 2, 3} { if !u.Contains(v) { t.Errorf("Failed to find a correct value in the unique iterator.") } } }