Skip to content

Commit

Permalink
adding tests for sw_combine, sw_combine_plot and sw_interval
Browse files Browse the repository at this point in the history
  • Loading branch information
hanecakr committed Nov 19, 2023
1 parent b42b764 commit 708a781
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .Rproj.user/429CC01A/pcs/files-pane.pper
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"ascending": false
}
],
"path": "C:/Users/hanecakr/Documents/R_github/fellingdateR"
"path": "C:/Users/hanecakr/Documents/R_github/fellingdateR/tests/testthat"
}
2 changes: 1 addition & 1 deletion .Rproj.user/429CC01A/pcs/source-pane.pper
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"activeTab": 20,
"activeTab": 21,
"activeTabSourceWindow0": 0
}
2 changes: 1 addition & 1 deletion .Rproj.user/429CC01A/pcs/workbench-pane.pper
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"TabSet1": 4,
"TabSet1": 0,
"TabSet2": 0,
"TabZoom": {}
}
6 changes: 5 additions & 1 deletion .Rproj.user/429CC01A/rmd-outputs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
C:/Users/hanecakr/Documents/R_github/fellingdateR/inst/paper/paper.pdf
C:/Users/hanecakr/Documents/R_github/fellingdateR/inst/paper/paper.pdf
C:/Users/hanecakr/Documents/R_github/fellingdateR/inst/paper/paper.pdf

C:/Users/hanecakr/Documents/R_github/fellingdateR/inst/paper/paper.pdf





8 changes: 8 additions & 0 deletions R/sw_interval_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@
#' @export
#'
sw_interval_plot <- function(x) {

if (all(
!(attributes(x)$names) %in% c(
"year",
"n_sapwood",
"p")
))
stop("Input differs from output sw_interval()")
# to avoid notes in CMD check
p.x <- upper <- year <- NULL

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-fd_report.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ testthat::test_that("Waneyedge gives exact date", {
)
})

testthat::test_that("No Waneyedge gives bewteen date", {
testthat::test_that("No Waneyedge gives between date", {
x <- fd_report(testdata
)
testthat::expect_equal(
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test-sw_combine.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
testthat::test_that("Output is a data.frame", {
x <- sw_combine(fellingdateR:::dummy2, plot = FALSE)
testthat::expect_s3_class(x$rawData, "data.frame")
testthat::expect_s3_class(x$individual_series, "data.frame")
testthat::expect_type(x$model_summary, "character")
})
5 changes: 5 additions & 0 deletions tests/testthat/test-sw_combine_plot.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Test if the function returns a ggplot object
testthat::test_that("sw_combine_plot() returns a ggplot object", {
int <- sw_combine(fellingdateR:::dummy2, plot = FALSE)
testthat::expect_true("ggproto" %in% class(sw_combine_plot(int)$layers[[1]]$stat))
})
11 changes: 11 additions & 0 deletions tests/testthat/test-sw_interval_plot.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Test if the function returns a ggplot object
testthat::test_that("sw_interval_plot() returns a ggplot object", {
int <- sw_interval(n_sapwood = 10,
last = 1000,
hdi = FALSE,
credMass = .95,
sw_data = "Hollstein_1980",
densfun = "lognormal",
plot = FALSE)
testthat::expect_true("ggproto" %in% class(sw_interval_plot(int)$layers[[1]]$stat))
})

0 comments on commit 708a781

Please sign in to comment.