github.com/m4gshm/gollections@v0.0.13-0.20240331203319-a34a86e58a24/internal/examples/loopexamples/range_Of_test.go (about)

     1  package loopexamples
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/m4gshm/gollections/loop/range_"
     7  	"github.com/stretchr/testify/assert"
     8  )
     9  
    10  func Test_RangeOf(t *testing.T) {
    11  
    12  	var increasing = range_.Of(-1, 3).Slice()    //[]int{-1, 0, 1, 2}
    13  	var decreasing = range_.Of('e', 'a').Slice() //[]rune{'e', 'd', 'c', 'b'}
    14  	var nothing = range_.Of(1, 1).Slice()        //nil
    15  
    16  	assert.Equal(t, []int{-1, 0, 1, 2}, increasing)
    17  	assert.Equal(t, []rune{'e', 'd', 'c', 'b'}, decreasing)
    18  	assert.Nil(t, nothing)
    19  }