Skip to content

Commit

Permalink
test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
mjskay committed Feb 23, 2024
1 parent 66cf523 commit 5a41d60
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .lintr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ linters: all_linters(
infix_spaces_linter(exclude_operators = c("/", "*")),
keyword_quote_linter = NULL,
line_length_linter(120L),
missing_argument_linter(except = c("alist", "quote", "switch", "pairlist2", "lapply")),
missing_argument_linter(except = c("alist", "quote", "switch", "pairlist2", "lapply", "map_dfr_")),
nested_ifelse_linter = NULL,
nested_pipe_linter = NULL,
nonportable_path_linter = NULL,
Expand All @@ -22,7 +22,7 @@ linters: all_linters(
regexes = c(
misc = "^(F_x|f_X|x_1_hat,x_n_hat|R_inv|Amat|Aind|.*ABC.*|)$",
CamelCase = "^(RankCorr.*|.*Geom.*|.*Stat.*|Scale.*|Position.*|K|Mode.*|.*Pr.*|.*linearGradient.*|\\.Deprecated.*)$",
dot.case = "^(na\\.rm|na\\.translate|na\\.value|lower\\.tail|log\\.p|width\\.cutoff)$",
dot.case = "^(na\\.rm|na\\.translate|na\\.value|lower\\.tail|log\\.p|width\\.cutoff|check\\.overlap|n\\.dodge)$",
bandwidth = "^(bandwidth_.*)$",
breaks = "^breaks_.*$"
)
Expand Down
3 changes: 2 additions & 1 deletion R/compat.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ eval_select_ = function(expr, data, env = caller_env(), ..., error_call = caller
"Column names must select exactly 1 column.",
"x" = "Found {length(i)} columns named {.val {as_name(expr)}}."
),
call = error_call
call = error_call,
class = "ggdist_invalid_column_selection"
)
}
i
Expand Down
10 changes: 10 additions & 0 deletions tests/testthat/test.curve_interval.R
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ test_that("basic cases on multiple variables", {

expect_equal(curve_interval(df, .along = x, .width = c(.95, 0, 1)), ref)
expect_equal(curve_interval(group_by(df, x), y1, y2, .width = c(.95, 0, 1)), ref)
expect_equal(
curve_interval(mutate(df, y = x + 1), .along = c(x, y), .width = c(.95, 0, 1)),
mutate(ref, y = x + 1, .after = 1)
)
})


Expand All @@ -179,6 +183,12 @@ test_that("basic cases on multiple variables", {
test_that("error is thrown when no columns found to summarize", {
df = data.frame(value = ppoints(10))
expect_error(curve_interval(df, .exclude = "value"), "No columns found to calculate point and interval summaries for")
expect_error(curve_interval(df, .along = x))
})

test_that("error is thrown when along does not match a column", {
df = data.frame(value = ppoints(10))
expect_error(curve_interval(df, .along = x), class = "ggdist_invalid_column_selection")
})

test_that("error is thrown with groups of different sizes", {
Expand Down

0 comments on commit 5a41d60

Please sign in to comment.