tests/testthat/test-icmp.r

context("ICMP")

test_that("We can ping localhost", {

  if (Sys.getenv("APPVEYOR") == "") {
    pr <- ping("127.0.0.1", count = 1)
    expect_true(is.double(pr))
    expect_true(length(pr) == 1)
    expect_true(pr < 1000)
  }
})

test_that("We can ping a remote host", {

  if (Sys.getenv("APPVEYOR") == "") {

    ## Non-existent IP
    pr <- ping("192.0.2.1", count = 1)
    expect_equal(pr, NA_real_)

    ## Google
    pr <- ping("google.com", count = 1)
    expect_true(is.double(pr))
    expect_true(length(pr) == 1)
    expect_true(pr < 1000)

    pr <- ping("8.8.8.8", count = 1)
    expect_true(is.double(pr))
    expect_true(length(pr) == 1)
    expect_true(pr < 1000)
  }
})

test_that("We don't wait too long", {

  ## TODO
  expect_true(TRUE)
})

Try the pingr package in your browser

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

pingr documentation built on Oct. 27, 2022, 1:06 a.m.