File: test-missing.R

package info (click to toggle)
r-cran-blob 1.2.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 180 kB
  • sloc: sh: 13; makefile: 2
file content (23 lines) | stat: -rw-r--r-- 586 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
context("missing")

test_that("is.na detects nulls", {
  x <- blob(as.raw(1), NULL, as.raw(2), NULL)
  expect_equal(is.na(x), c(FALSE, TRUE, FALSE, TRUE))
})

test_that("is.na<- sets missing values", {
  x <- blob(!!!as.raw(1:4))
  is.na(x) <- (1:4 %% 2 == 0)

  expect_equal(x, blob(as.raw(1), NULL, as.raw(3), NULL))
})

test_that("is.na<- auto-expansion for logical indexes", {
  x <- blob(!!!as.raw(1:4))
  expect_error(is.na(x) <- rep(TRUE, 5))
})

test_that("is.na<- auto-expansion for character indices", {
  x <- blob(!!!as.raw(1:4))
  expect_error(is.na(x) <- letters[1:2])
})