github.com/haraldrudell/parl@v0.4.176/iters/empty_test.go (about)

     1  /*
     2  © 2022–present Harald Rudell <harald.rudell@gmail.com> (https://haraldrudell.github.io/haraldrudell/)
     3  ISC License
     4  */
     5  
     6  package iters
     7  
     8  import (
     9  	"testing"
    10  )
    11  
    12  func TestEmpty(t *testing.T) {
    13  	var ok bool
    14  	var zeroValue int
    15  	var actual int
    16  	var err error
    17  
    18  	iter := NewEmptyIterator[int]()
    19  
    20  	if actual, ok = iter.Next(); ok {
    21  		t.Error("Next returned true")
    22  	} else if actual != zeroValue {
    23  		t.Error("Next returned other than zero-value")
    24  	}
    25  	if err = iter.Cancel(); err != nil {
    26  		t.Errorf("Cancel err: %v", err)
    27  	}
    28  }