tests/testthat/test_combine.R

library("testthat")
library("spectrolab")

context("Spectra combine")

spec = as_spectra(spec_matrix_example, name_idx = 1)
s1   = spec
bands(s1) = seq(ncol(s1))
s2   = spec[ , 400:2000]

test_that("combining wrong class throws", {
    expect_error( combine(spec, as.matrix(spec)) )
})

test_that("combining incompatible band values throws", {
    expect_error( combine(spec, s1) )
})

test_that("combining different band number throws", {
    expect_error( combine(spec, s2) )
})

test_that("combining identical obj doubles the number of samples", {
    expect_true( nrow(combine(spec, spec)) == nrow(spec) * 2 )
})
meireles/spectrolab documentation built on Jan. 16, 2025, 12:23 p.m.