Skip to content

Commit

Permalink
Merge pull request #33 from nutriverse/dev
Browse files Browse the repository at this point in the history
create test for calculate_team_tem; fix #26
  • Loading branch information
ernestguevarra authored Dec 18, 2024
2 parents 3ac92af + 2db06cb commit f018889
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
21 changes: 6 additions & 15 deletions R/04_calculate_team_tem.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,17 @@ calculate_team_tem <- function(n, k, m) {

if (!methods::is(m, "data.frame")) {
stop(
paste(
strwrap("Measurements should be supplied as a data frame.
Please check and try again.",
width = 80),
"\n",
collapse = "\n"
)
"Measurements should be supplied as a data frame. ",
"Please check and try again.",
call. = TRUE
)
}

if(ncol(m) != k | nrow(m) != n) {
stop(
paste(
strwrap("Measurements data frame should have rows equal to number of
subjects and columns equal to number of observers.
Please check and try again.",
width = 80),
"\n",
collapse = "\n"
)
"Measurements data frame should have rows equal to number of subjects ",
"and columns equal to number of observers. Please check and try again.",
call. = TRUE
)
}

Expand Down
14 changes: 14 additions & 0 deletions tests/testthat/test-04_calculate_team_tem.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Tests for calculate_team_tem -------------------------------------------------

team_tem <- calculate_team_tem(
n = 10, k = 4, m = stature[ , c("m1", "m2", "m3", "m4")]
)

test_that("calculate_team_tem works as expected", {
expect_type(team_tem, "double")
})

expect_error(calculate_team_tem(n = 10, k = 4, m = stature$m1))

expect_error(
calculate_team_tem(
n = 10, k = 4, m = stature[1:9, c("m1", "m2", "m3")]
)
)

0 comments on commit f018889

Please sign in to comment.