Fixed Stats method for Not iterator.
Added unit tests for Not iterator.
This commit is contained in:
parent
a5fd1905d0
commit
305815e663
2 changed files with 49 additions and 8 deletions
44
graph/iterator/not_iterator_test.go
Normal file
44
graph/iterator/not_iterator_test.go
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
package iterator
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestNotIteratorBasics(t *testing.T) {
|
||||
allIt := newFixed()
|
||||
allIt.Add(1)
|
||||
allIt.Add(2)
|
||||
allIt.Add(3)
|
||||
allIt.Add(4)
|
||||
|
||||
toComplementIt := newFixed()
|
||||
toComplementIt.Add(2)
|
||||
toComplementIt.Add(4)
|
||||
|
||||
not := NewNot(toComplementIt, allIt)
|
||||
|
||||
if v, _ := not.Size(); v != 2 {
|
||||
t.Errorf("Unexpected iterator size: got:%d, expected: %d", v, 2)
|
||||
}
|
||||
|
||||
expect := []int{1, 3}
|
||||
for i := 0; i < 2; i++ {
|
||||
if got := iterated(not); !reflect.DeepEqual(got, expect) {
|
||||
t.Errorf("Failed to iterate Not correctly on repeat %d: got:%v expected:%v", i, got, expect)
|
||||
}
|
||||
not.Reset()
|
||||
}
|
||||
|
||||
for _, v := range []int{1, 3} {
|
||||
if !not.Contains(v) {
|
||||
t.Errorf("Failed to correctly check %d as true", v)
|
||||
}
|
||||
}
|
||||
|
||||
for _, v := range []int{2, 4} {
|
||||
if not.Contains(v) {
|
||||
t.Errorf("Failed to correctly check %d as false", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue