tests/testthat/test_all_identical.R

context('all_are_identical')

testdat <- data.frame(
  a = factor(c(6,5,3,4,5)),
  b = factor(c('one', 'two', 'three', 'four', ' apple ')),
  c = c('one', 'two', 'three', 'four', 'apple'),
  d = c(TRUE, TRUE, TRUE, FALSE, FALSE),
  e = c(1, 1, 1, 1, 1),
  f = c('moon', 'moon', 'moon', 'moon', 'moon'),
  g = c('TRUE', 'TRUE', 'TRUE', 'FALSE', 'FALSE'),
  h = c('3', '4', '5', '5', '5'),
  i = as.POSIXct(c('2015-01-01', '2015-01-05', '2015-05-04', '2015-12-01', '2015-04-13')),
  j = c('2015-01-01', '2015-01-05', '2015-05-04', '2015-12-01', '2015-04-13'),
  k = c('1', '1.5', '0.000000001', '100000000000', '99.1'),
  l = factor(c('1', '1.5', '0.000000001', '100000000000', '99.1')),
  m = factor(c('a', NA, NA, NA, NA)),
  n = factor(c(NA, NA, NA , NA, NA)),
  n2 = c('apple', 'applepie', 'moon', 'nomoon', 'moo'),
  stringsAsFactors = FALSE
)

test_that("all_are_identical works.", {
  expect_false(all_are_identical(testdat$a))
  expect_false(all_are_identical(testdat$b))
  expect_false(all_are_identical(testdat$c))
  expect_false(all_are_identical(testdat$d))
  expect_true(all_are_identical(testdat$e))
  expect_true(all_are_identical(testdat$f))
})
s-fleck/isit documentation built on Aug. 20, 2019, 8:39 a.m.