Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
NiklasHohmann committed Apr 30, 2024
1 parent 6760d27 commit 278961d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
4 changes: 3 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ Imports:
StratigrapheR
Suggests:
knitr,
rmarkdown
rmarkdown,
testthat (>= 3.0.0)
VignetteBuilder: knitr
Config/testthat/edition: 3
4 changes: 2 additions & 2 deletions R/rename_facies.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ rename_facies = function(s, new_names, old_names = NULL){
rename_facies.stratcol = function(s, new_names, old_names = NULL){
#' @export
if (is.null(old_names)){
old_names = unique(s$fa)
old_names = unique_facies_names.stratcol(s)
}

new_fa = rep(NA, length(s$fa))
new_fa = rep(NA, no_facies.stratcol(s))
for ( i in seq_along(old_names)){
new_fa = replace(new_fa, s$fa == old_names[i], new_names[i])
}
Expand Down
12 changes: 12 additions & 0 deletions tests/testthat.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file is part of the standard setup for testthat.
# It is recommended that you do not modify it.
#
# Where should you do additional test configuration?
# Learn more about the roles of various files in:
# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview
# * https://testthat.r-lib.org/articles/special-files.html

library(testthat)
library(stratcols)

test_check("stratcols")
6 changes: 6 additions & 0 deletions tests/testthat/test_rename_facies.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
test_that("facies renaming works", {
s = as_stratcol(runif(10), rep(c(1,2), 5))
new_names = c(2,3)
s2 = rename_facies(s, new_names)
expect_equal(unique_facies_names(s2), new_names)
})

0 comments on commit 278961d

Please sign in to comment.