tests/testthat/test-ilength.r

context("ilength of an iterator")

test_that("ilength functions properly with a vector", {
  expect_equal(ilength(1:5), 5)
})

test_that("ilength functions properly with an iterator", {
  it <- iterators::iter(1:5)
  expect_equal(ilength(it), 5)
})

test_that("ilength functions properly with a chained iterator", {
  it <- ichain(1:3, 4:5, 6)
  expect_equal(ilength(it), 6)
})

test_that("ilength functions properly with a chained iterator of mixed types", {
  it <- ichain(1:3, levels(iris$Species))
  expect_equal(ilength(it), 6)
})

Try the itertools2 package in your browser

Any scripts or data that you put into this service are public.

itertools2 documentation built on May 2, 2019, 3:37 p.m.