context("test-r-anthropometric.R")
test_that("bmi calculations are correct", {
expect_error(calculate_bmi(weight = "70", height = 180))
expect_error(calculate_bmi(weight = 70, height = "180"))
expect_equal(calculate_bmi(weight = 70, height = 180), 21.605, tolerance = 0.001)
})
test_that("pi calculations are correct", {
expect_error(calculate_pi(weight = "70", height = 180))
expect_error(calculate_pi(weight = 70, height = "180"))
expect_equal(calculate_pi(weight = 70, height = 180), 12.003, tolerance = 0.001)
})
test_that("bmi prime calculations are correct", {
expect_error(calculate_bmi_prime(bmi = "22"))
expect_equal(calculate_bmi_prime(bmi = 22), 0.88)
})
test_that("calculate_bsa works", {
expect_equal(calculate_bsa(70, 180, equation = "Du-Bois"),
1.886277,
tolerance = 0.0001
)
expect_equal(calculate_bsa(70, 180, equation = "Haycock"),
1.867515,
tolerance = 0.0001
)
expect_equal(calculate_bsa(70, 180, equation = "Gehan-George"),
1.876048,
tolerance = 0.0001
)
expect_equal(calculate_bsa(70, 180, equation = "Fujimoto"),
1.832436,
tolerance = 0.0001
)
expect_equal(calculate_bsa(70, 180, equation = "Takahira"),
1.901244,
tolerance = 0.0001
)
expect_equal(calculate_bsa(70, 180, equation = "Shuter-Aslani"),
1.854206,
tolerance = 0.0001
)
expect_equal(calculate_bsa(70, 180, sex = "male", equation = "Schlich"),
1.82269,
tolerance = 0.0001
)
expect_equal(
calculate_bsa(70, 180, sex = "female", equation = "Schlich"),
1.87784,
tolerance = 0.0001
)
expect_equal(calculate_bsa(70, 180, equation = "costeff"),
1.79375,
tolerance = 0.0001
)
})
test_that("equation in calculate_bsa can not be recognised", {
expect_error(calculate_bsa(equation = "unknown"))
})
test_that("Mean body surface area is calculated correctly", {
expect_true(is.data.frame(calculate_mean_bsa(
weight = 80,
height = 180,
sex = "male"
)))
expect_equal(
class(calculate_mean_bsa(
weight = 80,
height = 180,
sex = "male"
)),
c("tbl_df", "tbl", "data.frame")
)
expect_equal(
calculate_mean_bsa(
weight = 80,
height = 180,
sex = "male"
),
structure(
list(
Equation = c(
"Du-Bois",
"Mosteller",
"Haycock",
"Gehan-George",
"Fujimoto",
"Takahira",
"Shuter-Aslani",
"Schlich",
"Costeff",
"Mean"
),
"Body surface area" = c(
2, 2, 2.01, 2.01, 1.94,
2.01, 1.97, 1.92, 1.92, 1.98
)
),
class = c("tbl_df", "tbl", "data.frame"),
row.names = c(NA, -10L)
)
)
})
test_that("calculate_sbsi", {
expect_equal(calculate_sbsi(height=180, bsa = 2, vtc = 175, waist = 92), 0.11, tolerance = 0.01)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.