func TestUnevenStep(t *testing.T) { r := ranging.FromToStep(0, 5, 2) for i := 0; i < 5; i += 2 { v := <-r if i != int(v) { t.Errorf("Expected: %d Got: %d", i, v) } } }
func TestUnevenNegativeStep(t *testing.T) { r := ranging.FromToStep(100, -113, -20) for i := 100; i > -100; i -= 20 { v := <-r if i != int(v) { t.Errorf("Expected: %d Got: %d", i, v) } } }
func ExampleFromToStep() { for i := range ranging.FromToStep(5, -5, -2) { fmt.Println(i) } //Output: 5 //3 //1 //-1 //-3 }