From ddd3c4c01d014a624a123e26a7547cc7bd65bb8c Mon Sep 17 00:00:00 2001 From: dankelley Date: Thu, 3 May 2018 16:14:21 -0300 Subject: [PATCH] ctdTrim gets better test --- tests/testthat/test_ctd.R | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/tests/testthat/test_ctd.R b/tests/testthat/test_ctd.R index 0596a1bdbe..f68c537b66 100644 --- a/tests/testthat/test_ctd.R +++ b/tests/testthat/test_ctd.R @@ -92,13 +92,21 @@ test_that("as.ctd() with an argo object, by profile", { }) test_that("ctdTrim indices argument", { - data(ctd) - a <- ctdTrim(ctd, method="sbe") - b <- ctdTrim(ctd, method="sbe", indices=TRUE) - for (name in names(a[["data"]])) { + data(ctdRaw) + a <- ctdRaw + ## Insert a crazy flag, not for conventional use, but only + ## to trace whether subsetting works as intended. + a[["salinityFlag"]] <- seq_along(a[["salinity"]]) + b <- ctdTrim(a, method="sbe") + c <- ctdTrim(a, method="sbe", indices=TRUE) + for (name in names(b[["data"]])) { ## Must use oceGetData because [["time"]] grabs 'time' from ## the metadata, which is a scalar. - expect_equal(oceGetData(ctd, name)[b], oceGetData(a, name)) + expect_equal(oceGetData(a, name)[c], oceGetData(b, name)) + } + ## Demonstrate that it works for flags + for (name in names(a[["flags"]])) { + expect_equal(a[[paste(name, "flag", sep="")]][c], b[[paste(name, "flag", sep="")]]) } })