tests/testthat/test-add_rh.R

test_that("Add relative humidity ", {
    
    expect_error(met_new <- add_rh(c(1, 2), c(3, 4)))
    expect_error(met_new <- add_rh(c(1, 2), c(3)))
    apsim <- system.file("extdata/ppd_72150.met", package = "weaana")
    standard <- system.file("extdata/drill_-35_147.txt", package = "weaana")
    
    
    met_new <- add_rh(apsim, standard)
    expect_equal(is.null(met_new$rhmint), FALSE)
    expect_equal(is.null(met_new$rhmaxt), FALSE)
    
    
    tmp_file <- tempfile(fileext = ".met")
    expect_no_error(met_new <- add_rh(apsim, standard, output = tmp_file))
    expect_error(met_new <- add_rh(apsim, standard, output = tmp_file))
    expect_no_error(met_new <- add_rh(apsim, standard, output = tmp_file, overwrite = TRUE))
    
    records2 <- readWeatherRecords(tmp_file) |> 
        getWeatherRecords()
    
    expect_equal(is.null(met_new$rhmint), FALSE)
    expect_equal(is.null(met_new$rhmaxt), FALSE)
    
    
    file.remove(tmp_file)
})

Try the weaana package in your browser

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

weaana documentation built on Nov. 5, 2025, 6:08 p.m.