tests/testthat/test-57-contvariable.R

test_that("CONTVARIABLE is handled correctly", {
  x <- px(get_px_file_path("CONTVARIABLE"))

  contvariable_name <- "ContentsCode"

  # CONTVARIABLE should be TRUE
  x$variables1 |>
    dplyr::filter(`variable-code` == contvariable_name) |>
    dplyr::pull(contvariable) |>
    expect_true()

  # CONTVARIABLE should be FALSE for all other variables
  x$variables1 |>
    dplyr::filter(`variable-code` != contvariable_name) |>
    dplyr::pull(contvariable) |>
    any() |>
    expect_false()

  # CONTVARIABLE should not be created as a keyword in table2
  x$table2 |>
    dplyr::filter(keyword == "CONTVARIABLE") |>
    nrow() |>
    expect_equal(0)
})

Try the pxmake package in your browser

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

pxmake documentation built on April 18, 2026, 5:08 p.m.