tests/testthat/test_eq_load_clean_data.R

context('test shortcut method to load and clean data ')

test_that('eq_load_clean_data loads data correctly', {

  quick_quakes <- eq_load_clean_data()

  expect_is(quick_quakes$LATITUDE, 'numeric')
  expect_is(quick_quakes$LONGITUDE, 'numeric')

  # the "slow" way
  slow_quakes <- quakes %>%
    eq_clean_data() %>%
    eq_location_clean()

  expect_equal(sum(quick_quakes$LOCATION_NAME == slow_quakes$LOCATION_NAME,
                   na.rm = TRUE),
               sum(!(is.na(quick_quakes$LOCATION_NAME))))

  expect_equal(sum(quick_quakes$DATE == slow_quakes$DATE),
               nrow(quick_quakes))
})
JazminCevallos/Package-Evaluation documentation built on May 27, 2019, 12:16 p.m.