Skip to content

Commit

Permalink
added tests for nr of time points, sites
Browse files Browse the repository at this point in the history
  • Loading branch information
markvanderloo committed Aug 10, 2016
1 parent 521734a commit ed5c877
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
31 changes: 31 additions & 0 deletions pkg/R/parse_outfile.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,37 @@ print.tof <- function(x,...){
cat(x)
}


#' Extract nr of times from \code{tof} object
#'
#' @param x An object of class \code{tof}
#'
#' @return \code{numeric}
#' @family parse_output
#' @keywords internal
get_n_site <- function(x){
mm <- regexpr("Site[[:blank:]]{5,}.*?\n",x)
s <- regmatches(x,mm)
get_num(s)
}


#' Extract nr of sites from \code{tof} object
#'
#' @param x An object of class \code{tof}
#'
#' @return \code{numeric}
#' @family parse_output
#' @keywords internal
get_n_time <- function(x){
mm <- regexpr("Time[[:blank:]]{5,}.*?\n",x)
s <- regmatches(x,mm)
get_num(s)
}




#' Extract time indices from \code{tof} object
#'
#' @param x An object of class \code{tof}
Expand Down
6 changes: 5 additions & 1 deletion pkg/tests/testthat/test_trim.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ test_that("skylark-1d model",{
tc <- read_tcf("outfiles/skylark-1d.tcf")
m <- trim(tc)
to <- read_tof("outfiles/skylark-1d.out")


# data basics
expect_equal(m$nsite, get_n_site(to))
expect_equal(m$ntime, get_n_time(to))

# time index check
tgt <- get_time_indices(to)
out <- index(m,"both")
Expand Down

0 comments on commit ed5c877

Please sign in to comment.