...

Source file src/cuelabs.dev/go/oci/ociregistry/iter_test.go

Documentation: cuelabs.dev/go/oci/ociregistry

     1  //go:build go1.23 || goexperiment.rangefunc
     2  
     3  package ociregistry
     4  
     5  import (
     6  	"errors"
     7  	"testing"
     8  
     9  	"github.com/go-quicktest/qt"
    10  )
    11  
    12  func TestSliceIter(t *testing.T) {
    13  	slice := []int{3, 1, 4}
    14  	var got []int
    15  	for x, err := range SliceIter(slice) {
    16  		qt.Assert(t, qt.IsNil(err))
    17  		got = append(got, x)
    18  	}
    19  	qt.Assert(t, qt.DeepEquals(got, slice))
    20  }
    21  
    22  func TestErrorIter(t *testing.T) {
    23  	err := errors.New("foo")
    24  	i := 0
    25  	for s, gotErr := range ErrorIter[string](err) {
    26  		qt.Assert(t, qt.Equals(i, 0))
    27  		qt.Assert(t, qt.Equals(s, ""))
    28  		qt.Assert(t, qt.Equals(err, gotErr))
    29  		i++
    30  	}
    31  	qt.Assert(t, qt.Equals(i, 1))
    32  }
    33  

View as plain text