github.com/cayleygraph/cayley@v0.7.7/graph/iterator/unique_test.go (about)

     1  package iterator_test
     2  
     3  import (
     4  	"context"
     5  	"reflect"
     6  	"testing"
     7  
     8  	. "github.com/cayleygraph/cayley/graph/iterator"
     9  )
    10  
    11  func TestUniqueIteratorBasics(t *testing.T) {
    12  	ctx := context.TODO()
    13  	allIt := NewFixed(
    14  		Int64Node(1),
    15  		Int64Node(2),
    16  		Int64Node(3),
    17  		Int64Node(3),
    18  		Int64Node(2),
    19  	)
    20  
    21  	u := NewUnique(allIt)
    22  
    23  	expect := []int{1, 2, 3}
    24  	for i := 0; i < 2; i++ {
    25  		if got := iterated(u); !reflect.DeepEqual(got, expect) {
    26  			t.Errorf("Failed to iterate Unique correctly on repeat %d: got:%v expected:%v", i, got, expect)
    27  		}
    28  		u.Reset()
    29  	}
    30  
    31  	for _, v := range []int{1, 2, 3} {
    32  		if !u.Contains(ctx, Int64Node(v)) {
    33  			t.Errorf("Failed to find a correct value in the unique iterator.")
    34  		}
    35  	}
    36  }