Skip to content
Snippets Groups Projects
Verified Commit f4fb8a3d authored by Gärber, Florian's avatar Gärber, Florian
Browse files

test: Add test for ChemoSpec_to_hyperSpec and inverse

parent 59c19fee
No related branches found
No related tags found
No related merge requests found
# This file is part of the standard setup for testthat.
# It is recommended that you do not modify it.
#
# Where should you do additional test configuration?
# Learn more about the roles of various files in:
# * https://r-pkgs.org/tests.html
# * https://testthat.r-lib.org/reference/test_package.html#special-files
library(testthat)
library(VISOR)
test_check("VISOR")
test_that("ChemoSpec ➡️ hyperSpec: SrE.IR", {
skip_if_not_installed("hyperSpec")
skip_if_not_installed("ChemoSpec")
skip_if_not_installed("ChemoSpecUtils")
suppressPackageStartupMessages({
library(ChemoSpec)
})
data("SrE.IR")
hy <- ChemoSpec_to_hyperSpec(SrE.IR)
expect_s4_class(hy, "hyperSpec")
})
test_that("ChemoSpec ➡️ hyperSpec: SrE.NMR", {
skip_if_not_installed("hyperSpec")
skip_if_not_installed("ChemoSpec")
skip_if_not_installed("ChemoSpecUtils")
suppressPackageStartupMessages({
library(ChemoSpec)
})
data("SrE.NMR")
hy <- ChemoSpec_to_hyperSpec(SrE.NMR)
expect_s4_class(hy, "hyperSpec")
})
test_that("ChemoSpec ➡️ hyperSpec: metMUD1", {
skip_if_not_installed("hyperSpec")
skip_if_not_installed("ChemoSpec")
skip_if_not_installed("ChemoSpecUtils")
suppressPackageStartupMessages({
library(ChemoSpec)
})
data("metMUD1")
hy <- ChemoSpec_to_hyperSpec(metMUD1)
expect_s4_class(hy, "hyperSpec")
})
test_that("ChemoSpec ➡️ hyperSpec: metMUD2", {
skip_if_not_installed("hyperSpec")
skip_if_not_installed("ChemoSpec")
skip_if_not_installed("ChemoSpecUtils")
suppressPackageStartupMessages({
library(ChemoSpec)
})
data("metMUD2")
hy <- ChemoSpec_to_hyperSpec(metMUD2)
expect_s4_class(hy, "hyperSpec")
})
test_that("ChemoSpec ➡️ hyperSpec: alignMUD", {
skip_if_not_installed("hyperSpec")
skip_if_not_installed("ChemoSpec")
skip_if_not_installed("ChemoSpecUtils")
suppressPackageStartupMessages({
library(ChemoSpec)
})
data("alignMUD")
hy <- ChemoSpec_to_hyperSpec(alignMUD)
expect_s4_class(hy, "hyperSpec")
})
test_that("hyperSpec ➡️ ChemoSpec: flu", {
skip_if_not_installed("hyperSpec")
skip_if_not_installed("ChemoSpecUtils")
suppressPackageStartupMessages({
library(hyperSpec)
})
data(flu)
suppressMessages({
hyperSpec_to_ChemoSpec(
flu,
names = 1:6 |> as.character(),
groups = LETTERS[1:6] |> as.factor()
)
})
expect(TRUE, "Should stop if chkSpectra fails")
})
test_that("hyperSpec ➡️ ChemoSpec: laser", {
skip_if_not_installed("hyperSpec")
skip_if_not_installed("ChemoSpecUtils")
suppressPackageStartupMessages({
library(hyperSpec)
})
data(laser)
suppressMessages({
hyperSpec_to_ChemoSpec(
laser,
names = 1:84 |> as.character(),
groups = rep("A", 84) |> as.factor()
)
})
expect(TRUE, "Should stop if chkSpectra fails")
})
test_that("hyperSpec ➡️ ChemoSpec: paracetamol", {
skip("ChemoSpec does not support duplicate frequencies")
})
test_that("hyperSpec ➡️ ChemoSpec: barbiturates", {
skip_if_not_installed("hyperSpec")
skip_if_not_installed("ChemoSpecUtils")
suppressPackageStartupMessages({
library(hyperSpec)
})
data(barbiturates)
suppressMessages({
b <- barbiturates |> hyperSpec::collapse()
b[[is.na(b)]] <- 0
hyperSpec_to_ChemoSpec(
b,
names = 1:5 |> as.character(),
groups = LETTERS[1:5] |> as.factor()
)
})
expect(TRUE, "Should stop if chkSpectra fails")
})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment