inst/tests/test_fileHandling.R

#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#+++ Unit tests for fConvertTimeToPosix functions +++
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Author: TW
#require(testthat)
context("fileHandling")

#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

test_that_ <- function(...){}	# for uncommenting tests

test_that_("fLoadFluxNCIntoDataframe",{
			Dir.s <- paste(system.file(package='REddyProc'), 'examples', sep='/')
			for( ncPack in c("ncdf4","RNetCDF")){
				if( tmp <- requireNamespace(ncPack, quietly=TRUE) ){
					ds <- fLoadFluxNCIntoDataframe(c('NEE', 'Rg', 'NEE_f')
							, 'Example_DE-Tha.1996.1998.hourly.nc', Dir.s
							, NcPackage.s=ncPack
					)
					colNames <- c("DateTime", "year", "month", "day", "hour", "NEE", "Rg", "NEE_f")
					expect_true( nrow(ds) > 2000L )
					expect_true( all(colNames %in% names(ds)) )
					expect_true( inherits(ds$DateTime,"POSIXct") )
					colName <- colNames[2]
					for( colName in colNames[-1] ){
						expect_true( inherits(ds[[colName]], "numeric"))
					}
				} #if
			} # for
		})

Try the REddyProc package in your browser

Any scripts or data that you put into this service are public.

REddyProc documentation built on May 2, 2019, 5:19 p.m.