Skip to content

Commit

Permalink
ctdTrim gets better test
Browse files Browse the repository at this point in the history
  • Loading branch information
dankelley committed May 3, 2018
1 parent 2c52974 commit ddd3c4c
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions tests/testthat/test_ctd.R
Original file line number Diff line number Diff line change
Expand Up @@ -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="")]])
}
})

Expand Down

0 comments on commit ddd3c4c

Please sign in to comment.