From e1fc5082eab87c01a74c6c0500f2c7b7aeb0c7b7 Mon Sep 17 00:00:00 2001 From: Eva Rifa Date: Wed, 11 Oct 2023 11:32:18 +0200 Subject: [PATCH] Update unit tests --- tests/testthat/test-Lon2index.R | 2 +- tests/testthat/test-Selbox.R | 18 +++++++++--------- tests/testthat/test-ShiftLon.R | 2 +- tests/testthat/test-Subset.R | 6 +++--- tests/testthat/test-WeightedCells.R | 2 +- tests/testthat/test-WeightedMean.R | 18 +++++++++--------- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/tests/testthat/test-Lon2index.R b/tests/testthat/test-Lon2index.R index 8f53079..e435dee 100644 --- a/tests/testthat/test-Lon2index.R +++ b/tests/testthat/test-Lon2index.R @@ -1,4 +1,4 @@ -context("Generic tests") + test_that("Sanity checks", { expect_error(Lon2Index(lon = NULL), "Parameter 'lon' cannot be NULL.") expect_error(Lon2Index(lon = 'a'), "Parameter 'lon' must be numeric.") diff --git a/tests/testthat/test-Selbox.R b/tests/testthat/test-Selbox.R index fce7f06..1b7b5a9 100644 --- a/tests/testthat/test-Selbox.R +++ b/tests/testthat/test-Selbox.R @@ -1,4 +1,4 @@ -context("ClimProjDiags::SelBox tests") + ############################################## @@ -73,8 +73,8 @@ test_that("1. Input checks", { expect_warning( SelBox(array(1:10, dim = c(lon = 10, lat = 1)), region = region, lon = 1:10, lat = 1, londim = 1, latdim = 2), - "Numeric 'londim' is deprecated, use dimension names instead. The ", - "corresponding dimension name will be assigned." + paste0("Numeric 'londim' is deprecated, use dimension names instead. The ", + "corresponding dimension name will be assigned.") ) expect_error( SelBox(array(1:10, dim = c(lon = 10, lat = 1)), region = region, @@ -84,8 +84,8 @@ test_that("1. Input checks", { expect_warning( SelBox(array(1:10, dim = c(lon = 10, lat = 1)), region = region, lon = 1:10, lat = 1, londim = c('lon', 'lat'), latdim = 'lat'), - "Parameter 'londim' must be of length 1. Only the first value ", - "will be used." + paste0("Parameter 'londim' must be of length 1. Only the first value ", + "will be used.") ) expect_error( SelBox(array(1:10, dim = c(lons = 10, lat = 1)), region = region, @@ -102,8 +102,8 @@ test_that("1. Input checks", { expect_warning( SelBox(array(1:10, dim = c(lon = 10, lat = 1)), region = region, lon = 1:10, lat = 1, latdim = 2), - "Numeric 'latdim' is deprecated, use dimension names instead. The ", - "corresponding dimension name will be assigned." + paste0("Numeric 'latdim' is deprecated, use dimension names instead. The ", + "corresponding dimension name will be assigned.") ) expect_error( SelBox(array(1:10, dim = c(lon = 10, lat = 1)), region = region, @@ -113,8 +113,8 @@ test_that("1. Input checks", { expect_warning( SelBox(array(1:10, dim = c(lon = 10, lat = 1)), region = region, lon = 1:10, lat = 1, latdim = c('lat', 'lon')), - "Parameter 'latdim' must be of length 1. Only the first value ", - "will be used." + paste0("Parameter 'latdim' must be of length 1. Only the first value ", + "will be used.") ) expect_error( SelBox(array(1:10, dim = c(lon = 10, lats = 1)), region = region, diff --git a/tests/testthat/test-ShiftLon.R b/tests/testthat/test-ShiftLon.R index e414b5c..99b81e5 100644 --- a/tests/testthat/test-ShiftLon.R +++ b/tests/testthat/test-ShiftLon.R @@ -1,4 +1,4 @@ -context("ShiftLon tests") + ############################################## diff --git a/tests/testthat/test-Subset.R b/tests/testthat/test-Subset.R index 8144f96..f9ec418 100644 --- a/tests/testthat/test-Subset.R +++ b/tests/testthat/test-Subset.R @@ -1,4 +1,4 @@ -context("Subset tests") + dat1 <- array(1:20, dim = c(dat = 1, lat = 2, lon = 10)) @@ -249,7 +249,7 @@ test_that("4. dat3", { expect_equal( Subset(dat1, 'dat', 1, drop = FALSE), Subset(dat3, 'dat', 1, drop = FALSE), -check.attributes = F +ignore_attr = T ) expect_equal( attributes(Subset(dat3, 'dat', 1, drop = FALSE)), @@ -270,7 +270,7 @@ list(dim = c(10), dimensions = c('lon')) expect_equal( Subset(dat1, c('lat', 'lon'), list(1, 2), drop = TRUE), Subset(dat3, c('lat', 'lon'), list(1, 2), drop = TRUE), -check.attributes = F +ignore_attr = T ) expect_equal( attributes(Subset(dat3, c('lat', 'lon'), list(1, 2), drop = TRUE)), diff --git a/tests/testthat/test-WeightedCells.R b/tests/testthat/test-WeightedCells.R index a5e9dd1..8f771f4 100644 --- a/tests/testthat/test-WeightedCells.R +++ b/tests/testthat/test-WeightedCells.R @@ -1,4 +1,4 @@ -context("ClimProjDiags::WeightedCells tests") + ############################################## diff --git a/tests/testthat/test-WeightedMean.R b/tests/testthat/test-WeightedMean.R index 3edfcae..4309710 100644 --- a/tests/testthat/test-WeightedMean.R +++ b/tests/testthat/test-WeightedMean.R @@ -1,4 +1,4 @@ -context("ClimProjDiags::WeightedMean tests") + ############################################## @@ -63,8 +63,8 @@ test_that("1. Input checks", { expect_warning( WeightedMean(array(1:10, dim = c(lon = 10, lat = 1)), lon = 1:10, lat = 1, londim = 1, latdim = 2), - "Numeric 'londim' is deprecated, use dimension names instead. The ", - "corresponding dimension name will be assigned." + paste0("Numeric 'londim' is deprecated, use dimension names instead. The ", + "corresponding dimension name will be assigned.") ) expect_error( WeightedMean(array(1:10, dim = c(lon = 10, lat = 1)), @@ -74,8 +74,8 @@ test_that("1. Input checks", { expect_warning( WeightedMean(array(1:10, dim = c(lon = 10, lat = 1)), lon = 1:10, lat = 1, londim = c('lon', 'lat'), latdim = 'lat'), - "Parameter 'londim' must be of length 1. Only the first value ", - "will be used." + paste0("Parameter 'londim' must be of length 1. Only the first value ", + "will be used.") ) expect_error( WeightedMean(array(1:10, dim = c(lons = 10, lat = 1)), @@ -92,8 +92,8 @@ test_that("1. Input checks", { expect_warning( WeightedMean(array(1:10, dim = c(lon = 10, lat = 1)), lon = 1:10, lat = 1, latdim = 2), - "Numeric 'latdim' is deprecated, use dimension names instead. The ", - "corresponding dimension name will be assigned." + paste0("Numeric 'latdim' is deprecated, use dimension names instead. The ", + "corresponding dimension name will be assigned.") ) expect_error( WeightedMean(array(1:10, dim = c(lon = 10, lat = 1)), @@ -103,8 +103,8 @@ test_that("1. Input checks", { expect_warning( WeightedMean(array(1:10, dim = c(lon = 10, lat = 1)), lon = 1:10, lat = 1, latdim = c('lat', 'lon')), - "Parameter 'latdim' must be of length 1. Only the first value ", - "will be used." + paste0("Parameter 'latdim' must be of length 1. Only the first value ", + "will be used.") ) expect_error( WeightedMean(array(1:10, dim = c(lon = 10, lats = 1)), -- GitLab