tests/testthat/test_plot_RLum.Data.Curve.R

## create dataset
data(ExampleData.CW_OSL_Curve, envir = environment())
data(ExampleData.BINfileData, envir = environment())
temp <- as(ExampleData.CW_OSL_Curve, "RLum.Data.Curve")
osl.bin <- Risoe.BINfileData2RLum.Analysis(CWOSL.SAR.Data, pos = 1)@records[[2]]
osl.bin.gy <- osl.bin
osl.bin.gy@info$IRR_UNIT <- 1

test_that("input validation", {
  testthat::skip_on_cran()

  expect_error(plot_RLum.Data.Curve("error"),
               "'object' should be of class 'RLum.Data.Curve'")
  expect_error(plot_RLum.Data.Curve(temp, norm = "error"),
               "'norm' should be one of 'max', 'min', 'first', 'last', 'huot' or 'intensity'")
  expect_error(plot_RLum.Data.Curve(temp, norm = -2),
               "'norm' should be a single positive value or one of 'max', 'min'")

  temp_NA <- temp
  temp_NA@data[] <- suppressWarnings(NA_real_)
  expect_warning(expect_null(plot_RLum.Data.Curve(temp_NA)),
                 "Curve contains only NA-values, nothing plotted")
  expect_warning(plot_RLum.Data.Curve(set_RLum("RLum.Data.Curve"), norm = TRUE),
                 "Curve normalisation produced Inf/NaN values, values replaced by 0")
})

test_that("check functionality", {
  testthat::skip_on_cran()

  ## run function with various conditions
  expect_silent(plot_RLum.Data.Curve(temp))
  expect_silent(plot_RLum.Data.Curve(temp, norm = TRUE))
  expect_silent(plot_RLum.Data.Curve(temp, norm = "max"))
  expect_silent(plot_RLum.Data.Curve(temp, norm = "last"))
  expect_silent(plot_RLum.Data.Curve(temp, norm = "huot"))
  expect_silent(plot_RLum.Data.Curve(temp, norm = "intensity"))
  expect_silent(plot_RLum.Data.Curve(temp, main = "title", col = "red"))
  expect_silent(plot_RLum.Data.Curve(temp, auto_scale = TRUE, xlim = c(10,20)))
  expect_silent(plot_RLum.Data.Curve(temp, auto_scale = TRUE, ylim = c(1,200)))
  expect_silent(plot_RLum.Data.Curve(temp, smooth = TRUE))
  expect_silent(plot_RLum.Data.Curve(temp, par.local = FALSE))

  temp@recordType <- "OSL"
  temp@info <- list(interval = 1)
  expect_silent(plot_RLum.Data.Curve(temp))
  temp@recordType <- "TL"
  temp@info <- list(curveDescripter = "xlab;ylab", RATE = 2)
  expect_silent(plot_RLum.Data.Curve(temp))
})

test_that("check interactive mode", {
  testthat::skip_on_cran()

  ## simple plot
  expect_silent(plot_RLum.Data.Curve(temp, interactive = TRUE))

  ## with arguments
  expect_silent(plot_RLum.Data.Curve(
    object = temp,
    interactive = TRUE,
    lty = 2,
    col = "red",
    log = "xy"))
})

test_that("graphical snapshot tests", {
  testthat::skip_on_cran()
  testthat::skip_if_not_installed("vdiffr")

  SW({
  vdiffr::expect_doppelganger("default",
                              plot_RLum.Data.Curve(temp))
  vdiffr::expect_doppelganger("autoscale-xlim-smooth",
                              plot_RLum.Data.Curve(temp, auto_scale = TRUE,
                                                   xlim = c(10, 20),
                                                   smooth = TRUE))
  vdiffr::expect_doppelganger("autoscale-ylim-mtext-cex",
                              plot_RLum.Data.Curve(temp, auto_scale = TRUE,
                                                   ylim = c(1, 200),
                                                   mtext = "Test", cex = 2))
  vdiffr::expect_doppelganger("bin",
                              plot_RLum.Data.Curve(osl.bin))
  vdiffr::expect_doppelganger("bin gy",
                              plot_RLum.Data.Curve(osl.bin.gy))
  })
})

Try the Luminescence package in your browser

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

Luminescence documentation built on Sept. 18, 2026, 9:07 a.m.