diff --git a/DESCRIPTION b/DESCRIPTION index 2abb9209..1b7fae39 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -60,4 +60,5 @@ Encoding: UTF-8 LazyData: true Roxygen: list(markdown = TRUE) RoxygenNote: 7.3.2 +Config/testthat/edition: 3 VignetteBuilder: knitr diff --git a/tests/testthat/GlanceNetCDF b/tests/testthat/GlanceNetCDF deleted file mode 100644 index 7263d018..00000000 --- a/tests/testthat/GlanceNetCDF +++ /dev/null @@ -1,11 +0,0 @@ ------ Variables ----- -air: - mean Daily Air temperature in degK - Dimensions: lon by lat by level by time - - ------ Dimensions ----- - time: 1 values from 2010-07-09 to 2010-07-09 - level: 17 values from 10 to 1000 millibar - lat: 73 values from -90 to 90 degrees_north - lon: 144 values from 0 to 357.5 degrees_east diff --git a/tests/testthat/_snaps/GetTopography.md b/tests/testthat/_snaps/GetTopography.md new file mode 100644 index 00000000..5d9c178f --- /dev/null +++ b/tests/testthat/_snaps/GetTopography.md @@ -0,0 +1,19 @@ +# GetTopography gets topography + + Code + topo + Output + lon lat h + + 1: 280.25 -0.25 263 + 2: 280.75 -0.25 289 + 3: 281.25 -0.25 1532 + 4: 281.75 -0.25 2830 + 5: 282.25 -0.25 2375 + --- + 11996: 327.75 -59.75 -3094 + 11997: 328.25 -59.75 -3413 + 11998: 328.75 -59.75 -2282 + 11999: 329.25 -59.75 -2966 + 12000: 329.75 -59.75 -2752 + diff --git a/tests/testthat/_snaps/ReadNetCDF.md b/tests/testthat/_snaps/ReadNetCDF.md new file mode 100644 index 00000000..b9c293a7 --- /dev/null +++ b/tests/testthat/_snaps/ReadNetCDF.md @@ -0,0 +1,36 @@ +# GlanceNetCDF prints nicely + + Code + print(GlanceNetCDF(file)) + Output + ----- Variables ----- + air: + mean Daily Air temperature in degK + Dimensions: lon by lat by level by time + + + ----- Dimensions ----- + time: 1 values from 2010-07-09 to 2010-07-09 + level: 17 values from 10 to 1000 millibar + lat: 73 values from -90 to 90 degrees_north + lon: 144 values from 0 to 357.5 degrees_east + +# subsetting works + + Code + ReadNetCDF(file, subset = s) + Output + time level lat lon air + + 1: 2010-07-09 1000 -70 0.0 249.07 + 2: 2010-07-09 1000 -70 2.5 249.82 + 3: 2010-07-09 1000 -70 5.0 250.32 + 4: 2010-07-09 1000 -70 7.5 250.62 + 5: 2010-07-09 1000 -70 10.0 250.77 + --- + 7493: 2010-07-09 10 70 347.5 242.17 + 7494: 2010-07-09 10 70 350.0 242.05 + 7495: 2010-07-09 10 70 352.5 241.95 + 7496: 2010-07-09 10 70 355.0 241.85 + 7497: 2010-07-09 10 70 357.5 241.70 + diff --git a/tests/testthat/_snaps/eof.md b/tests/testthat/_snaps/eof.md new file mode 100644 index 00000000..21425c48 --- /dev/null +++ b/tests/testthat/_snaps/eof.md @@ -0,0 +1,13 @@ +# eof methods + + Code + summary(eof) + Output + Importance of components: + Component Explained variance Cumulative variance + 1 100% 100% + 2 0% 100% + 3 0% 100% + 4 0% 100% + 5 0% 100% + diff --git a/tests/testthat/_snaps/interpolate.md b/tests/testthat/_snaps/interpolate.md new file mode 100644 index 00000000..44099bcb --- /dev/null +++ b/tests/testthat/_snaps/interpolate.md @@ -0,0 +1,183 @@ +# interpolate works + + Code + geopotential[, Interpolate(gh ~ lon + lat, x.out, y.out)] + Output + lon lat gh + + 1: 0 -90 2715.936 + 2: 10 -90 2715.936 + 3: 20 -90 2715.936 + 4: 30 -90 2715.936 + 5: 40 -90 2715.936 + --- + 366: 320 0 NA + 367: 330 0 NA + 368: 340 0 NA + 369: 350 0 NA + 370: 360 0 NA + +--- + + Code + geopotential[, Interpolate(gh ~ lon + lat, x.out, y.out, grid = FALSE)] + Output + lon lat gh + + 1: 0 -90 2715.936 + 2: 40 -80 2776.129 + 3: 80 -70 2722.968 + 4: 120 -60 2708.710 + 5: 160 -50 2928.774 + 6: 200 -40 3095.548 + 7: 240 -30 3170.258 + 8: 280 -20 NA + 9: 320 -10 NA + 10: 360 0 NA + +--- + + Code + geopotential[, Interpolate(gh ~ lon + lat, x.out, y.out, grid = FALSE)] + Output + lon lat gh + + 1: 0 -90 2715.936 + 2: 40 -80 2776.129 + 3: 80 -70 2722.968 + 4: 120 -60 2708.710 + 5: 160 -50 2928.774 + 6: 200 -40 3095.548 + 7: 240 -30 3170.258 + 8: 280 -20 NA + 9: 320 -10 NA + 10: 360 0 NA + +--- + + Code + geopotential[, Interpolate(u | v ~ lon + lat, x.out, y.out)] + Output + lon lat u v + + 1: 0 -90 NA 0.00000000 + 2: 40 -90 NA 0.00000000 + 3: 80 -90 NA 0.00000000 + 4: 120 -90 NA 0.00000000 + 5: 160 -90 NA 0.00000000 + 6: 200 -90 NA 0.00000000 + 7: 240 -90 NA 0.00000000 + 8: 280 -90 NA 0.00000000 + 9: 320 -90 NA 0.00000000 + 10: 360 -90 NA NA + 11: 0 -80 0.2060515 -5.40863143 + 12: 40 -80 -0.1545536 -0.59330168 + 13: 80 -80 -0.8718648 3.17222089 + 14: 120 -80 0.8639167 3.24061898 + 15: 160 -80 -1.1096189 1.32374501 + 16: 200 -80 0.4676200 1.11820527 + 17: 240 -80 3.7568859 -2.37337946 + 18: 280 -80 2.9325899 2.94388178 + 19: 320 -80 -0.1624718 -4.70116019 + 20: 360 -80 NA NA + 21: 0 -70 -4.2985774 1.84579405 + 22: 40 -70 -6.8237095 -5.57368410 + 23: 80 -70 -5.1208940 -2.82934752 + 24: 120 -70 -4.0576755 0.08501093 + 25: 160 -70 -0.2035282 -0.59507650 + 26: 200 -70 2.6331356 -0.13353609 + 27: 240 -70 1.7775944 -0.29142665 + 28: 280 -70 -1.1338483 -5.52515894 + 29: 320 -70 3.8085068 -0.64360166 + 30: 360 -70 NA NA + 31: 0 -60 3.5781696 3.53304644 + 32: 40 -60 8.8687692 -1.91979880 + 33: 80 -60 7.1743135 2.46953084 + 34: 120 -60 3.4114219 -1.33391364 + 35: 160 -60 10.9507454 0.25238969 + 36: 200 -60 7.9404185 -1.35199020 + 37: 240 -60 9.8511790 -0.21630479 + 38: 280 -60 7.2103984 0.26139387 + 39: 320 -60 1.4240577 2.06393378 + 40: 360 -60 NA NA + 41: 0 -50 18.3000222 0.23778405 + 42: 40 -50 17.6937333 -3.40017988 + 43: 80 -50 19.0234508 3.13072329 + 44: 120 -50 16.0023015 -2.11618203 + 45: 160 -50 16.2825038 -1.28399785 + 46: 200 -50 15.3450773 0.41216301 + 47: 240 -50 15.9972504 -1.77540222 + 48: 280 -50 15.1667842 1.15718769 + 49: 320 -50 15.2330272 2.71064214 + 50: 360 -50 NA NA + 51: 0 -40 19.2893933 -0.75294282 + 52: 40 -40 13.6974663 -1.91804865 + 53: 80 -40 13.5213788 2.51244878 + 54: 120 -40 14.3107397 -1.69616087 + 55: 160 -40 8.6701957 -0.80842976 + 56: 200 -40 12.1735190 0.97489059 + 57: 240 -40 8.7430294 -0.28529287 + 58: 280 -40 10.4491757 3.08315448 + 59: 320 -40 14.2196172 0.32494354 + 60: 360 -40 NA NA + 61: 0 -30 2.5367799 1.84769720 + 62: 40 -30 -0.2653629 0.38758871 + 63: 80 -30 0.4136992 0.12619485 + 64: 120 -30 6.8063350 -3.82145282 + 65: 160 -30 0.7570996 0.80212173 + 66: 200 -30 1.1474053 0.41460123 + 67: 240 -30 -0.5697742 0.76610504 + 68: 280 -30 1.3503855 2.76694139 + 69: 320 -30 6.8688359 -4.11893159 + 70: 360 -30 NA NA + 71: 0 -20 NA NA + 72: 40 -20 NA NA + 73: 80 -20 NA NA + 74: 120 -20 NA NA + 75: 160 -20 NA NA + 76: 200 -20 NA NA + 77: 240 -20 NA NA + 78: 280 -20 NA NA + 79: 320 -20 NA NA + 80: 360 -20 NA NA + 81: 0 -10 NA NA + 82: 40 -10 NA NA + 83: 80 -10 NA NA + 84: 120 -10 NA NA + 85: 160 -10 NA NA + 86: 200 -10 NA NA + 87: 240 -10 NA NA + 88: 280 -10 NA NA + 89: 320 -10 NA NA + 90: 360 -10 NA NA + 91: 0 0 NA NA + 92: 40 0 NA NA + 93: 80 0 NA NA + 94: 120 0 NA NA + 95: 160 0 NA NA + 96: 200 0 NA NA + 97: 240 0 NA NA + 98: 280 0 NA NA + 99: 320 0 NA NA + 100: 360 0 NA NA + lon lat u v + +--- + + Code + geopotential[, Interpolate(gh ~ lon + lat, as.path(lons, lats))] + Output + lon lat .order gh + + 1: 302.0000 -34.00000 1 3120.352 + 2: 299.3333 -38.44444 2 3087.826 + 3: 296.6667 -42.88889 3 3026.312 + 4: 294.0000 -47.33333 4 2956.951 + 5: 291.3333 -51.77778 5 2882.163 + 6: 290.0000 -54.00000 6 2841.716 + 7: 277.7778 -51.33333 7 2898.452 + 8: 253.3333 -46.00000 8 3051.176 + 9: 228.8889 -40.66667 9 3108.243 + 10: 204.4444 -35.33333 10 3136.094 + 11: 180.0000 -30.00000 11 3144.161 + diff --git a/tests/testthat/_snaps/trajectory.md b/tests/testthat/_snaps/trajectory.md new file mode 100644 index 00000000..ccbd3621 --- /dev/null +++ b/tests/testthat/_snaps/trajectory.md @@ -0,0 +1,14 @@ +# trajectory works + + Code + Trajectory(dlon + dlat ~ lon + lat + date, x0 = 180, y0 = -60, data = na.omit( + geopotential), res = 3, cyclical = c(TRUE, FALSE)) + Output + lon lat id piece date dlon dlat + + 1: 180.00000 -60.00000 1 1 631152000 1.527505e-04 -1.373291e-05 + 2: 316.37564 -72.26074 1 1 632044800 1.258644e-04 -4.088801e-06 + 3: 71.24737 -75.91122 1 2 632937600 -1.124835e-04 1.634286e-06 + 4: 328.32208 -74.45213 1 3 633830400 9.383545e-05 -1.294094e-05 + 5: 54.59837 -86.00580 1 4 634723200 6.627506e-04 -6.734548e-06 + diff --git a/tests/testthat/_snaps/waveflux.md b/tests/testthat/_snaps/waveflux.md new file mode 100644 index 00000000..40ff2e46 --- /dev/null +++ b/tests/testthat/_snaps/waveflux.md @@ -0,0 +1,19 @@ +# waveflux returns w.x and w.y + + Code + return + Output + w.x w.y + + 1: NA NA + 2: NA NA + 3: NA NA + 4: NA NA + 5: NA NA + --- + 4028: NA NA + 4029: NA NA + 4030: NA NA + 4031: NA NA + 4032: NA NA + diff --git a/tests/testthat/eof_print b/tests/testthat/eof_print deleted file mode 100644 index d4a08f75..00000000 --- a/tests/testthat/eof_print +++ /dev/null @@ -1,38 +0,0 @@ -left: - lat lon PC gh - - 1: -22.5 0.0 PC1 0.017593184 - 2: -22.5 2.5 PC1 0.017585293 - 3: -22.5 5.0 PC1 0.017580330 - 4: -22.5 7.5 PC1 0.017581851 - 5: -22.5 10.0 PC1 0.017592958 - --- -20156: -90.0 347.5 PC5 0.004206307 -20157: -90.0 350.0 PC5 0.004206307 -20158: -90.0 352.5 PC5 0.004206307 -20159: -90.0 355.0 PC5 0.004206307 -20160: -90.0 357.5 PC5 0.004206307 - -right: - date PC gh - - 1: 1990-01-01 PC1 0.12015851 - 2: 1990-02-01 PC1 0.11921023 - 3: 1990-03-01 PC1 0.11905844 - 4: 1990-04-01 PC1 0.11914120 - 5: 1990-05-01 PC1 0.11874389 - --- -356: 1995-08-01 PC5 0.07093237 -357: 1995-09-01 PC5 -0.01593794 -358: 1995-10-01 PC5 -0.01926659 -359: 1995-11-01 PC5 0.26030288 -360: 1995-12-01 PC5 0.15063041 - -sdev: - PC sd r2 - -1: PC1 1524593.818 9.997635e-01 -2: PC2 15617.405 1.049075e-04 -3: PC3 8444.272 3.066998e-05 -4: PC4 6126.190 1.614247e-05 -5: PC5 5176.628 1.152611e-05 diff --git a/tests/testthat/eof_summary b/tests/testthat/eof_summary deleted file mode 100644 index 46e467e9..00000000 --- a/tests/testthat/eof_summary +++ /dev/null @@ -1,7 +0,0 @@ -Importance of components: -Component Explained variance Cumulative variance - 1 100% 100% - 2 0% 100% - 3 0% 100% - 4 0% 100% - 5 0% 100% diff --git a/tests/testthat/interpolate1 b/tests/testthat/interpolate1 deleted file mode 100644 index d938aec8..00000000 Binary files a/tests/testthat/interpolate1 and /dev/null differ diff --git a/tests/testthat/interpolate2 b/tests/testthat/interpolate2 deleted file mode 100644 index f7b97904..00000000 Binary files a/tests/testthat/interpolate2 and /dev/null differ diff --git a/tests/testthat/interpolate3 b/tests/testthat/interpolate3 deleted file mode 100644 index 88cbd206..00000000 Binary files a/tests/testthat/interpolate3 and /dev/null differ diff --git a/tests/testthat/interpolate4 b/tests/testthat/interpolate4 deleted file mode 100644 index 8e31423f..00000000 Binary files a/tests/testthat/interpolate4 and /dev/null differ diff --git a/tests/testthat/readnetcdf_unnamed_subset b/tests/testthat/readnetcdf_unnamed_subset deleted file mode 100644 index 6a4bb55b..00000000 Binary files a/tests/testthat/readnetcdf_unnamed_subset and /dev/null differ diff --git a/tests/testthat/test-GetTopography.R b/tests/testthat/test-GetTopography.R index 6290a792..b2a0565b 100644 --- a/tests/testthat/test-GetTopography.R +++ b/tests/testthat/test-GetTopography.R @@ -5,7 +5,7 @@ test_that("GetTopography gets topography", { expect_s3_class(GetTopography(280, 330, 0, -60, resolution = 0.5, file.dir = "~"), "data.frame") topo <- GetTopography(280, 330, 0, -60, resolution = 0.5) - expect_known_value(topo, "topography") + expect_snapshot(topo) expect_message(GetTopography(280, 330, 0, -60, resolution = 0.5, verbose = TRUE), "Fetching cached field.") }) diff --git a/tests/testthat/test-ReadNetCDF.R b/tests/testthat/test-ReadNetCDF.R index b1c0472d..45bb72f9 100644 --- a/tests/testthat/test-ReadNetCDF.R +++ b/tests/testthat/test-ReadNetCDF.R @@ -1,5 +1,3 @@ - -context("ReadNetCDF") skip_if_not_installed(c("ncdf4", "CFtime")) file <- system.file("extdata", "temperature.nc", package = "metR") test_that("returns a data.table", { @@ -8,7 +6,7 @@ test_that("returns a data.table", { }) test_that("GlanceNetCDF prints nicely", { - expect_known_output(print(GlanceNetCDF(file)), "GlanceNetCDF") + expect_snapshot(print(GlanceNetCDF(file))) }) @@ -23,7 +21,7 @@ test_that("subsetting works", { list(lat = -90:-70, lon = 0:60), list(lat = 70:90, lon = 300:360) ) - expect_known_value(ReadNetCDF(file, subset = s), "readnetcdf_unnamed_subset") + expect_snapshot(ReadNetCDF(file, subset = s)) }) @@ -37,8 +35,8 @@ test_that("naming works", { test_that("different outs work", { expect_s3_class(ReadNetCDF(file), "data.table") - expect_is(ReadNetCDF(file, out = "array")[[1]], "array") - expect_is(ReadNetCDF(file, out = "vector")[[1]], "numeric") + expect_equal(class(ReadNetCDF(file, out = "array")[[1]]), "array") + expect_type(ReadNetCDF(file, out = "vector")[[1]], "double") }) diff --git a/tests/testthat/test-breaks.R b/tests/testthat/test-breaks.R index 072f6e3a..213c584a 100644 --- a/tests/testthat/test-breaks.R +++ b/tests/testthat/test-breaks.R @@ -1,13 +1,6 @@ -library(metR) - - -context("Breaks") - test_that("functions return functions", { - expect_equal(is.function(MakeBreaks()), - TRUE) - expect_equal(is.function(AnchorBreaks()), - TRUE) + expect_true(is.function(MakeBreaks())) + expect_true(is.function(AnchorBreaks())) }) test_that("Anchor is in breaks", { diff --git a/tests/testthat/test-derivate.R b/tests/testthat/test-derivate.R index a8aefef8..5bdf66ef 100644 --- a/tests/testthat/test-derivate.R +++ b/tests/testthat/test-derivate.R @@ -1,5 +1,3 @@ -context("Derivate internals") - test_derv <- function(y, cyclical = FALSE, fill = FALSE, equispaced = TRUE) { y <- sort(y) x <- sin(y) @@ -52,7 +50,6 @@ test_that("Works with unequal grid", { }) -context("Derivate interface") test_that("Derivative works", { expect_equal({ x <- 1:10 diff --git a/tests/testthat/test-eof.R b/tests/testthat/test-eof.R index a56c0a41..f1ae1f4f 100644 --- a/tests/testthat/test-eof.R +++ b/tests/testthat/test-eof.R @@ -1,5 +1,4 @@ -context("EOF") data(geopotential) test_that("EOF runs", { expect_s3_class({ @@ -42,12 +41,16 @@ test_that("EOF rotates", { round(EOF(gh ~ lon + lat | date, data = geopotential, n = 1:2, rotate = function(x) stats::varimax(x, normalize = FALSE))$sdev$sd), c(1424982, 542271) ) - + expect_warning( + compare_val <- EOF(gh ~ lon + lat | date, data = geopotential, n = 1:2, + rotate = TRUE)$sdev$sd, + "deprecated" + ) expect_equal( EOF(gh ~ lon + lat | date, data = geopotential, n = 1:2, rotate = function(x) stats::varimax(x, normalize = FALSE))$sdev$sd, - expect_warning(EOF(gh ~ lon + lat | date, data = geopotential, n = 1:2, - rotate = TRUE)$sdev$sd, "deprecated")) + compare_val + ) }) @@ -83,6 +86,6 @@ test_that("eof methods", { expect_equal(predict(eof_all, n = 1:5), predict(eof)) - expect_known_output(summary(eof), file = "eof_summary") + expect_snapshot(summary(eof)) }) diff --git a/tests/testthat/test-fitlm.R b/tests/testthat/test-fitlm.R index b3588d4a..ff9537c9 100644 --- a/tests/testthat/test-fitlm.R +++ b/tests/testthat/test-fitlm.R @@ -1,6 +1,3 @@ -context("Fitlm") - - n <- 100 x <- rnorm(n) y <- rnorm(n) diff --git a/tests/testthat/test-imputeeof.R b/tests/testthat/test-imputeeof.R index 6f67800e..5fd88d68 100644 --- a/tests/testthat/test-imputeeof.R +++ b/tests/testthat/test-imputeeof.R @@ -1,7 +1,3 @@ -library(metR) - -context("Impute EOF") - library(data.table) data(geopotential) geopotential <- copy(geopotential) diff --git a/tests/testthat/test-interpolate.R b/tests/testthat/test-interpolate.R index 39336a19..6f12fff3 100644 --- a/tests/testthat/test-interpolate.R +++ b/tests/testthat/test-interpolate.R @@ -1,5 +1,3 @@ - -context("interpolate") library(data.table) data(geopotential) geopotential <- geopotential[date == date[1]] @@ -10,20 +8,20 @@ y.out <- seq(-90, 0, by = 10) # Interpolate values to a new grid test_that("interpolate works" , { - expect_known_value(geopotential[, Interpolate(gh ~ lon + lat, x.out, y.out)], "interpolate1") + expect_snapshot(geopotential[, Interpolate(gh ~ lon + lat, x.out, y.out)]) x.out <- seq(0, 360, length.out = 10) y.out <- seq(-90, 0, length.out = 10) - expect_known_value(geopotential[, Interpolate(gh ~ lon + lat, x.out, y.out, grid = FALSE)], "interpolate2") + expect_snapshot(geopotential[, Interpolate(gh ~ lon + lat, x.out, y.out, grid = FALSE)]) - expect_known_value(geopotential[, Interpolate(gh ~ lon + lat, x.out, y.out, grid = FALSE)], "interpolate2") + expect_snapshot(geopotential[, Interpolate(gh ~ lon + lat, x.out, y.out, grid = FALSE)]) geopotential[, c("u", "v") := GeostrophicWind(gh, lon, lat)] - expect_known_value(geopotential[, Interpolate(u | v ~ lon + lat, x.out, y.out)], "interpolate3") + expect_snapshot(geopotential[, Interpolate(u | v ~ lon + lat, x.out, y.out)]) lats <- c(-34, -54, -30) # start and end latitudes lons <- c(302, 290, 180) # start and end longituded - expect_known_value(geopotential[, Interpolate(gh ~ lon + lat, as.path(lons, lats))], "interpolate4") + expect_snapshot(geopotential[, Interpolate(gh ~ lon + lat, as.path(lons, lats))]) }) diff --git a/tests/testthat/test-season.R b/tests/testthat/test-season.R index a816fc32..a67cb6f4 100644 --- a/tests/testthat/test-season.R +++ b/tests/testthat/test-season.R @@ -1,6 +1,3 @@ - -context("season functions") - levels <- c("DJF", "MAM", "JJA", "SON") niveles <- c("DEF", "MAM", "JJA", "SON") diff --git a/tests/testthat/test-smallfun.R b/tests/testthat/test-smallfun.R index 27b2faa1..9ec7b372 100644 --- a/tests/testthat/test-smallfun.R +++ b/tests/testthat/test-smallfun.R @@ -1,7 +1,3 @@ -library(metR) - -context("Small functions") - test_that("Percentile works", { expect_equal(Percentile(1:10), seq(0.1, 1, by = 0.1)) diff --git a/tests/testthat/test-trajectory.R b/tests/testthat/test-trajectory.R index 161e757c..1c0963b9 100644 --- a/tests/testthat/test-trajectory.R +++ b/tests/testthat/test-trajectory.R @@ -6,9 +6,9 @@ geopotential[, `:=`(dlon = dlon(u, lat), dlat = dlat(v))] test_that("trajectory works", { - expect_known_value(Trajectory(dlon + dlat ~ lon + lat + date, x0 = 180, y0 = -60, + expect_snapshot(Trajectory(dlon + dlat ~ lon + lat + date, x0 = 180, y0 = -60, data = na.omit(geopotential), res = 3, - cyclical = c(TRUE, FALSE)), "trajectory1") + cyclical = c(TRUE, FALSE))) expect_error( Trajectory(dlon ~ lon + lat + date, x0 = 180, y0 = -60, diff --git a/tests/testthat/test-vis-arrow.R b/tests/testthat/test-vis-arrow.R index b28ccb44..9ff1d94f 100644 --- a/tests/testthat/test-vis-arrow.R +++ b/tests/testthat/test-vis-arrow.R @@ -4,8 +4,6 @@ skip_if_not_installed("vdiffr") library(vdiffr) library(ggplot2) -context("arrows") - test_that("arrow guide works", { g <- ggplot(seals, aes(long, lat)) + diff --git a/tests/testthat/test-vis-contour2.R b/tests/testthat/test-vis-contour2.R index bead6bfc..02789a98 100644 --- a/tests/testthat/test-vis-contour2.R +++ b/tests/testthat/test-vis-contour2.R @@ -4,7 +4,6 @@ skip_if_not_installed("vdiffr") library(vdiffr) library(ggplot2) -context("stat_contour2") data(geopotential) geo <- subset(geopotential, date == date[1]) test_that("geom_contour2 mimics geom_contour", { diff --git a/tests/testthat/test-vis-contour_fill.R b/tests/testthat/test-vis-contour_fill.R index 0ae74a0a..7f9157ba 100644 --- a/tests/testthat/test-vis-contour_fill.R +++ b/tests/testthat/test-vis-contour_fill.R @@ -6,8 +6,6 @@ library(data.table) library(ggplot2) -context("contour_fill") - test_that("geom_contour_fill works", { skip_on_ci() expect_doppelganger("contour_fill-base", diff --git a/tests/testthat/test-vis-discretised-scale.R b/tests/testthat/test-vis-discretised-scale.R index f95e7a18..1d30eb33 100644 --- a/tests/testthat/test-vis-discretised-scale.R +++ b/tests/testthat/test-vis-discretised-scale.R @@ -3,7 +3,6 @@ skip_if_not_installed("vdiffr") library(ggplot2) library(vdiffr) -context("discretised_scale") v <- ggplot(faithfuld, aes(waiting, eruptions, z = density)) v <- v + geom_contour_filled() diff --git a/tests/testthat/test-vis-geom-relief.R b/tests/testthat/test-vis-geom-relief.R index 33d29909..b544afea 100644 --- a/tests/testthat/test-vis-geom-relief.R +++ b/tests/testthat/test-vis-geom-relief.R @@ -6,7 +6,6 @@ library(ggplot2) data(volcano) v <- reshape2::melt(volcano) -context("geom_relief") test_that("geom-relief", { expect_doppelganger("volcano-relief", ggplot(v, aes(Var1, Var2)) + diff --git a/tests/testthat/test-vis-guide_colorstrip.R b/tests/testthat/test-vis-guide_colorstrip.R index 93efbc4c..2ff809c9 100644 --- a/tests/testthat/test-vis-guide_colorstrip.R +++ b/tests/testthat/test-vis-guide_colorstrip.R @@ -4,7 +4,6 @@ skip_if_not_installed("vdiffr") library(vdiffr) library(ggplot2) -context("guide_colourstrip") data(geopotential) geo <- geopotential[date == date[1]] base <- ggplot(geo, aes(lon, lat)) + diff --git a/tests/testthat/test-vis-streamline.R b/tests/testthat/test-vis-streamline.R index 8bf1c086..ca58cf92 100644 --- a/tests/testthat/test-vis-streamline.R +++ b/tests/testthat/test-vis-streamline.R @@ -5,7 +5,6 @@ library(ggplot2) library(data.table) library(vdiffr) -context("Streamline") geo <- geopotential[date == date[1]] geo[, c("u", "v") := GeostrophicWind(gh, lon, lat)] diff --git a/tests/testthat/test-vis-text-contour.R b/tests/testthat/test-vis-text-contour.R index 0e724f8d..716165be 100644 --- a/tests/testthat/test-vis-text-contour.R +++ b/tests/testthat/test-vis-text-contour.R @@ -4,7 +4,6 @@ skip_if_not_installed("vdiffr") library(ggplot2) library(vdiffr) -context("text_contour") data(geopotential) geo <- subset(geopotential, date == date[1]) diff --git a/tests/testthat/test-waveflux.R b/tests/testthat/test-waveflux.R index 2e8eb762..8e790ea9 100644 --- a/tests/testthat/test-waveflux.R +++ b/tests/testthat/test-waveflux.R @@ -4,6 +4,6 @@ geo <- geopotential[date == date[1]][, c("u", "v") := GeostrophicWind(gh, lon, l test_that("waveflux returns w.x and w.y", { return <- with(geo, WaveFlux(gh, u, v, lon, lat, lev = 700)) - expect_known_output(return, "waveflux-return") + expect_snapshot(return) }) diff --git a/tests/testthat/test-waves.R b/tests/testthat/test-waves.R index 37a6e7ff..3c52779c 100644 --- a/tests/testthat/test-waves.R +++ b/tests/testthat/test-waves.R @@ -1,7 +1,3 @@ - - -context("FitWave") - t <- seq(0, 2*pi, length.out = 100)[-1] x <- 3*cos(t) + 2*cos(2*t) diff --git a/tests/testthat/test_text_contour.R b/tests/testthat/test_text_contour.R index b45175f0..9f0b57bc 100644 --- a/tests/testthat/test_text_contour.R +++ b/tests/testthat/test_text_contour.R @@ -1,5 +1,4 @@ -# context("tex_contour") # v <- reshape2::melt(volcano) # g <- ggplot(v, aes(Var1, Var2, z = value)) + # geom_contour() diff --git a/tests/testthat/tests.R b/tests/testthat/tests.R index 9d80932f..033d4ff0 100644 --- a/tests/testthat/tests.R +++ b/tests/testthat/tests.R @@ -1,7 +1,6 @@ library(metR) -context("season") test_that("season assigns season", { expect_equal(as.character(season(1)), "DJF") expect_equal(as.character(season(1, lang = "es")), @@ -15,10 +14,8 @@ test_that("season assigns season", { -context("MaskLand") -test_that("Water is still water", { +test_that("Maskland Water is still water", { skip_if_not_installed("maps") - expect_equal(MaskLand(120, 14), FALSE) expect_equal(MaskLand(360-58, -34), TRUE) expect_equal(MaskLand(-58, -34, wrap = c(-180, 180)), TRUE) diff --git a/tests/testthat/topography b/tests/testthat/topography deleted file mode 100644 index 7d72eb66..00000000 Binary files a/tests/testthat/topography and /dev/null differ diff --git a/tests/testthat/trajectory1 b/tests/testthat/trajectory1 deleted file mode 100644 index 4cf8c4b5..00000000 Binary files a/tests/testthat/trajectory1 and /dev/null differ diff --git a/tests/testthat/waveflux-return b/tests/testthat/waveflux-return deleted file mode 100644 index e69de29b..00000000