tests/testthat/test_convert_xy2TKA.R

test_that("General tests", {
  testthat::skip_on_cran()
  local_edition(3)

  ##general stop ... not object
  expect_error(convert_xy2TKA())

  ##wrong input
  expect_error(convert_xy2TKA(object = data.frame()))

})


test_that("Input and output", {
  testthat::skip_on_cran()
  local_edition(3)

  ##input as xylib object
  expect_type(
    convert_xy2TKA(
      object = read_xyData(system.file("extdata/ExampleSpectrum.CNF", package = "rxylib"))),
    "list")

  ##input as file path
  expect_type(
    convert_xy2TKA(
      object = system.file("extdata/ExampleSpectrum.CNF", package = "rxylib")),
    "list")

  ##input file path not correct
  expect_type(
    convert_xy2TKA(
      object = system.file("extdata/ExampleSpectrum.TEST", package = "rxylib")),
    "NULL")

  ##input format not recognised
  expect_error(
    convert_xy2TKA(
      object = system.file("extdata/ExampleChiPlot.chi", package = "rxylib")))

  ##test output writing
  path <- tempfile()

    ##with input file and no name
    expect_silent(convert_xy2TKA(
      object = system.file("extdata/ExampleSpectrum.CNF", package = "rxylib"),
      file = path
      ))

    ##with file name
    expect_silent(convert_xy2TKA(
      object = system.file("extdata/ExampleSpectrum.CNF", package = "rxylib"),
      file = paste0(path, "test.TKA")
    ))


})

Try the rxylib package in your browser

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

rxylib documentation built on Nov. 3, 2023, 5:09 p.m.