File: test-null.R

package info (click to toggle)
r-cran-covr 3.5.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 984 kB
  • sloc: javascript: 238; cpp: 54; ansic: 48; xml: 41; sh: 18; makefile: 11
file content (26 lines) | stat: -rw-r--r-- 565 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
context("NULL")

test_that("coverage of functions with NULL constructs", {
  f1 <- function() NULL
  f2 <- function() {
    NULL
  }
  f3 <- function() {
    if (FALSE) {
      NULL
    }
  }
  f4 <- function() {
    if (FALSE)
      NULL
  }

  cv1 <- function_coverage(f1, f1())
  expect_equal(percent_coverage(cv1), 100)
  cv2 <- function_coverage(f2, f2())
  expect_equal(percent_coverage(cv2), 100)
  cv3 <- function_coverage(f3, f3())
  expect_equal(percent_coverage(cv3), 50)
  cv4 <- function_coverage(f4, f4())
  expect_equal(percent_coverage(cv4), 50)
})